An organization hosts a critical multi-region web application on Amazon ECS Fargate across the us-east-1 and us-west-2 Regions. The application connects to an Amazon Aurora Global Database. A developer needs to design a secure solution to manage the database password. The password must be rotated every 30 days, and ECS tasks in both Regions must be able to retrieve the credentials locally with minimal latency. Which solution meets these requirements with the least operational overhead?
- AStore the database credentials as a SecureString parameter in AWS Systems Manager Parameter Store in us-east-1 and us-west-2. Configure an AWS Lambda function triggered by an Amazon EventBridge scheduled rule to update the database password, update the parameter in the primary Region, and copy it to the secondary Region.
- BStore the database credentials in AWS Secrets Manager in the primary Region. In the ECS task application code, initialize the AWS SDK client using hardcoded IAM user access keys to authenticate and retrieve the secret value from the primary Region during application startup.
- CStore the database credentials in AWS Secrets Manager in the primary Region, configure automatic rotation using the built-in RDS rotation template, and replicate the secret to the secondary Region. In the ECS task definition, assign the permission to retrieve the secret to the ECS Task Role, and reference the local Secrets Manager ARN in the container definition's environment variables (valueFrom).
- Store the database credentials in AWS Secrets Manager in the primary Region, configure automatic rotation using the built-in RDS rotation template, and replicate the secret to the secondary Region. In the ECS task definition, assign the permission to retrieve the secret to the ECS Task Execution Role, and reference the local Secrets Manager ARN in the container definition's environment variables (valueFrom).Answer
Answer
Store the database credentials in AWS Secrets Manager in the primary Region, configure automatic rotation using the built-in RDS rotation template, and replicate the secret to the secondary Region. In the ECS task definition, assign the permission to retrieve the secret to the ECS Task Execution Role, and reference the local Secrets Manager ARN in the container definition's environment variables (valueFrom).
The correct solution leverages AWS Secrets Manager's native support for automatic rotation of database credentials using built-in AWS Lambda rotation templates. Replicating the secret to the secondary Region ensures that ECS Fargate tasks can retrieve the secret locally, minimizing latency. To inject secrets as environment variables during task startup, the ECS container agent retrieves the secret, which requires the necessary permissions to be attached to the ECS Task Execution Role, rather than the ECS Task Role.
Step-by-Step Solution
Key Concept
Database credential rotation, multi-region replication, and ECS task execution role permissions for secrets injection.
Estimated Time:2m 30s