A developer is configuring a Java-based backend service that uses the AWS SDK to read objects from an Amazon S3 bucket. The service will be deployed to Amazon Elastic Container Service (ECS) on Amazon EC2 container instances. During testing, the developer wants to ensure that the SDK retrieves credentials securely using the default credential provider chain.
Which two credential sources are checked by the default credential provider chain before it attempts to retrieve credentials from the Amazon EC2 Instance Metadata Service (IMDS)?
- Environment variables such as `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`Answer
- The shared credentials file (typically located at `~/.aws/credentials` on the host)Answer
- CThe credentials associated with the Amazon ECS Task Execution Role
- DAn encrypted parameter stored in Systems Manager Parameter Store containing the access keys
- EHardcoded credentials specified directly within the Java code when instantiating the S3 client
Answer
The default credential provider chain resolves environment variables and the shared credentials file before checking the Amazon EC2 Instance Metadata Service.
The default credential provider chain checks environment variables (like `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`) first, and subsequently checks the shared credentials file (usually at `~/.aws/credentials`). Both of these checks occur before the SDK attempts to query the Amazon EC2 Instance Metadata Service (IMDS) for instance profile credentials.
Step-by-Step Solution
Key Concept
AWS SDK Default Credential Provider Chain Order of Precedence
Estimated Time:1m 30s