| title | AWS CLI Best Practices |
|---|---|
| inclusion | always |
When running AWS CLI commands that might produce large outputs, always use the --no-cli-pager option to prevent interactive paging. This is especially important for:
- List operations (
aws s3 ls,aws ec2 describe-instances, etc.) - Commands that return large JSON responses
- Commands used in scripts or automation
Example:
aws amplify list-apps --profile da --no-cli-pager
aws ec2 describe-instances --no-cli-pager
aws s3 ls s3://my-bucket --no-cli-pager- Use
--output jsonfor programmatic processing - Use
--output tablefor human-readable output - Use
--queryto filter results and reduce output size
- Always check exit codes in scripts
- Use
--debugflag for troubleshooting - Consider using
--dry-runfor testing destructive operations
- Use IAM roles instead of access keys when possible
- Rotate access keys regularly
- Use least privilege principle for IAM policies
- Use AWS-Knowledge MCP server for current documentation and best practices
- Follow AWS Well-Architected Framework principles
- Reference official AWS documentation for implementation patterns
- Validate service usage against latest AWS documentation
- Use aws-api-mcp-server for programmatic AWS API interactions