A developer is deploying a microservice to Amazon Elastic Container Service (Amazon ECS) on AWS Fargate. The microservice needs to connect to an Amazon Aurora MySQL database. The database credentials must be rotated automatically every 30 days to comply with organizational security policies. The developer needs to implement a solution that retrieves these credentials securely without hardcoding them or causing application downtime during rotation.
Which two actions should the developer take to meet these requirements? (Select TWO.)
- Store the database credentials in AWS Secrets Manager and enable automatic rotation using the built-in rotation function for Amazon RDS.Cevap
- Associate an IAM policy that allows the secretsmanager:GetSecretValue action to the ECS Task Role, and retrieve the credentials dynamically using the AWS SDK in the application code.Cevap
- CStore the database credentials in AWS Systems Manager Parameter Store as a SecureString parameter, and configure a custom AWS Lambda function to rotate the parameter value.
- DAttach an IAM policy that allows the secretsmanager:GetSecretValue action to the ECS Task Execution Role, and retrieve the credentials dynamically using the AWS SDK in the application code.
- EHardcode the database connection string containing the password inside the application code, and initialize the database client directly using these credentials.
Cevap
Store the database credentials in AWS Secrets Manager with automatic RDS rotation enabled, and retrieve the credentials dynamically using the AWS SDK in the application code with permissions granted by the ECS Task Role.
To securely manage and rotate database credentials without causing downtime, the credentials should be stored in AWS Secrets Manager. Secrets Manager offers native integration with Amazon RDS to rotate secrets automatically. To access the secret from the container, the application code must query Secrets Manager using the AWS SDK, which requires assigning permissions to the ECS Task Role. Since rotation happens every 30 days, retrieving the credentials dynamically ensures that the application always uses the most current password without requiring task restarts.
Adım Adım Çözüm
Anahtar Kavram
AWS Secrets Manager vs Systems Manager Parameter Store, and ECS Task Roles vs Task Execution Roles.