Least Effort Way to Rotate AWS Secrets for EC2 Startup?

A company runs a payment application on Amazon EC2 instances behind an Application Load Balance. The EC2 instances run in an Auto Scaling group across multiple Availability Zones. The application needs to retrieve application secrets during the application startup and export the secrets as environment variables. These secrets must be encrypted at rest and need to be rotated every month. Which solution will meet these requirements with the LEAST development effort?

  1. Save the secrets in a text file and store the text file in Amazon S3. Provision a customer managed key. Use the key for secret encryption in Amazon S3. Read the contents of the text file and read the export as environment variables. Configure S3 Object Lambda to rotate the text file every month.
  2. Save the secrets as strings in AWS Systems Manager Parameter Store and use the default AWS Key Management Service (AWS KMS) key. Configure an Amazon EC2 user data script to retrieve the secrets during the startup and export as environment variables. Configure an AWS Lambda function to rotate the secrets in Parameter Store every month.
  3. Save the secrets as base64 encoded environment variables in the application properties. Retrieve the secrets during the application startup. Reference the secrets in the application code. Write a script to rotate the secrets saved as environment variables.
  4. Store the secrets in AWS Secrets Manager. Provision a new customer master key. Use the key to encrypt the secrets. Enable automatic rotation. Configure an Amazon EC2 user data script to programmatically retrieve the secrets during the startup and export as environment variables. Source Reference Answer

Community Votes

D
100%

100% of anonymous learners picked answer D. Votes are pick records left by other test-takers — they are not the verified answer.

Community Insight

The exam tests your understanding of AWS Secrets Manager's built-in rotation feature versus manual or Lambda-based rotation in Parameter Store; the trap is assuming Parameter Store is equivalent for automatic rotation.

For EC2 applications needing encrypted, monthly-rotated secrets as environment variables, AWS Secrets Manager with automatic rotation is the least-effort solution. Community consensus strongly favors option D because Secrets Manager handles rotation natively, unlike Parameter Store.

Option B (Parameter Store) is the most common wrong answer because it can store secrets and retrieve them via user data, but it lacks native automatic rotation, requiring a custom Lambda function and thus more development effort.

Community Discussion (6 comments)

tgv 👍 6
rotation --> AWS Secrets Manager
CrescentShared 👍 6 Selected: D
D is right
Saudis 👍 1 Selected: D
rotated is key word :)
albert_kuo 👍 1 Selected: D
#!/bin/bash secret_value=$(aws secretsmanager get-secret-value --secret-id your-secret-id --query SecretString --output text) export SECRET_ENV_VAR=$secret_value
65703c1 👍 1 Selected: D
D is the correct answer.
seetpt 👍 2 Selected: D
D is right

Comments & Corrections

No comments yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Submitted for moderation before publishing. Keep it helpful and respectful.

Expert Analysis

Why the Answer Is Correct

Option D is correct because AWS Secrets Manager is purpose-built for storing and rotating secrets. It provides automatic rotation with a single click or API call, eliminating the need to write custom rotation logic. The EC2 user data script can retrieve secrets programmatically and export them as environment variables, satisfying the startup requirement. Secrets are encrypted at rest using a customer master key (CMK), and monthly rotation can be configured directly in Secrets Manager, meeting all requirements with minimal effort.

Community comments reinforce this: one commenter simply notes "rotation --> AWS Secrets Manager" (comment [1]), and another provides a clean user data script using the AWS CLI to fetch and export the secret (comment [2]). The high vote count for D (100%) shows broad consensus that Secrets Manager is the intended service for this scenario.

Why the Other Options Are Wrong

Option A (S3 + Object Lambda) is wrong because S3 is not designed for secret storage; Object Lambda is for transforming data on-the-fly, not rotating secrets, and this approach requires significant custom engineering. Option B (Parameter Store) stores secrets but has no native automatic rotation; you would need to build and manage an AWS Lambda rotation function, increasing development effort compared to Secrets Manager. Option C (base64 env vars in application properties) is insecure and does not encrypt secrets at rest or provide any rotation mechanism, making it completely invalid.

Community Comment Notes

Comments are unanimous for D, with several users simply stating "D is right" (comments [3], [4], [6]). One commenter emphasizes the keyword "rotated" (comment [5]), indicating that the presence of rotation in the requirement is the deciding factor. Another provides a practical example of the user data script (comment [2]), confirming that the retrieval mechanism is straightforward with the AWS CLI. No comment defends B, which suggests that even those who might consider Parameter Store realize it lacks the built-in rotation capability that Secrets Manager offers.

Official Reference

Exam Strategy

When you see 'rotate' plus 'least effort' in a secrets question, immediately think of AWS Secrets Manager's automatic rotation feature. Remember that Parameter Store can store secrets but requires custom rotation logic, so it is rarely the correct answer for a rotation-focused scenario.

Related Analysis

Practice All DVA-C02 Questions

Access 100 questions with complete answers and detailed explanations.

View Full DVA-C02 Practice Test →

← Back to DVA-C02 Study Guide