Topic lessonTopic: AWS CLI: configuration, sign-in and request targets
AWS CLI for beginners: profiles, sign-in and Regions
The AWS Command Line Interface (AWS CLI) makes requests to AWS from commands. A profile selects configuration; authentication establishes the caller; Region is part of the request destination. Read a fictional report task to see why matching names alone are not enough.
Distinguish profile, session, account/role, Region and operation target; pause when conditions are unknown or inconsistent.
Basic authentication, authorization, accounts and roles. No AWS account or CLI is needed. Do not paste this lesson’s examples into a terminal.
Separate profiles, callers, Regions and targets
An AWS account contains resources; it is not the person using them. A person authenticates through an assigned identity system. A role in AWS Identity and Access Management (IAM) is an identity with permissions; assuming it provides temporary credentials for a role session. The example uses an assigned role, rather than representing every sign-in method.
- Task → ProfileSelect the organization-approved access method and its configuration.
- Profile → CallerEstablish the actual caller instead of trusting the profile name.
- Caller → TargetEven with the expected caller, check the target and authorization separately.
- Task
- Check the existing report application without creating or changing resources.
- Profile
- report-training selects configuration. Establish its authentication method and source.
- Caller
- Check the account and role represented by the active session.
- Target
- Match the service, operation, Region and resource to the task.
| Term | Role | What to establish |
|---|---|---|
| Profile | A named group of configuration settings | Whether the resolved credentials and caller match the task |
| Authentication session | An active signed-in context; temporary credentials depend on the method | Validity and the associated account and role |
| Region | A setting used to select a request destination | The target service’s Region and the setting effective for that request |
| Service, resource and operation | What is requested, and from what | The resource ID, required operation and authorization; caller identity alone is insufficient |
Choose sign-in from organizational requirements and CLI version
For a person using the CLI, first establish the organization-approved temporary-access method. IAM Identity Center assigns people access to AWS accounts and other resources. Single sign-on (SSO) lets one sign-in support access to multiple assigned destinations. Console-based sign-in and federation with an external identity system have different prerequisites. Creating long-term access keys or using root for routine work is not the default introduction.
| Condition | Relevant official path | Check first |
|---|---|---|
| The organization specifies IAM Identity Center | Configure with aws configure sso and sign in with aws sso login | Assigned access, the supplied portal details and SSO Region; SSO Region is separate from the workload Region |
| The organization approves the supported console-credential path | aws login; current documentation requires AWS CLI 2.32.0 or later | CLI version, intended identity and required access; Identity Center users follow the separate SSO instructions |
| Method, assignment or CLI version is unknown, or another identity system is used | Ask the responsible team, then use that method’s official instructions | Do not switch methods or create keys just to imitate an example |
Worked example: the expected profile name is not enough
GetCallerIdentity in AWS Security Token Service (STS) is an API: a programmatic interface used here to ask which identity made the request. In the output, Account is the account ID and Arn names the caller identity. This request does not return an EC2 resource list or establish permission to operate on EC2.
Input example to read, not execute: an STS caller-identity request
aws sts get-caller-identity --profile report-training --region ap-northeast-3Fictional output, not an execution result
{
"UserId": "TRAINING-ROLE-ID:lesson-01",
"Account": "444455556666",
"Arn": "arn:aws:sts::444455556666:assumed-role/ReportViewer/lesson-01"
}| Item | Required for the task | What the example shows |
|---|---|---|
| Profile | Use the approved configuration | report-training is selected; the name alone does not establish the caller |
| Caller | Account A / 111122223333 and the assigned role | Account is 444455556666 (training B); a matching ReportViewer name is still in another account |
| Workload Region | The EC2 target is Tokyo / ap-northeast-1 | The working note and STS request specify Osaka / ap-northeast-3; the next EC2 request destination is unverified |
| Service and resource | Identify existing EC2 R17 / report-web, then perform only an authorized state check | This request is to STS. It does not establish the EC2 resource’s existence, actual ID, state or permissions |
Pause before the EC2 query and recheck the account and workload Region. GetCallerIdentity reports the caller for its own request, not permission to query EC2. A --region option applies to that command; it does not switch all later commands. Environment and other configuration sources can also affect resolution, so do not infer identity from the profile name.
Separate session expiry, denial and an unknown target
| Observation | Next check | What it does not establish |
|---|---|---|
| The authentication session is reported expired | Check reauthentication requirements for the organization’s method | It does not imply that a new long-term key is needed |
| Another service request returns AccessDenied | Review caller, action, resource and applicable controls | A successful identity check does not authorize that operation |
| The expected resource is not found | Check account, service, Region, resource ID and filters | It does not yet establish absence, deletion or a need to recreate it |
Credential and sign-in lifetimes, refresh and reauthentication depend on the method. Error wording also varies with context and version. This fixed example does not diagnose every expired or denied request.
Choose the next check as conditions change
Choose an option to see the result and explanation.
Continue with the IAM fundamentals
Review the prerequisites
- To distinguish successful sign-in from permission to perform an operation.:Authentication and authorization →
- To review temporary credentials and role-based access.:Access paths for people and applications →
Check, then explain in your own words
- Explain the difference between a profile name and the caller.
- Identify the approved authentication method and reauthentication requirements.
- Match service, operation, Region and resource to the task before proceeding.
Check your understanding: Does the expected profile name let you proceed with the EC2 operation?
Not from the name alone. Check caller, session, target and authorization for the required operation.
A profile selects configuration. The example has the same role name in another account and a different planned Region. An identity API’s success is separate from authorization to operate on another service.
Sources and conditions checked
The official references used in this lesson are collected here with their scope, conditions and corresponding sections. Independent expert review and live AWS comparison have not been performed.
Scope and conditionsNamed profiles group settings; config and credentials are distinct files. Profile names alone are not caller verification.
Used in this lessonSeparate profiles, callers, Regions and targets
Scope and conditionsSettings and credentials have multiple sources. A command-specific Region option is not a persistent change to later commands; no exhaustive precedence algorithm is implemented.
Used in this lessonSeparate profiles, callers, Regions and targets Worked example: the expected profile name is not enough
Scope and conditionsConsole-credential aws login requires CLI2.32.0+ and an applicable identity/access path. Identity Center follows separate instructions. Lifetimes are method-specific; no login or permission attachment performed.
Used in this lessonChoose sign-in from organizational requirements and CLI version Separate session expiry, denial and an unknown target
Scope and conditionsAssigned Identity Center access and organization-provided settings precede configure/sign-in. SSO Region and workload Region are separate. Do not copy tutorial broad permission examples.
Used in this lessonChoose sign-in from organizational requirements and CLI version Separate session expiry, denial and an unknown target
Scope and conditionsReturns caller identity fields; success is not evidence of EC2 access. The illustrated invocation is static and unexecuted; no real identity output collected.
Used in this lessonSeparate profiles, callers, Regions and targets Worked example: the expected profile name is not enough Separate session expiry, denial and an unknown target
Scope and conditionsMultiple applicable authentication paths; prefer approved temporary access, rather than one universal sign-in command or new long-term keys.
Used in this lessonChoose sign-in from organizational requirements and CLI version
- Security best practices in IAMChecked:
Scope and conditionsFederated human access/Identity Center; workload temporary role credentials; least privilege, long-term credentials only for justified use cases.
Used in this lessonSeparate profiles, callers, Regions and targets Choose sign-in from organizational requirements and CLI version Separate session expiry, denial and an unknown target
- IAM rolesChecked:
Scope and conditionsIAM role identity, trust, temporary credentials; role versus session.
Used in this lessonSeparate profiles, callers, Regions and targets
- What is an AWS account?Checked:
Scope and conditionsAn account is a resource/access/billing management unit distinct from the individual person. Only this basic distinction is used, not account creation or new signup paths.
Used in this lessonSeparate profiles, callers, Regions and targets