About these AWS CLI snippets
These are the AWS CLI commands I actually type (or alias) in production. Not the sanitized versions from the docs. Each one handles the edge cases and output formatting that the official examples skip over: parsing JSON responses with jq, piping secrets safely, handling pagination, and cleaning up output so it is readable by a human, not just a machine.
Everything here targets AWS CLI v2 and assumes you have credentials configured via aws configure, environment variables, or an instance profile. Most commands work across Linux, macOS, and WSL without modification.
What's inside
- Identity and access: check which IAM identity you are using, assume a cross-account role with session tokens, and authenticate Docker against a private ECR registry.
- S3 operations: generate presigned download URLs with expiry control, and sync local folders to S3 with include/exclude filters for selective deployments.
- Compute and serverless: list running EC2 instances as a clean table, invoke a Lambda function synchronously, and read the decoded response payload.
- Observability: tail CloudWatch log groups in real time, and pull monthly cost breakdowns by service from Cost Explorer.
- Secrets: fetch and parse JSON secrets from Secrets Manager in a single pipeline, ready to pipe into environment variables or config files.
More commands land here as I pull them from runbooks and incident response playbooks. If a pattern saves me more than ten seconds and I use it more than twice, it ends up in this collection.
How to use them
Every snippet page shows the full command, explains what each flag does, and lists the IAM permissions you need. Copy, replace the placeholder values (they are in UPPER_SNAKE_CASE), and run. If you are scripting, the --output json and jq patterns shown are designed to be piped directly into shell variables or downstream commands.
If you spot a better flag combination or a cleaner jq filter, the code is open on GitHub. PRs and issues are welcome.