An enterprise runs an application on Amazon EC2 instances inside a private subnet in VPC A under AWS Account A. The application must retrieve sensitive database credentials stored in AWS Secrets Manager inside a central security account (Account B). Currently, the EC2 instances access Secrets Manager via an Interface VPC Endpoint (AWS PrivateLink) created in VPC A. To strengthen network and identity security, the solutions architect must ensure that only these specific application EC2 instances can retrieve this particular secret, and that no other resources in VPC A can use the Interface VPC Endpoint to access Secrets Manager. Which combination of actions will meet these requirements?
- Configure the VPC Endpoint policy on the Secrets Manager interface endpoint in VPC A to allow secretsmanager:GetSecretValue for the secret ARN in Account B only when the principal is the application's IAM role. Configure the secret resource policy in Account B to allow the IAM role to retrieve the secret. Encrypt the secret using a customer managed KMS key in Account B, and update its key policy to grant the application's IAM role kms:Decrypt permissions. Set the VPC endpoint's security group to only allow inbound traffic from the application EC2 instances' security group.Answer
- BConfigure the VPC Endpoint policy on the Secrets Manager interface endpoint in VPC A to allow secretsmanager:GetSecretValue for the secret ARN in Account B only when the principal is the application's IAM role. Configure the secret resource policy in Account B to allow the IAM role to retrieve the secret. Encrypt the secret using the default AWS managed key (aws/secretsmanager) in Account B, and configure a Service Control Policy (SCP) in Account B to permit Account A's IAM role to decrypt using this key. Set the VPC endpoint's security group to only allow inbound traffic from the application EC2 instances' security group.
- CCreate a Service Control Policy (SCP) at the root of the AWS Organization that explicitly grants secretsmanager:GetSecretValue and kms:Decrypt permissions for the application's IAM role to access Account B resources. In VPC A, configure the VPC Endpoint policy to allow all principals (*) to access the Secrets Manager endpoint. Use the default AWS managed key for Secrets Manager in Account B to encrypt the secret. Set the VPC endpoint's security group to only allow inbound traffic from the application EC2 instances' security group.
- DConfigure the VPC Endpoint policy on the Secrets Manager interface endpoint in VPC A to allow secretsmanager:GetSecretValue for the secret ARN in Account B for all principals. In Account B, share the customer managed KMS key and the database secret with Account A using AWS Resource Access Manager (RAM). Set the security group on the Interface VPC Endpoint to allow inbound traffic from the entire VPC A CIDR block.
Answer
Configure the VPC Endpoint policy to allow only the application's IAM role to access the secret in Account B, use a customer managed KMS key in Account B with a key policy allowing cross-account decryption, configure the secret resource policy to trust the role, and restrict the endpoint security group to allow inbound traffic only from the application EC2 instances' security group.
The correct solution uses a customer managed KMS key (CMK) in Account B with a key policy that grants decrypt permissions to the cross-account role in Account A. This is necessary because AWS-managed keys cannot have their key policies modified for cross-account access. In addition, configuring the VPC endpoint policy to restrict access to the specific IAM role and target secret ARN, combined with a security group that limits inbound traffic to only the application's security group, ensures both network and identity-level security constraints are met.
Step-by-Step Solution
Key Concept
Cross-account access to AWS Secrets Manager using Customer Managed KMS Keys and restricting access via Interface VPC Endpoint policies.