HxHippy

Cloud Engineer Cheat Sheet

Multi-cloud CLI commands for AWS, GCP, and Azure.

Last updated: 2025-01-15

Cloud Engineer Cheat Sheet

Multi-cloud CLI commands for AWS, GCP, and Azure.

Quick Reference

# AWS - List running instances
aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" --query 'Reservations[*].Instances[*].[InstanceId,Tags[?Key==`Name`].Value|[0]]' --output table

# GCP - List instances
gcloud compute instances list

# Azure - List VMs
az vm list -d -o table

AWS CLI

EC2

# List instances
aws ec2 describe-instances --output table

# Start/stop instance
aws ec2 start-instances --instance-ids i-1234567890abcdef0
aws ec2 stop-instances --instance-ids i-1234567890abcdef0

# Get instance IP
aws ec2 describe-instances --instance-ids i-xxx --query 'Reservations[0].Instances[0].PublicIpAddress'

# Security groups
aws ec2 describe-security-groups --group-ids sg-xxx

S3

# List buckets
aws s3 ls

# List objects
aws s3 ls s3://bucket-name/prefix/

# Copy files
aws s3 cp file.txt s3://bucket/
aws s3 cp s3://bucket/file.txt ./
aws s3 sync ./local s3://bucket/remote

# Presigned URL
aws s3 presign s3://bucket/file.txt --expires-in 3600

IAM

# Current identity
aws sts get-caller-identity

# List roles
aws iam list-roles --query 'Roles[*].RoleName'

# Assume role
aws sts assume-role --role-arn arn:aws:iam::123456789:role/MyRole --role-session-name mysession

CloudWatch

# Get metrics
aws cloudwatch get-metric-statistics --namespace AWS/EC2 --metric-name CPUUtilization --dimensions Name=InstanceId,Value=i-xxx --start-time 2024-01-01T00:00:00Z --end-time 2024-01-02T00:00:00Z --period 3600 --statistics Average

# Logs
aws logs describe-log-groups
aws logs tail /aws/lambda/my-function --follow

GCP CLI

Compute

# List instances
gcloud compute instances list

# Create instance
gcloud compute instances create my-vm --zone=us-central1-a --machine-type=e2-medium

# SSH
gcloud compute ssh my-vm --zone=us-central1-a

# Start/stop
gcloud compute instances start my-vm --zone=us-central1-a
gcloud compute instances stop my-vm --zone=us-central1-a

Storage

# List buckets
gsutil ls

# Copy files
gsutil cp file.txt gs://bucket/
gsutil cp gs://bucket/file.txt ./
gsutil rsync -r ./local gs://bucket/remote

# Signed URL
gsutil signurl -d 1h keyfile.json gs://bucket/file.txt

IAM

# Current account
gcloud config get-value account

# List projects
gcloud projects list

# Switch project
gcloud config set project my-project

# Service accounts
gcloud iam service-accounts list

Azure CLI

Virtual Machines

# List VMs
az vm list -o table

# Create VM
az vm create --resource-group myRG --name myVM --image Ubuntu2204 --admin-username azureuser --generate-ssh-keys

# Start/stop
az vm start --resource-group myRG --name myVM
az vm stop --resource-group myRG --name myVM

# SSH
az ssh vm --resource-group myRG --name myVM

Storage

# List storage accounts
az storage account list -o table

# List containers
az storage container list --account-name mystorageaccount -o table

# Upload blob
az storage blob upload --account-name mystorageaccount --container-name mycontainer --name myblob --file ./file.txt

Identity

# Current account
az account show

# List subscriptions
az account list -o table

# Switch subscription
az account set --subscription "My Subscription"

Cross-Cloud Comparison

Task AWS GCP Azure
List VMs aws ec2 describe-instances gcloud compute instances list az vm list
List storage aws s3 ls gsutil ls az storage account list
Current identity aws sts get-caller-identity gcloud config get-value account az account show
SSH to VM ssh -i key.pem user@ip gcloud compute ssh vm az ssh vm

Cost Management

# AWS
aws ce get-cost-and-usage --time-period Start=2024-01-01,End=2024-01-31 --granularity MONTHLY --metrics UnblendedCost

# GCP
gcloud billing accounts list
gcloud beta billing budgets list --billing-account=XXXXXX-XXXXXX-XXXXXX

# Azure
az consumption usage list --start-date 2024-01-01 --end-date 2024-01-31
intermediate DevOps Roles Updated 2025-01-15
  • cloud
  • aws
  • gcp
  • azure
  • cli
  • infrastructure