An application running on an Amazon ECS container using AWS Fargate in Account () needs to write objects to an Amazon S3 bucket in Account (). The application code uses the AWS SDK to call the AWS Security Token Service (STS) `AssumeRole` API to assume an IAM role named `CrossAccountS3Writer` in Account . However, the application receives an `AccessDenied` error on the `AssumeRole` call.
The ECS task definition is configured with the `taskRoleArn` parameter set to `arn:aws:iam::111122223333:role/ecsTaskRole` and the `executionRoleArn` parameter set to `arn:aws:iam::111122223333:role/ecsTaskExecutionRole`.
Which two actions are required to resolve this access issue and allow the application to write to the S3 bucket? (Select TWO.)
- Update the trust policy of the CrossAccountS3Writer role in Account B to trust the principal arn:aws:iam::111122223333:role/ecsTaskRole.Answer
- BUpdate the trust policy of the CrossAccountS3Writer role in Account B to trust the principal arn:aws:iam::111122223333:role/ecsTaskExecutionRole.
- Modify the application code to initialize the S3 client using the temporary security credentials returned by the AssumeRole call.Answer
- DHardcode a set of long-term IAM user access keys from Account B directly in the application configuration files to bypass STS.
- EAttach the AmazonS3FullAccess policy to the ecsTaskExecutionRole in Account A to authorize the S3 client.
Answer
Update the trust policy of the CrossAccountS3Writer role in Account B to trust the principal arn:aws:iam::111122223333:role/ecsTaskRole, and modify the application code to initialize the S3 client using the temporary security credentials returned by the AssumeRole call.
The correct options involve updating the trust policy of the CrossAccountS3Writer role in Account B to trust the principal arn:aws:iam::111122223333:role/ecsTaskRole, and modifying the application code to initialize the S3 client using the temporary security credentials returned by the AssumeRole call. The application runs using the container task role (ecsTaskRole), so the trust relationship must target this role. The SDK must also explicitly use the temporary credentials retrieved from AWS STS to interact with the S3 bucket.
Step-by-Step Solution
Key Concept
Cross-account access and task-level role delegation in Amazon ECS