1.AWS CLI basics: profiles, regions, and JMESPath queries
The AWS CLI wraps every service API as a command. A named profile picks which credentials and region to use, and `--query` filters a large JSON response down to just the fields you need with JMESPath.
Key features
- ~/.aws/config holds regions and settings per profile; ~/.aws/credentials holds keys
- --profile <name> or AWS_PROFILE selects which named profile to use
- --region overrides the profile's default region for one call
- --output can be json, yaml, text, or table
- --query applies a JMESPath expression to filter the response client-side
Common AWS CLI flags
- Whole: aws ec2 describe-instances \ --profile staging --region eu-west-1 \ --query "Reservations[].Instances[].InstanceId" --output text
- --profile staging — profile: which credentials and default settings to use
- --region eu-west-1 — region: overrides the profile's default region, this call only
- --query "Reservations[].Instances[].InstanceId" — query: JMESPath — reshapes the response client-side
- --output text — output: the response format
Command
aws <service> <operation> [--profile name] [--region region] [--query jmespath] [--output format]--profile picks credentials and default region; --query (JMESPath) reshapes the response client-side — always safer to script against than text-output column position.