A developer is running a containerized Python application in Amazon ECS on AWS Fargate. The container needs to read messages from an Amazon SQS queue. The ECS Task Definition has an ECS Task Role assigned with the necessary SQS permissions. During deployment, the developer accidentally leaves the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY set to developer-specific credentials that do not have permission to access SQS. When the application initializes the Boto3 client, which of the following describes the credential resolution behavior and the result of the API calls?
- The application uses the credentials defined in the environment variables because environment variables take precedence over ECS container credentials in the default credential provider chain, causing the SQS API calls to fail.Cevap
- BThe application uses the ECS Task Role credentials because Fargate task runtimes override environment variable credentials to ensure security, resulting in successful SQS API calls.
- CThe application fails to initialize the SQS client because the SDK detects a conflict between the environment variables and the ECS task role credentials, raising a configuration exception.
- DThe application uses the ECS Task Execution Role credentials instead of the Task Role, causing the SQS API calls to fail because the Task Execution Role is only used for container pull and logging permissions.
Cevap
The application uses the credentials defined in the environment variables because environment variables take precedence over ECS container credentials in the default credential provider chain, causing the SQS API calls to fail.
The default credential provider chain checks for credentials in a specific order: first environment variables, then system properties (if applicable), then web identity token credentials, then shared credentials profiles, and finally ECS container credentials (Task Roles) and EC2 instance metadata. Because environment variables are checked first, any set environment variables will override the Task Role credentials, causing the application to use the unauthorized credentials and fail.
Adım Adım Çözüm
Anahtar Kavram
AWS SDK Default Credential Provider Chain precedence