Question #743
A developer is deploying an application on AWS Fargate using Amazon ECS. The application requires certain environment variables to initialize properly during container startup. Where should these environment variables be configured?
Define the environment variables under the environment parameter in the service definition.
Define the environment variables under the environment parameter in the task definition.
Specify the environment variables in the command parameter within the task definition.
Specify the environment variables in the command parameter within the service definition.
Explanation
In Amazon ECS, environment variables are configured in the task definition under the environment parameter. The task definition acts as a blueprint for containers, defining runtime configurations such as environment variables, which are essential for application initialization.
- Why B is correct: The task definition directly controls container settings, including environment variables required at startup. This ensures variables are available when the container initializes.
- Why A is incorrect: The service definition manages task orchestration (e.g., scaling, load balancing) but does not handle container-specific configurations like environment variables.
- Why C/D are incorrect: The command parameter overrides the container's default command but does not set environment variables. Environment variables are specified separately under the environment parameter.
Key Point: Task definitions define container runtime settings, while service definitions handle task deployment and management.
Answer
The correct answer is: B