AWS profiles, Regions and output selection
Separate identity from location
A named profile is a group of local CLI settings that can refer to an authentication method and defaults such as Region or output. A Region specifies where a regional request is directed. A profile name such as training does not prove that the credentials belong to a training account. Use explicit profile and Region values when preparing an approved lab; verify the effective identity before changing anything.
Read a proposed configuration
The following fictional config fragment illustrates non-secret defaults only. Do not write it into your real configuration. The command below it shows how explicit flags select a profile and override its Region and output defaults for that invocation. The command is not an offline exercise: it would contact EC2.
[profile training]region = us-east-1output = json
aws ec2 describe-instances --profile training --region us-west-2 --output tableChoose the output format
JSON preserves structured objects and arrays and is a useful default for programs. Text is compact but can lose structural context; table is convenient for human inspection. These choices change presentation, not authorization or the underlying resource. With paginated commands, text output can apply a query page by page; JSON output normally applies it to the combined response. Check the command-specific pagination rules.
Extract fields with JMESPath
JMESPath is a query language for JSON. The synthetic response below is simplified from an EC2 response. The expression follows Reservations, flattens Instances, then selects InstanceId from each instance. The expected result is an array with two IDs. In AWS CLI the --query option performs client-side selection; it is not a service-side permission filter. A service-specific filter can reduce results on the server when supported.
{"Reservations":[{"Instances":[{"InstanceId":"i-00000000000000001"},{"InstanceId":"i-00000000000000002"}]}]}Query: Reservations[].Instances[].InstanceIdResult: ["i-00000000000000001","i-00000000000000002"]Avoid credential confusion
Authentication settings may come from multiple sources; the exact precedence depends on the tool and configuration. Do not place access keys in commands, source files or screenshots. Prefer approved temporary sessions. In an authorized sandbox only, STS get-caller-identity can report the caller ARN, account and user ID; it does not establish permission for another operation. Never invoke it to discover unknown credentials. For practice, predict the output of the query above when Instances is an empty array: the result is an empty array.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Profiles, regions and output selection — knowledge check
Apply the concepts in offline scenarios.
A profile defaults to us-east-1; a command explicitly sets --region us-west-2. Which Region does the flag select?
Which output is a natural choice for parsing structured arrays and objects?
What does the CLI --query option do?
What does a profile named training prove about the account?
What can an authorized STS get-caller-identity call establish?