BioPharma Nexus is modernizing its legacy drug discovery simulation application by migrating it from on-premises servers to Amazon ECS on AWS Fargate. The application is deployed across multiple private subnets in a Workload VPC. The container images are hosted in an Amazon ECR repository in a centralized Shared Services AWS account. The tasks also retrieve database credentials from AWS Secrets Manager in the Workload account, which are encrypted using a customer managed AWS KMS key in the Workload account.
To comply with strict security standards, no internet gateways or NAT gateways are allowed in either VPC. An AWS Transit Gateway connects the Workload VPC and the Shared Services VPC. Interface VPC endpoints for ECR (api and dkr), Secrets Manager, and KMS are established in the Shared Services VPC. The Route 53 Private Hosted Zones (PHZs) for these endpoints are currently associated only with the Shared Services VPC.
When deploying the ECS tasks in the Workload VPC, they fail to transition to the RUNNING state, displaying the error: 'ResourceInitializationError: unable to pull secrets or registry auth'.
Which of the following solutions will resolve the initialization error and allow the tasks to run successfully?
- AAssociate the ECR, Secrets Manager, and KMS Private Hosted Zones with the Workload VPC. Create an S3 Gateway VPC endpoint in the Shared Services VPC, and add a route in the Workload VPC route tables directing S3-bound traffic to the Transit Gateway.
- Associate the ECR, Secrets Manager, and KMS Private Hosted Zones with the Workload VPC. Create an S3 Gateway VPC endpoint in the Workload VPC and associate it with the Workload VPC route tables. Ensure the ECS task execution role has permissions to pull ECR images, retrieve the Secrets Manager secret, and decrypt it using the customer managed KMS key.Answer
- CModify the ECS task definition to use host network mode to allow the container to bypass Fargate VPC endpoint restrictions. Associate the ECR, Secrets Manager, and KMS Private Hosted Zones with the Workload VPC, and create an S3 Gateway VPC endpoint in the Shared Services VPC.
- DCreate ECR, Secrets Manager, and KMS Interface VPC endpoints locally in the Workload VPC. Configure the ECS tasks to use the default AWS-managed KMS key (aws/secretsmanager) to decrypt the database credentials, and update the key policy in the Workload account to trust the Workload task execution role.