A developer is configuring an Amazon ECS task definition to deploy a backend service to AWS Fargate. The service requires sensitive database credentials stored in AWS Systems Manager Parameter Store to be injected as environment variables when the container starts. Additionally, the service logs must be sent directly to Amazon CloudWatch Logs. Which TWO configurations must the developer implement to meet these requirements?
- Add the ssm:GetParameters and logs:PutLogEvents permissions to the ECS Task Execution Role.Cevap
- In the task definition, define the secrets parameter inside the container definition referencing the Parameter Store parameter ARNs, and configure the logConfiguration parameter to use the awslogs log driver.Cevap
- CAdd the ssm:GetParameters and logs:PutLogEvents permissions to the ECS Task Role.
- DAdd a trust policy to the ECS Task Role that allows the Systems Manager service principal (ssm.amazonaws.com) to assume the role.
- EStore the database credentials in the environment parameter of the task definition, and configure the task definition to use the host network mode to forward logs.
Cevap
The correct configurations are: adding ssm:GetParameters and logs:PutLogEvents permissions to the ECS Task Execution Role, and defining the secrets parameter referencing the Parameter Store ARNs along with the awslogs log driver in the container definition.
The correct configuration requires adding the necessary permissions to the ECS Task Execution Role, as this is the IAM role used by the ECS container agent to call AWS APIs (like SSM to pull parameters and CloudWatch to write logs) before the containerized application runs. Additionally, the task definition must use the 'secrets' parameter to declare the environment variables mapped to SSM parameters, and configure 'logConfiguration' with the 'awslogs' driver to natively forward standard output and standard error stream logs.
Adım Adım Çözüm
Anahtar Kavram
ECS Task Role vs. Task Execution Role & ECS Secret Injection
Tahmini Süre:2m 0s