A developer is configuring an Amazon ECS service on AWS Fargate to deploy a containerized application. The Docker image is hosted in a private Amazon Elastic Container Registry (ECR) repository located in a separate, central AWS account. The Fargate tasks will run in a private subnet within the developer's AWS account. Which configuration is required to allow the ECS service to successfully pull the container image and deploy the application?
- AConfigure the ECS Task Role in the developer's account with permissions to call ecr:GetAuthorizationToken and pull the image. Update the central ECR repository policy to allow access to the developer's ECS Task Role ARN, and configure VPC endpoints for ECR and Amazon S3.
- BModify the ECS Task Execution Role's trust policy to trust the central AWS account ID. Configure the central ECR repository to assume this role when retrieving images, and configure VPC endpoints for ECR and Amazon S3.
- Configure the ECS Task Execution Role in the developer's account with permissions to call ecr:GetAuthorizationToken and pull the image. Update the central ECR repository policy to allow access to the developer's ECS Task Execution Role ARN, and configure VPC endpoints for ECR and Amazon S3.Cevap
- DHardcode the central account's IAM user credentials in the task definition's container environment variables to authenticate the container registry pull, and configure VPC endpoints for ECR and Amazon S3.
Cevap
Configure the ECS Task Execution Role in the developer's account with permissions to call ECR APIs and pull the image, update the central ECR repository policy to trust this role, and establish VPC endpoints for ECR and Amazon S3.
The correct configuration uses the ECS Task Execution Role because the ECS container agent is responsible for pulling the image and authenticating with Amazon ECR. Since the ECR repository is in another account, the repository policy in that central account must trust the Task Execution Role ARN from the developer's account. Finally, because the Fargate task runs in a private subnet, VPC endpoints for ECR and S3 (or a NAT Gateway) are required for the ECS agent to communicate with ECR.
Adım Adım Çözüm
Anahtar Kavram
Distinction between ECS Task Role and Task Execution Role in cross-account ECR deployments