/errors/aws-cli/unable-to-locate-credentials
AWS CLI: Unable to locate credentials. You can configure credentials by running aws configure
The commands on this page have not been executed by our verification runner yet.updated 2026-10-20
- tool
- AWS CLI
- exit code
- 253
- versions
- AWS CLI v2
- os
- any
The AWS CLI looks for credentials in a fixed order: command-line options, environment variables, the shared credentials and config files (including SSO and credential_process profiles), and finally container and instance roles. When every step comes up empty, it stops with Unable to locate credentials. You can configure credentials by running "aws configure".
See what the CLI found
aws configure list # shows each value and where it came from (env, shared-credentials-file, iam-role…)
aws configure list-profiles
aws sts get-caller-identity # succeeds only with working credentialsFix: local machine
aws configure sso # IAM Identity Center (recommended)
aws sso login --profile dev
export AWS_PROFILE=devaws configure with access keys also works, but keys stored in ~/.aws/credentials never expire, so prefer SSO.
Fix: CI and servers
- GitHub Actions, GitLab CI: let the job assume an IAM role through OIDC (for example the
aws-actions/configure-aws-credentialsaction) instead of storing keys as secrets. - EC2 / ECS / EKS: attach an instance profile, task role or IRSA / Pod Identity role; the CLI picks it up automatically.
- sudo or another user:
~changes, so~/.awsis not found; run without sudo or passAWS_CONFIG_FILEandAWS_SHARED_CREDENTIALS_FILE.
Sources
Related pages
glossary · terraformWhat is Terraform state?Terraform state is the JSON record that maps each resource address in your code to the real object it manages and its last known attributes: terraform.tfstate.errors · terraformTerraform: Reference to undeclared input variableterraform validate and plan fail with Reference to undeclared input variable when code uses var.name without a variable block in the same module. How to fix it.config · terraformTerraform variable precedence: tfvars, auto.tfvars, -var and TF_VAR_Terraform reads variables from TF_VAR_ environment variables, terraform.tfvars, *.auto.tfvars, then -var-file and -var. Later sources win, shown with plans.