A company is deploying a new service in a multi-account environment. An Amazon ECS task running in Account B must retrieve a database credential stored in AWS Secrets Manager in Account A. The secret is encrypted using the default AWS-managed KMS key (aws/secretsmanager). A resource-based policy has been attached to the secret in Account A, granting read permissions to the IAM role of the ECS task in Account B. However, the ECS task still receives an access denied error when attempting to retrieve the credential. Which action must the Solutions Architect take to resolve this issue?
- AModify the key policy of the default AWS-managed KMS key (aws/secretsmanager) in Account A to grant KMS decrypt permissions to the ECS task IAM role in Account B.
- Re-encrypt the secret in Account A using a customer managed KMS key, configure the key policy of the customer managed KMS key to allow cross-account access from Account B, and grant KMS decrypt permissions to the ECS task IAM role in Account B.Answer
- CAttach a Service Control Policy (SCP) to the Organizational Unit of Account A that explicitly allows cross-account decryption operations for all roles in the organization.
- DConfigure the IAM role of the ECS task in Account B with a trust policy that trusts the AWS KMS service in Account A, allowing the role to assume the KMS key's permissions directly.
Answer
Re-encrypt the secret in Account A using a customer managed KMS key, configure the key policy of the customer managed KMS key to allow cross-account access from Account B, and grant KMS decrypt permissions to the ECS task IAM role in Account B.
Re-encrypting the secret with a customer managed KMS key is required because AWS-managed KMS keys (like aws/secretsmanager) cannot be shared across accounts. A customer managed KMS key's policy can be updated to trust Account B, and the IAM role in Account B can then be granted decrypt permissions.
Step-by-Step Solution
Key Concept
Cross-account AWS KMS access constraints and differences between AWS-managed keys and customer managed keys.