AWS CLI Config File: Profiles, Regions, Output, and Role Settings
Learn how to configure ~/.aws/config with AWS CLI profiles, Regions, output formats, role assumption, IAM Identity Center, credential sources, and troubleshooting.
What the AWS CLI config file does
The AWS CLI uses a shared configuration file to store non-secret command-line settings. These settings can include an AWS Region, output format, profile relationships, IAM role-assumption options, retry behavior, and endpoint preferences.
On Unix-like systems, the default path is ~/.aws/config. On Windows, the equivalent is typically %USERPROFILE%\.aws\config.
The config file is different from the companion credentials file, which commonly stores static access keys and named credential profiles. A profile can use settings from both files, or obtain credentials from another provider without storing credentials locally.
| File | Typical location | Primary purpose | Named profile section syntax | Sensitive data considerations |
|---|---|---|---|---|
| Config | ~/.aws/config | Region, output, role, SSO, retry, pager, and other CLI settings | [profile name] | Usually non-secret, but may contain sensitive infrastructure or endpoint details |
| Credentials | ~/.aws/credentials | Static access keys and credential profiles | [name] | Can contain long-term secrets; protect it and never commit it |
Values can come from several sources. In general, a command-line option such as --region or --output overrides environment and file settings. Environment variables such as AWS_REGION, AWS_DEFAULT_REGION, and AWS_PROFILE commonly override corresponding file-based choices. The exact provider order can vary by setting, so use aws configure list to inspect the resolved source.
INI syntax and profile sections
The config file uses INI-style sections. A section name is enclosed in brackets, and each setting uses a key, an equals sign, and a value.
[default]
region = us-east-1
output = json
[profile development]
region = us-west-2
output = yamlDefault profile: The special [default] section is used when no explicit profile is selected.
Named profile: Every non-default profile in the config file uses the [profile profile-name] form. For example, the profile named development is written as [profile development].
This differs from the credentials file. The same profile is written as [development] in ~/.aws/credentials. Omitting the profile prefix in the config file can cause settings to be ignored.
Regions and output formats
An AWS Region is a geographic area where many AWS services and resources are scoped. Configure a Region when a command or service requires one.
[default]
region = us-east-1
output = json
[profile development]
region = us-west-2
output = yaml
[profile production]
region = us-east-1
output = tableThe profile-specific values apply when that profile is active. Common output formats are json, yaml, yaml-stream, text, and table.
| Format | Best for | Strengths | Limitations |
|---|---|---|---|
json | Scripts and general inspection | Structured and widely supported | Can be verbose |
yaml | Human-readable structured data | Readable hierarchy | Less convenient for some shell parsers |
yaml-stream | Streaming or large results | Outputs YAML documents progressively | Requires a compatible consumer |
text | Simple shell pipelines | Compact and easy to scan | Less explicit structure |
table | Interactive terminal use | Readable columns | Not suitable for reliable parsing |
Override a configured value for one command without editing the file:
aws s3 ls --profile development --region eu-west-1 --output tableCreating and selecting profiles
aws configure interactively creates or updates the default profile. To work with a named profile, provide --profile.
aws configure
aws configure --profile developmentFor non-secret settings, aws configure set writes directly to the selected profile:
aws configure set region us-west-2 --profile development
aws configure set output yaml --profile developmentSelect a profile for one command with --profile:
aws sts get-caller-identity --profile developmentAlternatively, set AWS_PROFILE in the current shell:
AWS_PROFILE=development aws ec2 describe-regionsWhen neither --profile nor AWS_PROFILE selects a profile, the CLI uses [default].
| Mechanism | Example | Typical use | Relative precedence |
|---|---|---|---|
| Command option | --profile development --region us-west-2 | One-command override | Highest for the specified setting |
| Environment variable | AWS_PROFILE=development | Shell sessions and automation | Generally above file defaults |
| Config file | [profile development] | Persistent profile behavior | Used when not overridden |
| Default profile | [default] | Fallback when no profile is selected | Fallback profile selection |
Use descriptive names such as development, production-readonly, or audit-account-a to separate accounts, environments, and roles.
Credential sources and profile relationships
A profile does not have to contain credentials. The CLI can obtain credentials from the environment, the credentials file, a credential process, IAM Identity Center, or instance and container metadata.
| Pattern | Key settings | Credential origin | Best use case |
|---|---|---|---|
| Static local profile | Profile in the credentials file | Access keys stored locally | Compatibility with controlled local use; avoid when temporary credentials are available |
| Source profile | source_profile = developer | Another local profile | Assuming a role from a base profile |
| Runtime source | credential_source = Environment, Ec2InstanceMetadata, or EcsContainer | Environment variables or runtime metadata | CI, EC2, and ECS workloads |
| External process | credential_process | A command returning temporary credentials | Enterprise credential brokers and custom providers |
| IAM Identity Center | sso_session and account or role settings | Temporary workforce credentials | Human access to multiple AWS accounts |
source_profile names another local profile whose credentials are used to obtain credentials for the current profile. credential_source instead tells the CLI to use a runtime provider. Supported values include Environment, Ec2InstanceMetadata, and EcsContainer.
IAM role-assumption profiles
An IAM role-assumption profile uses initial credentials to obtain temporary credentials for a target IAM role. The target role is identified by role_arn.
[profile engineering-readonly]
role_arn = arn:aws:iam::123456789012:role/EngineeringReadOnly
source_profile = developer
role_session_name = cli-engineering-session
region = us-east-1source_profile references a local base profile. For workloads that receive credentials through the environment, use credential_source instead:
[profile deployment-role]
role_arn = arn:aws:iam::123456789012:role/DeploymentRole
credential_source = Environment
region = us-east-1role_session_name labels the temporary session. A descriptive value can improve CloudTrail and other audit records. Some roles also require external_id or mfa_serial:
[profile vendor-access]
role_arn = arn:aws:iam::123456789012:role/VendorAccess
source_profile = vendor-base
role_session_name = approved-vendor-session
external_id = approved-external-id
mfa_serial = arn:aws:iam::123456789012:mfa/operatorThe source identity must be allowed to call sts:AssumeRole, and the target role trust policy must trust that identity. Role chaining means assuming a role using credentials that were themselves obtained by assuming another role. Chained sessions have stricter duration limitations, so avoid unnecessary chains and design the trust path deliberately.
Select an assume-role profile like any other profile:
aws sts get-caller-identity --profile engineering-readonlyIAM Identity Center profiles
IAM Identity Center, previously commonly called AWS SSO, provides browser-based workforce sign-in and temporary AWS credentials. Modern configuration separates reusable sign-in data into an sso-session section. A profile references that session with sso_session.
[sso-session company]
sso_start_url = ORGANIZATION_PROVIDED_START_URL
sso_region = us-east-1
sso_registration_scopes = sso:account:access
[profile company-admin]
sso_session = company
sso_account_id = 123456789012
sso_role_name = AdministratorAccess
region = us-east-1
output = jsonsso_start_url identifies the organization's IAM Identity Center portal, sso_region identifies the sign-in service Region, and sso_account_id and sso_role_name select the AWS account and role where applicable.
Sign in before using the profile:
aws sso login --profile company-admin
aws sts get-caller-identity --profile company-adminThe CLI caches temporary sign-in tokens locally. They expire and should not be manually copied or treated as static access keys.
Advanced configuration settings
| Setting | Purpose | Typical values | Applicable profile types |
|---|---|---|---|
credential_process | Run a command that supplies temporary credentials in the AWS CLI process format | Organization-approved credential helper | Profiles using an external provider |
web_identity_token_file | Read a federated identity token used with a role | Path to a workload token file | Web identity federation workloads |
role_arn | Specify the role to assume | IAM role ARN | Role profiles and web identity profiles |
retry_mode | Choose retry behavior | standard, adaptive, or legacy | Any profile |
max_attempts | Set the maximum retry attempts | Positive integer | Any profile |
cli_pager | Control paging of output | Pager command or empty value | Any profile |
cli_auto_prompt | Control interactive command prompting | on, on-partial, or off | Any profile |
cli_binary_format | Control binary parameter encoding | base64 or raw-in-base64-out | Any profile |
endpoint_url | Use a custom service endpoint | Organization-approved endpoint | Approved private endpoints and local emulators |
ca_bundle | Trust an organization-provided certificate authority bundle | Path to a CA bundle | Profiles reaching endpoints with custom trusted CAs |
Web identity configuration commonly combines role_arn with web_identity_token_file:
[profile workload]
role_arn = arn:aws:iam::123456789012:role/WorkloadRole
web_identity_token_file = /path/to/approved/token
region = us-east-1Use endpoint_url only when an approved environment requires a local emulator, private endpoint, or other nonstandard service endpoint. A custom endpoint can change where commands send data. When TLS uses an organizational certificate authority, configure ca_bundle rather than disabling certificate verification.
Inspecting and validating configuration
List profiles recognized by the CLI:
aws configure list-profilesInspect resolved settings and their sources for the default profile:
aws configure listInspect a named profile:
aws configure list --profile developmentUse the harmless identity operation sts get-caller-identity to verify the active account and principal:
aws sts get-caller-identity --profile developmentUse --debug carefully when diagnosing provider selection, profile loading, region selection, or endpoint resolution:
aws sts get-caller-identity --profile development --debugDebug output can reveal paths, provider behavior, and request details. Do not share it without reviewing and removing sensitive information.
Troubleshooting common problems
A Region is required
- Check the intended profile with
aws configure list --profile profile-name. - Check whether
AWS_PROFILEselects a different profile. - Run the command with an explicit
--regionto confirm the cause. - Set
regionin the intended profile or use an approved environment override.
Credentials cannot be located
- Verify the selected profile and its credential source.
- Check that a
source_profileexists and is spelled correctly. - For
credential_source = Environment, confirm that the runtime injected usable credentials. - For IAM Identity Center, run
aws sso login --profile profile-name. - Confirm the result with
aws sts get-caller-identity --profile profile-name.
Role assumption is denied
- Identify the source principal with
sts get-caller-identity. - Verify that it has
sts:AssumeRolepermission. - Review the target role trust policy.
- Check
role_arn,source_profile,external_id, andmfa_serial.
A named config profile is ignored
- Use
[profile name]in the config file. - Use
[name]in the credentials file. - Run
aws configure list-profilesto see which names the CLI recognizes.
Unexpected credentials or settings are used
- Run
aws configure listand inspect the source of each resolved value. - Check
AWS_PROFILE,AWS_REGION,AWS_DEFAULT_REGION, and other AWS environment variables. - Check shell startup files and CI configuration for injected values.
- Use
--profileexplicitly and verify the account withsts get-caller-identity.
Certificate validation fails for a custom endpoint
- Verify the endpoint setting and network path.
- Ask the endpoint operator to confirm the certificate chain.
- Configure an authorized organizational
ca_bundlewhen required. - Do not disable certificate verification as a routine workaround.
Security and operational practices
- Keep long-term access keys out of the config file and avoid committing either
~/.aws/configor~/.aws/credentialsto source control. - Prefer IAM roles, IAM Identity Center, temporary credentials, or workload identity over static access keys.
- Restrict permissions on AWS configuration and credential files. On Unix-like systems, review ownership and use restrictive permissions such as
chmod 600 ~/.aws/credentialswhere appropriate. - Use descriptive profile names and separate production access from development and testing access.
- Do not share profile files casually. Even configuration-only files can disclose account IDs, role names, internal endpoints, or local credential-provider commands.
- Review external credential-process commands before enabling them, because the command runs locally and can access its execution environment.