Skip to content

Instantly share code, notes, and snippets.

lol no

Cameron Tod cam8001

lol no
  • Wellington, New Zealand
View GitHub Profile
cam8001 /
Created Sep 15, 2022
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 Apr 20, 2022
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 Oct 1, 2021
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 Oct 1, 2021
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
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
cam8001 /
Last active Jun 14, 2022
sudo apt-get -y install git zsh && echo zsh >> ~/.bashrc
echo 'alias l="ls -lash"' >> ~/.zshrc
# Install oh-my-zsh
sh -c "$(curl -fsSL" "" --unattended
# Install powelevel10k
git clone --depth=1 ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k &&
sed -i 's/robbyrussell/powerlevel10k\/powerlevel10k/' ~/.zshrc &&
cam8001 /
Last active Jun 26, 2021
Userdata to install Unifi Network (unifi controller) on Ubuntu 20.04 when launching an x86 instance on AWS
# Associate this EIP on launch.
echo "Updating packages..."
# Force grub to update in a silent mode
DEBIAN_FRONTEND=noninteractive apt-get -y -o DPkg::options::="--force-confdef" -o DPkg::options::="--force-confold" -qq --allow-remove-essential --allow-change-held-packages upgrade
# Update packages.
sudo apt-get upgrade -y
cam8001 / ssm-document.yml
Created Jun 25, 2021
SSM Run Command Document for syncing a folder to s3
View ssm-document.yml
schemaVersion: '2.2'
description: State Manager Bootstrap Example
parameters: {}
- action: aws:runShellScript
name: backupUnifi
- aws s3 --region ap-southeast-2 sync <your-folder> s3://<your-bucket>
cam8001 /
Last active Sep 11, 2022
Customise AWS cloudshell or Amazon Linux 2 with nice utilities
# Note for Cloudshell, only stuff in your home directory is saved.
# But, Cloudshell already has git and zsh available. So we just install custom binaries to ~/bin and update our path.
# you can whoami == cloudshell-user or $AWS_EXECUTION_ENV==CloudShell to detect cloudshell
# Start zsh on startup. No chsh :(
[[ $AWS_EXECUTION_ENV == "CloudShell" ]] && echo "In CloudShell, no need to install git/zsh" || sudo yum -y install git zsh && echo zsh >> ~/.bashrc
echo 'alias l="ls -lash"' >> ~/.zshrc
cam8001 / package.json
Last active Apr 17, 2021
tsconfig.json for lambda with typescript
View package.json
"name": "my-lambda-function",
"version": "1.0.0",
"scripts": {
"build": "tsc && npm run copy-config",
"copy-config": "cp -r configuration/* build/",
"release": "npm run build",
"dependencies": {
"aws-lambda": "^1.0.6",