A developer is implementing a microservice in AWS Account A that needs to securely access a database credential managed in a centralized security AWS Account B. The microservice must access the credential directly without assuming an IAM role in Account B. Which approach should the developer use to meet these requirements?
- AStore the credential as a SecureString parameter in AWS Systems Manager Parameter Store in Account B, and attach a resource-based policy to the parameter that grants read permissions to the IAM execution role of the microservice in Account A.
- BStore the credential in AWS Systems Manager Parameter Store in Account A, and initialize the AWS SDK client inside the microservice code by hardcoding the AWS access key and secret key of an IAM user created in Account B.
- Store the credential in AWS Secrets Manager in Account B, attach a resource-based policy to the secret that allows the IAM execution role of the microservice in Account A to retrieve it, and encrypt the secret using an AWS KMS customer managed key that grants decryption permissions to Account A.Answer
- DStore the credential in AWS Secrets Manager in Account B, encrypt the secret using the default AWS managed key (aws/secretsmanager), and update the IAM execution role in Account A to allow decryption using the default AWS managed key.
Answer
Store the credential in AWS Secrets Manager in Account B, attach a resource-based policy to the secret that allows the IAM execution role of the microservice in Account A to retrieve it, and encrypt the secret using an AWS KMS customer managed key that grants decryption permissions to Account A.
The correct approach is to store the credential in AWS Secrets Manager in Account B, attach a resource-based policy to the secret to allow Account A's role to retrieve it, and use a customer managed KMS key that grants cross-account decryption permissions. AWS Secrets Manager supports resource-based policies, enabling direct access from another account without assuming a role. Additionally, default AWS managed KMS keys cannot be shared across accounts, necessitating a customer managed key.
Step-by-Step Solution
Key Concept
Cross-account access capabilities and encryption configurations in AWS Secrets Manager versus Systems Manager Parameter Store.