Skip to content

Instantly share code, notes, and snippets.

View bashtoni's full-sized avatar

Sam Bashton bashtoni

View GitHub Profile
@bashtoni
bashtoni / not-autoscaling.sh
Created January 9, 2018 14:48
List all instances not in an autoscaling group
aws ec2 describe-instances --filter --query 'Reservations[].Instances[?!not_null(Tags[?Key == `aws:autoscaling:groupName`].Value)] | [].[InstanceId]' --output text
### Keybase proof
I hereby claim:
* I am bashtoni on github.
* I am sambashton (https://keybase.io/sambashton) on keybase.
* I have a public key whose fingerprint is F008 00FE C6A4 AFB4 2E08 E1B7 E2CB 2ADC 2C3C 437C
To claim this, I am signing this object:
@bashtoni
bashtoni / gist:995c0683bb18fd19eaefdc296a9401d8
Created July 4, 2018 10:48
Find ARN for ACM certificate for a given domain name
aws acm us-east-1 list-certificates --query CertificateSummaryList[].[CertificateArn,DomainName] \
--output text | grep example.com | cut -f1
@bashtoni
bashtoni / gist:cda204308d9730d6420e59d84f55f77e
Created July 4, 2018 10:49
Get HostedZoneId from AWS CLI for a given domain
aws route53 list-hosted-zones-by-name --dns-name example.com --query HostedZones[].Id --output text | cut -d/ -f3
@bashtoni
bashtoni / assume_role.sh
Last active May 15, 2023 22:32
AWS assume role on CLI
ROLE_TO_ASSUME="arn:aws:iam::${ACCOUNT_ID}:role/${ROLE_NAME}"
session_token=($(aws sts assume-role --role-arn $ROLE_TO_ASSUME --query 'Credentials.[AccessKeyId,SecretAccessKey,SessionToken]' --role-session-name "$USER-$$" --output text))
export AWS_ACCESS_KEY_ID="${session_token[1]}" AWS_SECRET_ACCESS_KEY="${session_token[2]}" AWS_SESSION_TOKEN="${session_token[3]}"
@bashtoni
bashtoni / snap.sh
Created June 4, 2020 08:26
Create volume with name matching snapshot name
snap=snap-123456789
desc=$(aws ec2 describe-snapshots --snapshot-ids $snap --query Snapshots[].Description --output text)
aws ec2 create-volume --snapshot-id $snap --availability-zone ap-southeast-2c --tag-specifications "[{\"ResourceType\":\"volume\",\"Tags\":[{\"Key\":\"Name\",\"Value\":\"$desc\"}]}]"
@bashtoni
bashtoni / attach-multiple-volumes.sh
Last active June 9, 2020 04:22
Attach multiple volumes to an EC2 Instance
count=0
for vol in vol-0123abcd vol-1023abcd vol-2013abcd ; do
device="/dev/xvd$(echo $count | tr '[0-9]' '[j-z]')"
aws ec2 attach-volume --volume-id $vol --instance-id i-123456789abc --device $device
count=$(expr $count + 1)
done
@bashtoni
bashtoni / global_quota_increase.sh
Created May 18, 2021 01:31
Request a quota increase across all regions
#!/bin/bash
SERVICE_CODE=cloudformation
QUOTA_CODE=L-0485CB21 # Number of stacks - find via `aws service-quotas list-service-quotas` or AWS Console
DESIRED_VALUE=500
for region in $(aws ec2 describe-regions --query Regions[][RegionName] --output text); do
aws service-quotas --region $region request-service-quota-increase \
--service-code $SERVICE_CODE \
--quota-code $QUOTA_CODE \
@bashtoni
bashtoni / i.sh
Created April 13, 2022 23:55
Install AWS CLI in homedir
./install -b ${HOME}/.local/bin/ -i ${HOME}/awscli
@bashtoni
bashtoni / pfsense-on-centos-8.md
Last active June 25, 2022 21:14 — forked from RulerOf/pfsense-on-centos-8.md
Installing pfSense on KVM in CentOS 8

Installing pfSense on KVM in CentOS 8

We download the latest release of pfSense as a gzipped ISO, then extract it and pass it to virt-install to get the VM up and running. Interactive portions of setup are done with virt-install's native console redirection.

Instructions

Install and start libvirtd

sudo dnf -y install libvirt-daemon
sudo systemctl enable --now libvirtd