A developer is troubleshooting an application that uses the AWS SDK to access Amazon S3. The application is running on an Amazon EC2 instance that has an IAM instance profile attached. However, the developer notices that the application is using outdated, static credentials instead of the temporary credentials provided by the instance profile. Which of the following could be the root causes of this behavior? (Select TWO.)
- AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables are defined in the operating system environment of the EC2 instance.Cevap
- A shared credentials file located at ~/.aws/credentials contains a [default] profile with static credentials.Cevap
- CThe trust policy of the IAM role associated with the instance profile does not explicitly list the private IP address of the EC2 instance.
- DThe SDK's default credential provider chain is configured to query the EC2 Instance Metadata Service (IMDS) before checking local environment variables.
- EThe application code is missing the required SDK configuration to automatically retrieve credentials from AWS Systems Manager Parameter Store.
Cevap
The application could be using static credentials because environment variables are defined on the EC2 instance, or because a shared credentials file with a default profile is present. Both of these sources take precedence over the EC2 instance profile in the AWS SDK default credential provider chain.
The AWS SDK default credential provider chain resolves credentials in a specific order of precedence. Environment variables (such as AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY) and the shared credentials file (such as the default profile in ~/.aws/credentials) are both evaluated before the Amazon EC2 Instance Metadata Service (IMDS). If either of these sources contains static credentials, the SDK will use them instead of the temporary credentials provided by the EC2 instance profile.
Adım Adım Çözüm
Anahtar Kavram
AWS SDK Default Credential Provider Chain Order of Precedence