Skip to main content
Cloud & DevOps

AWS CLI v2 & Cloud Services

Production

Essential AWS command-line interface commands for S3, EC2, Lambda, Secrets Manager, CloudWatch, and STS security.

Instant Copy & SearchProduction Flagged SyntaxCurrent Flag Reference

AWS CLI v2 & Cloud Services Interactive Command Directory

Browse, search, and copy battle-tested commands & syntax recipes (17 Total Commands).

17+ Verified Recipes
Identity & Securitysts get-caller-identity
aws sts get-caller-identity

Verify current active IAM identity, account ID, and assumed role ARN.

S3 Sync & Storages3 sync --delete --cache-control
aws s3 sync ./dist s3://my-production-bucket --delete --cache-control "max-age=31536000"

Incrementally synchronize static build assets to S3 and purge deleted files with cache headers.

S3 Operationss3 cp
aws s3 cp s3://my-bucket/database-dump.sql ./db.sql

Download single object from Amazon S3 directly to local directory.

EC2 Instances--filters, --query, --output table
aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" --query "Reservations[*].Instances[*].[InstanceId,PrivateIpAddress,PublicIpAddress]" --output table

Query running EC2 virtual machines and output IP addresses in tabular format.

Lambda Invocation--function-name, --payload
aws lambda invoke --function-name DataProcessor --payload '{"source":"queue"}' --cli-binary-format raw-in-base64-out response.json

Synchronously trigger a serverless AWS Lambda function and save response payload to disk.

Secrets Manager--secret-id, --query
aws secretsmanager get-secret-value --secret-id prod/database --query SecretString --output text

Retrieve decrypted JSON credentials from AWS Secrets Manager securely.

CloudWatch Logstail --follow
aws logs tail /aws/lambda/DataProcessor --follow --format short

Stream live real-time execution logs from Amazon CloudWatch log group.

ECR Docker Loginecr get-login-password
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 123456789.dkr.ecr.us-east-1.amazonaws.com

Authenticate local Docker daemon to push/pull container images from AWS ECR.

SQS Queues--queue-url, --max-number-of-messages
aws sqs receive-message --queue-url https://sqs.us-east-1.amazonaws.com/123/tasks --max-number-of-messages 10

Poll and consume pending messages from an Amazon SQS queue.

CloudFront CDN--distribution-id, --paths
aws cloudfront create-invalidation --distribution-id E12345 --paths "/*"

Purge cached static assets globally across all CloudFront edge locations.

S3 Sync & Static Hostings3 sync --delete
aws s3 sync ./out s3://my-static-site --delete --cache-control 'max-age=31536000,public'

Synchronize a local build directory to an AWS S3 bucket, pruning obsolete files and setting immutable cache headers.

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

List all active EC2 instances showing Instance ID, private IP, and server Name tag in a clean ASCII table.

Secrets Managersecretsmanager get-secret-value
aws secretsmanager get-secret-value --secret-id prod/database/credentials --query SecretString --output text

Fetch and decrypt sensitive production database credentials directly from AWS Secrets Manager.

ECR Docker Loginecr get-login-password
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 123456789012.dkr.ecr.us-east-1.amazonaws.com

Authenticate your local Docker CLI client to push and pull private container images from AWS Elastic Container Registry.

CloudWatch Live Logslogs tail --follow
aws logs tail /aws/lambda/payment-processor --follow --since 15m

Stream live serverless execution logs from CloudWatch in real time from the command line.

CloudFront Cache Invalidationcloudfront create-invalidation
aws cloudfront create-invalidation --distribution-id E12345EXAMPLE --paths '/*'

Purge edge CDN caches across global CloudFront edge locations following a new production frontend release.

Profile SwitchingAWS_PROFILE
export AWS_PROFILE=production && aws sts get-caller-identity

Switch the active CLI credentials context to a named profile configured in ~/.aws/credentials.

Zero Setup100% In-Browser Execution

Companion Developer Tools & Playgrounds

Accelerate command execution and syntax debugging with HelloAIHub suite of interactive tools.

Explore all developer tools

AWS CLI v2 & Cloud Services: Command Groups & Quick Index

17 indexed entries across 15 sections
Identity & Security1 items
S3 Sync & Storage1 items
S3 Operations1 items
EC2 Instances1 items
Lambda Invocation1 items
Secrets Manager2 items
CloudWatch Logs1 items
ECR Docker Login2 items
SQS Queues1 items
CloudFront CDN1 items
S3 Sync & Static Hosting1 items
EC2 Query Filtering1 items
CloudWatch Live Logs1 items
CloudFront Cache Invalidation1 items
Profile Switching1 items

Highlighted Flags & Syntax Examples in AWS CLI v2 & Cloud Services

aws sts get-caller-identity

Verify current active IAM identity, account ID, and assumed role ARN.

Flags: sts get-caller-identity
aws s3 sync ./dist s3://my-production-bucket --delete --cache-control "max-age=31536000"

Incrementally synchronize static build assets to S3 and purge deleted files with cache headers.

Flags: s3 sync --delete --cache-control
aws s3 cp s3://my-bucket/database-dump.sql ./db.sql

Download single object from Amazon S3 directly to local directory.

Flags: s3 cp
aws ec2 describe-instances --filters "Name=instance-state-name,Values=running" --query "Reservations[*].Instances[*].[InstanceId,PrivateIpAddress,PublicIpAddress]" --output table

Query running EC2 virtual machines and output IP addresses in tabular format.

Flags: --filters, --query, --output table

Frequently Asked Questions

Expert recommendations, common traps, and production best practices for AWS CLI v2 & Cloud Services.

How does AWS CLI credential precedence work?

AWS CLI resolves credentials in this order: 1) Explicit CLI options (--profile), 2) Environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY), 3) Assume role credential process, 4) AWS credentials file (~/.aws/credentials), 5) ECS task role, 6) EC2 instance profile IAM metadata.

What is JMESPath and how is it used with the --query flag?

JMESPath is a query language for JSON. The AWS CLI --query parameter evaluates client-side JMESPath expressions before formatting, allowing you to filter, project, and reshape JSON responses without external tools like jq.

What is the priority order of AWS CLI credential resolution?

The AWS CLI resolves credentials in this strict order: (1) CLI command flags (--profile), (2) Environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY), (3) Web Identity / OIDC token credentials, (4) AWS credentials file (~/.aws/credentials), (5) AWS config file (~/.aws/config), and (6) EC2 / ECS / Lambda Instance Profile IAM metadata service.

How does JMESPath query filtering work in the AWS CLI?

The --query flag executes client-side JMESPath expressions on returned JSON payloads. Using --query 'Reservations[*].Instances[*].InstanceId' allows you to extract specific array fields directly without needing external tools like jq or grep.

How can I avoid hitting AWS API rate limits (ThrottlingExceptions) in CI/CD scripts?

Configure automatic exponential backoff in ~/.aws/config by setting retry_mode = adaptive and max_attempts = 10. For high-volume polling loops, add explicit sleep intervals or migrate to event-driven EventBridge rules.

Why is hardcoding AWS Access Keys in CI/CD environments considered a security risk?

Long-lived access keys do not expire automatically and risk exposure via leaked logs or GitHub repository commits. Modern CI/CD systems (GitHub Actions, GitLab) should use OIDC to request short-lived temporary STS credentials with 1-hour expiration.

Cross-Hub Skill Acceleration

Combine command lookups with active coding interviews and complete career paths.

Need More Cheat Sheets?

Explore developer cheat sheets and syntax guides on HelloAIHub.

Browse All Cheat Sheets