lgjohnson
11/15/2018 - 10:15 PM

AWS

Handy AWS CLI commands.

# get s3 bucket size
aws s3 ls --summarize --human-readable --recursive s3://<bucket_name>

# take snapshot of rds cluster
aws rds create-db-cluster-snapshot \
  --db-cluster-snapshot-identifier smart-filtering-db-prod-cluster-migration-to-experiments \
  --db-cluster-identifier smart-filtering-db-prod-cluster
  
# connect to instance using instance-id; requires jq
# usage: connect_ec2 i-083eb548c770e226a
connect_ec2 () {
  ssh \
    -i ~/.ssh/gg_rsa \
    -o "StrictHostKeyChecking no" \
    $(echo ubuntu@$(\
      aws ec2 describe-instances \
        --instance-id $1 \
        --output json \
      | jq '.Reservations[0].Instances[0].NetworkInterfaces[0].PrivateIpAddress' \
      | sed 's/"//g'))
}