AWS CLI Cloud Infrastructure Commands Cheat Sheet
Production AWS CLI reference: credentials configuration, S3 sync & presigned URLs, EC2 instance states, Lambda invocations, and live CloudWatch log streaming with 1-click copy.
Configuration & Auth (3 commands)
aws configure
Interactively configures AWS Access Key, Secret Key, default region, and output format.
aws sts get-caller-identity
Verifies the currently active IAM user or assumed role ARN and AWS account ID.
export AWS_PROFILE="production"
Switches the active CLI session to a named profile defined in ~/.aws/config.
Amazon S3 Storage (4 commands)
aws s3 ls
Lists all S3 buckets associated with your AWS account.
aws s3 cp ./build/ s3://my-bucket/ --recursive
Uploads all local files in build/ to the destination S3 bucket.
aws s3 sync ./dist/ s3://my-website-bucket/ --delete
Synchronizes local files to S3, uploading only changed files and deleting obsolete keys.
aws s3 presign s3://my-bucket/reports/q4.pdf --expires-in 3600
Generates a secure, time-limited presigned URL granting temporary read access.
Amazon EC2 Compute (3 commands)
aws ec2 describe-instances --filters "Name=instance-state-name,Values=running"
Lists all currently running EC2 virtual machines with IP addresses and tags.
aws ec2 start-instances --instance-ids i-0123456789abcdef0
Starts a stopped EBS-backed virtual machine instance.
aws ec2 reboot-instances --instance-ids i-0123456789abcdef0
Requests an orderly operating system reboot of the targeted virtual machine.
AWS Lambda Functions (2 commands)
aws lambda list-functions --max-items 50
Lists deployed serverless Lambda functions, memory allocations, and runtime versions.
aws lambda invoke --function-name MyHandler --payload '{"action":"test"}' response.json
Synchronously executes a Lambda function payload and writes response to a local file.
CloudWatch Logs (2 commands)
aws logs tail /aws/lambda/MyFunction --follow
Streams live log events emitted by Lambda or EC2 CloudWatch log groups in real time.
aws logs filter-log-events --log-group-name "/aws/lambda/MyFunction" --filter-pattern "ERROR"
Searches CloudWatch log events matching a specific term or metric pattern.