INFRASTRUCTURE LEARNINGINFRASTRUCTURE LEARNING
インフラ大全インフラ大全IT INFRASTRUCTURE / LEARNING
Infrastructure learning guide
Find a lesson or lab/

Esc to close · Search terms stay on your device

LEARNING日本語

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.

What you will learn

Distinguish profile, session, account/role, Region and operation target; pause when conditions are unknown or inconsistent.

Prerequisite

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.

Four checks before a CLI request: arrows show the review order
Four checks before a CLI request: arrows show the review order1: Task — Select the organization-approved access method and its configuration. — Profile. 2: Profile — Establish the actual caller instead of trusting the profile name. — Caller. 3: Caller — Even with the expected caller, check the target and authorization separately. — Target123TaskProfileCallerTargetFour checks before a CLI request: arrows show the review order1: Task — Select the organization-approved access method and its configuration. — Profile. 2: Profile — Establish the actual caller instead of trusting the profile name. — Caller. 3: Caller — Even with the expected caller, check the target and authorization separately. — Target123TaskProfileCallerTarget
  1. Task → ProfileSelect the organization-approved access method and its configuration.
  2. Profile → CallerEstablish the actual caller instead of trusting the profile name.
  3. 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.
Each CLI detail answers a different question
TermRoleWhat to establish
ProfileA named group of configuration settingsWhether the resolved credentials and caller match the task
Authentication sessionAn active signed-in context; temporary credentials depend on the methodValidity and the associated account and role
RegionA setting used to select a request destinationThe target service’s Region and the setting effective for that request
Service, resource and operationWhat is requested, and from whatThe 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.

Identify the applicable official instructions; do not sign in here
ConditionRelevant official pathCheck first
The organization specifies IAM Identity CenterConfigure with aws configure sso and sign in with aws sso loginAssigned access, the supplied portal details and SSO Region; SSO Region is separate from the workload Region
The organization approves the supported console-credential pathaws login; current documentation requires AWS CLI 2.32.0 or laterCLI 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 usedAsk the responsible team, then use that method’s official instructionsDo 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.

Synthetic reading example; do not executeScroll horizontally to read long lines. Use arrow keys in the code area.
Input example to read, not execute: an STS caller-identity request
aws sts get-caller-identity --profile report-training --region ap-northeast-3
Synthetic reading example; do not executeScroll horizontally to read long lines. Use arrow keys in the code area.
Fictional output, not an execution result
{
  "UserId": "TRAINING-ROLE-ID:lesson-01",
  "Account": "444455556666",
  "Arn": "arn:aws:sts::444455556666:assumed-role/ReportViewer/lesson-01"
}
Compare task requirements with the fictional observations
ItemRequired for the taskWhat the example shows
ProfileUse the approved configurationreport-training is selected; the name alone does not establish the caller
CallerAccount A / 111122223333 and the assigned roleAccount is 444455556666 (training B); a matching ReportViewer name is still in another account
Workload RegionThe EC2 target is Tokyo / ap-northeast-1The working note and STS request specify Osaka / ap-northeast-3; the next EC2 request destination is unverified
Service and resourceIdentify existing EC2 R17 / report-web, then perform only an authorized state checkThis 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

Choose a next check from the result
ObservationNext checkWhat it does not establish
The authentication session is reported expiredCheck reauthentication requirements for the organization’s methodIt does not imply that a new long-term key is needed
Another service request returns AccessDeniedReview caller, action, resource and applicable controlsA successful identity check does not authorize that operation
The expected resource is not foundCheck account, service, Region, resource ID and filtersIt 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.

Your organization specifies IAM Identity Center, but another article shows aws login. What next?
Read the answer and reason

Answer: Check the assignment and CLI version, then the SSO instructions · Matching the assigned method helps avoid selecting an unintended sign-in path or account.

The example uses report-training and ReportViewer, but Account is training B. What next?
Read the answer and reason

Answer: Pause and recheck the approved caller and target · Account differs from the task. Match the caller, Region and resource, then separately establish authorization for the required operation.

The approved temporary session is reported expired. What next?
Read the answer and reason

Answer: Check reauthentication for the assigned method · Establish how to resume through the approved path before adding a different credential method.

Continue with the IAM fundamentals

Review the prerequisites

Check, then explain in your own words

  1. Explain the difference between a profile name and the caller.
  2. Identify the approved authentication method and reauthentication requirements.
  3. 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.