A developer is creating a CloudFormation custom resource backed by a Lambda function to configure an Amazon OpenSearch Service domain. The Lambda must use the OpenSearch internal master user credentials to access the domain. What is the most secure way to provide these credentials to the Lambda function?
Choose an answer
Tap an option to check your answer.
Correct answer: Use CloudFormation to create a Secrets Manager secret, reference the secret value with a CloudFormation dynamic reference for the OpenSearch domain’s MasterUserOptions, and give the Lambda an IAM role with secretsmanager:GetSecretValue. Store the secret name in the Lambda environment variable and retrieve the secret at runtime..
Why this is the answer
Using AWS Secrets Manager is the most secure method. It allows you to store, manage, and retrieve sensitive credentials, including master user passwords, securely. CloudFormation can create the secret, and a dynamic reference ensures the OpenSearch domain uses the correct credentials without exposing them in the template. The Lambda function, granted secretsmanager:GetSecretValue permissions via its IAM role, can then retrieve the secret at runtime, ensuring credentials are never hardcoded or exposed in environment variables. Passing credentials directly as CloudFormation parameters or environment variables, even with NoEcho=true, is less secure as they can still be viewed in console or logs. While Systems Manager Parameter Store is better than direct environment variables, Secrets Manager offers more robust secret rotation and management features specifically designed for sensitive credentials. Encrypting with KMS is good, but Secrets Manager provides a complete solution for secret lifecycle management.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed