AWS & gcloud

AWS & gcloud CLI cheatsheet.

The everyday AWS CLI and Google Cloud commands — credentials, storage, instances and deploys. Tap to copy.

AWS CLI
aws configureSet up credentials and default region
aws sts get-caller-identityShow which identity you're using
aws s3 lsList your S3 buckets
aws s3 cp file.txt s3://bucket/Upload a file to S3
aws s3 sync . s3://bucket/Sync a folder up to S3
aws ec2 describe-instancesList your EC2 instances
aws logs tail /aws/lambda/fn --followStream a Lambda's logs
Google Cloud (gcloud)
gcloud initSet up the gcloud CLI interactively
gcloud auth loginAuthenticate with your Google account
gcloud config set project my-projectSet the active project
gcloud projects listList your projects
gcloud compute instances listList Compute Engine VMs
gcloud app deployDeploy an App Engine app
Cloud Storage (gsutil)
gsutil lsList Cloud Storage buckets
gsutil cp file.txt gs://bucket/Upload a file to a bucket
gsutil -m rsync -r . gs://bucket/Sync a folder to a bucket (parallel)
Run aws configure or gcloud init first to set up credentials before the other commands will work.

Two clouds, similar patterns

The AWS and Google Cloud command-line tools let you manage cloud resources without leaving the terminal. Both start the same way: authenticate and set defaults with aws configure or gcloud init. From there the patterns rhyme — list resources, copy files to object storage (aws s3 cp / gsutil cp), inspect compute instances, and deploy. This cheatsheet keeps the most common commands from each side by side.

Storage and everyday tasks

Object storage is where most people start: aws s3 sync and gsutil rsync mirror a local folder up to a bucket, which is handy for static sites, backups and build artifacts. Checking your identity (aws sts get-caller-identity) is the first thing to run when a command fails with a permissions error — it confirms which account and role you're actually using. These pair naturally with the Docker and kubectl commands when you deploy containers.

FAQ

How do I set up the AWS or gcloud CLI?
Run aws configure to enter your access key, secret and default region for AWS, or gcloud init to authenticate and pick a project for Google Cloud.
How do I copy files to cloud storage?
On AWS use aws s3 cp file s3://bucket/ (or aws s3 sync for folders). On Google Cloud use gsutil cp file gs://bucket/ (or gsutil rsync -r).

More cheatsheets