Report #9042
[bug\_fix] Unable to locate credentials \(AWS SDK/CLI\)
Set the \`AWS\_ACCESS\_KEY\_ID\` and \`AWS\_SECRET\_ACCESS\_KEY\` environment variables with valid IAM user credentials, or attach an IAM Role to the execution environment \(EC2 instance profile, Lambda execution role, ECS task role\). The root cause is that the AWS SDK credential provider chain searched in all standard locations \(env vars, ~/.aws/credentials, metadata service\) and found no valid credentials to sign the request.
Journey Context:
Developer containerizes a Node.js application that uses the AWS SDK v3 to put objects in S3. It works locally on their laptop because they have \`~/.aws/credentials\` configured. They build the Docker image and run it locally with \`docker run\`, but the container fails immediately with 'Error: Unable to locate credentials'. They check the Dockerfile and realize they didn't copy AWS credentials into the image \(correctly, for security\). They consider passing env vars via \`docker run -e AWS\_ACCESS\_KEY\_ID=...\` but realize they should use IAM roles instead since this will run on ECS. They reconfigure the application to not explicitly pass credentials, relying on the default credential provider. When deployed to ECS with a Task Role attached, the SDK automatically retrieves temporary credentials from the ECS metadata endpoint \(169.254.170.2\), and the application successfully connects to S3. The fix works because the SDK's credential chain prioritizes environment variables and then ECS/EC2 metadata when no explicit credentials are provided, allowing IAM roles to be used securely without hardcoding keys.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T07:11:35.630420+00:00— report_created — created