Skip to content

Instantly share code, notes, and snippets.

lol no

Cameron Tod cam8001

lol no
  • Wellington, New Zealand
View GitHub Profile
cam8001 /
Last active May 22, 2023 22:50
`Failed to delete stack: Role <role> is invalid or cannot be assumed` Assume this role from the cli if your cloudformation stack can't delete

Create a role with a trust policy that can be assumed by Cloudformation. Trust policy looks like this:

    "Version": "2012-10-17",
    "Statement": [
            "Sid": "",
 "Effect": "Allow",
cam8001 / http-apigw-log-format.json
Created May 13, 2023 07:43
Logging config for API Gateway JSON format with all variable included
View http-apigw-log-format.json
{ "accountId": "$context.accountId", "apiId": "$context.apiId", "authorizer.error": "$context.authorizer.error", "authorizer.principalId": "$context.authorizer.principalId", "": "$", "awsEndpointRequestId": "$context.awsEndpointRequestId", "awsEndpointRequestId2": "$context.awsEndpointRequestId2", "customDomain.basePathMatched": "$context.customDomain.basePathMatched", "dataProcessed": "$context.dataProcessed", "domainName": "$context.domainName", "domainPrefix": "$context.domainPrefix", "error.message": "$context.error.message", "error.messageString": "$context.error.messageString", "error.responseType": "$context.error.responseType", "extendedRequestId": "$context.extendedRequestId", "httpMethod": "$context.httpMethod", "identity.accountId": "$context.identity.accountId", "identity.caller": "$context.identity.caller", "identity.cognitoAuthenticationProvider": "$context.identity.cognitoAuthenticationProvider", "identity.cognitoAuthenticationType": "$context.ident
cam8001 / .zshrc
Created May 6, 2023 02:29
aws cli autocompletions for zsh
View .zshrc
# after doing `brew install awscli`, add the following to the bottom of your .zshrc:
autoload bashcompinit && bashcompinit
source /opt/homebrew/share/zsh/site-functions/
cam8001 /
Created February 6, 2023 20:55
# connect your flash drive
# make sure it is visible to etcher

$ balena util available-drives
cam8001 /
Last active November 10, 2022 03:39
One liner to get list of services keyed to AWS region
curl -s '' \
| jq '.prices[] | .attributes | .["aws:region"], .["aws:serviceName"]' \
| sed '$!N;s/\n/,/'
cam8001 /
Created September 15, 2022 00:18
Export a contact list from SES, with pagination
# Specify contact list name here
OUTPUT_FILE="./contact-list_$CONTACT_LIST_NAME-$(date +%s).csv"
AWS_CLI_COMMAND="aws sesv2 list-contacts --contact-list-name $CONTACT_LIST_NAME --filter FilteredStatus=OPT_IN --page-size 1000 "
function cli_call() {
if [ ! -z NEXT_TOKEN ]; then
cam8001 / aws-cli.bash
Last active April 20, 2022 06:02
AWS CLI Snippets
View aws-cli.bash
# Get a list of all SSM managed instances that appear to be online
aws ssm describe-instance-information --filter Key=PingStatus,Values=Online --query "InstanceInformationList[*].{Instance:InstanceId,Name:Name}" --output=text
# Get a list of all IPs for a service in region
# Way 1: using prefix lists
aws ec2 get-managed-prefix-list-entries --prefix-list-id pl-b8a742d1
# Way 2: using ip-ranges.json
curl | jq '.prefixes | map(select(.region=="ap-southeast-2" and .service=="EC2")) | map(.ip_prefix) | .[]'
cam8001 /
Created October 1, 2021 09:41
Unifi controller on Ubuntu 20.04 arm64 - AWS userdata
echo -e "Running custom Unifi userdata"
# Assoicate an elastic IP
# Set timezone
ln -fs /usr/share/zoneinfo/Pacific/Auckland /etc/localtime
apt-key adv --keyserver --recv 06E85760C0A52C50
cam8001 /
Created October 1, 2021 09:38
Associate Elastic IP on every boot even with custom AMI (eg for autoscaling)
Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"
cam8001 /
Last active May 29, 2022 02:06
New Mac setup
brew install --cask visual-studio-code
brew install --cask iterm2
brew install --cask alfred
brew install --cask istatmenus
brew install --cask hiddenbar
# Shell
echo 'alias l="ls -lashF"' >> ~/.zshrc