Skip to content

Instantly share code, notes, and snippets.

@coldclimate
Created December 12, 2014 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coldclimate/ca2677f3773c447dd2b5 to your computer and use it in GitHub Desktop.
Save coldclimate/ca2677f3773c447dd2b5 to your computer and use it in GitHub Desktop.

AWS CLI Profiles

Use named profiles if you have to connect using more than one set of credencials. No more editing .aws_config http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-multiple-profiles

(sub tip: don't set a default and thus never accidentally conenct to the wrong place) aws --profile=prod ec2

Monitoring S3

There is no CloudWatch integration with S3. Roll you own by bolting together readin S3 and pushing it into CloudWatch (or other monitoring tools). Use awk to slice out the columns you are interested in.

For example: track the total size of the bucket in gigs.

aws --profile=prod s3 ls s3://mybucket > /tmp/s3.tmp
TOTALBYTES=`cat /tmp/one.tmp | awk '{print $3}' | paste -sd+ - | bc`
echo "scale=2;${TOTALBYTES}/1000000000" | bc >> ${1}.totalGigs

Trusted

Trusted Advisor can really help you scale your instances and reduce your bills https://aws.amazon.com/premiumsupport/trustedadvisor/

Tags are your friends

Tag your instances for easy finding, sorting, and slicing billing data

Don't get tunnel vision

Don't forget to look outside AWS: specifically for one person CloudFront Vs CloudFlare

#ElasticbeanStalk dependancies ElasticBeanStalk .EBextentions - beware of dependancies

#JQ FTW When using the AWS CLI, pipe your output through jq for filtering and layout

JQ alternatives

If you've not got jq installed using Python for the same effects

aws cli | python -m json.tool

Sensible roles

Use IAM roles for everything. Stop embedding usernames and passwords

s3 quick bucket copy

You can copy one s3 bucket into another with aws s3 sync bucket1 bucket2

grep context

Trying to find a specific things and not sure exactly what it's called? Use grep and --context *aws ec2 describe-instances | grep --context 100 "phils forgotten thing"

disk names

Mount point have different names inside and outside /dev/xvda2 Vs /dev/sda2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment