Report #78549
[bug\_fix] AWS Unable to locate credentials: No credentials found in the credential chain
Provide valid credentials through one of the standard credential provider chain locations: environment variables \(AWS\_ACCESS\_KEY\_ID, AWS\_SECRET\_ACCESS\_KEY\), the shared credentials file \(~/.aws/credentials\), IAM instance profile attached to EC2/ECS/Lambda, or explicit configuration in code via \`aws configure\`. For ECS, ensure the task has a task role assigned. For Lambda, ensure the function has an execution role. For EC2, attach an instance profile or set the metadata options to allow IMDSv2.
Journey Context:
Developer clones a repository and tries to run a Python script that uses boto3 to list S3 buckets. It immediately fails with 'Unable to locate credentials'. Developer checks their shell - they haven't run \`aws configure\`. They set the environment variables AWS\_ACCESS\_KEY\_ID and AWS\_SECRET\_ACCESS\_KEY in their \`.bashrc\` but make a typo in the secret key \(missing last character\). They source the file and run again - same error. They check \`echo $AWS\_ACCESS\_KEY\_ID\` - it's set. They check \`~/.aws/credentials\` - the file doesn't exist. They realize the typo in the env var, fix it, and it works locally. Later, they deploy to an EC2 instance and get the same error. They SSH into the instance and find no env vars set and no credentials file \(as expected for secure deployment\). They realize they forgot to attach an IAM Instance Profile to the EC2 instance. They create a launch template revision with the instance profile attached, terminate the old instance, and let the ASG spin up a new one. The SDK now successfully retrieves credentials from the Instance Metadata Service \(IMDSv2\) and the application starts. The root cause was that the AWS SDK searches a specific chain: EnvProvider -> SharedCredentialsProvider -> WebIdentityTokenProvider -> EC2/ECS/ContainerMetadata -> ProcessProvider, and if none return valid credentials, it throws this error.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T14:26:29.981809+00:00— report_created — created