A developer is troubleshooting a Python application running on a local workstation. The application uses the AWS SDK for Python (Boto3) to read objects from an Amazon S3 bucket. To configure the correct development credentials, the developer creates a profile named 'dev-profile' in the local ~/.aws/credentials file and sets the environment variable AWS_PROFILE=dev-profile in the terminal. However, when executing the script, the developer receives an AccessDenied error indicating that access is denied for an old, incorrect IAM user that is not defined in the 'dev-profile'. Which of the following is the most likely cause of this behavior?
- Active AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables are set in the terminal session, which take precedence over the AWS_PROFILE environment variable.Answer
- BThe Boto3 client initialization code explicitly specifies hardcoded, expired access keys in its parameters, which overrides the profile configuration.
- CThe local workstation's IP address is not explicitly authorized under an IAM trust policy, which prevents Boto3 from reading profiles in the shared credentials file.
- DThe application is attempting to retrieve access credentials from Systems Manager Parameter Store instead of AWS Secrets Manager, causing a fallback to default credentials.
Answer
Active AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables are set in the terminal session, which take precedence over the AWS_PROFILE environment variable.
The correct option is correct because the AWS SDK credential provider chain evaluates explicit credential environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY) before the shared credentials file. If these environment variables are set in the active terminal session, Boto3 will use them and ignore the profile specified by the AWS_PROFILE environment variable.
Step-by-Step Solution
Key Concept
AWS SDK Credential Provider Chain Precedence