Courseiva
Question 1,157 of 724
SecuritymediumMultiple ChoiceObjective-mapped

DVA-C02 Security Practice Question

A developer launches an Amazon EC2 instance that needs to read and write data to an Amazon DynamoDB table. The developer must follow the principle of least privilege and ensure that no long-term credentials are stored on the instance. Which approach should the developer use?

⚠ Common exam trap

Watch out — candidates often choose Option B (Parameter Store) thinking it securely stores credentials, but they overlook that the instance still needs an IAM role to access Parameter Store, and the retrieved credentials are static rather than automatically rotated temporary credentials, which fails the 'no long-term credentials' requirement.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Create an IAM role with the necessary DynamoDB permissions, and attach the role to the EC2 instance profile. The SDK will automatically retrieve temporary credentials from the instance metadata.

It uses an IAM role attached to the EC2 instance profile, which allows the AWS SDK to automatically retrieve temporary credentials from the instance metadata service (IMDS). This follows the principle of least privilege by granting only the necessary DynamoDB permissions and eliminates the need to store any long-term credentials on the instance, as the credentials are rotated automatically by AWS STS.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Create an IAM user with programmatic access, store the access key and secret key in a configuration file on the EC2 instance.

    Why it's wrong here

    This approach is a significant security anti-pattern. Storing static IAM user access keys and secret keys directly on an EC2 instance creates a persistent attack vector; if the instance is compromised, these long-term credentials can be exfiltrated and used indefinitely until manually rotated or revoked. This method also lacks automatic credential rotation, increasing the operational burden and the window of vulnerability.

  • Store the DynamoDB credentials in AWS Systems Manager Parameter Store as a SecureString, and retrieve them from the EC2 instance at runtime.

    Why it's wrong here

    While AWS Systems Manager Parameter Store is excellent for secure configuration management, this solution introduces a circular dependency without solving the core problem. The EC2 instance would still require some form of credentials, likely an IAM user's access key or an IAM role, to authenticate and retrieve the DynamoDB credentials from Parameter Store. This means long-term credentials would still be present on the instance, just shifted from DynamoDB direct access to Parameter Store access, maintaining the same security risk.

  • Create an IAM role with the necessary DynamoDB permissions, and attach the role to the EC2 instance profile. The SDK will automatically retrieve temporary credentials from the instance metadata.

    Why this is correct

    This is the recommended and most secure method. By attaching an IAM role to the EC2 instance profile, the instance is granted temporary, frequently rotated credentials via the Instance Metadata Service (IMDS). AWS SDKs and CLIs automatically query IMDS for these credentials, eliminating the need to store any long-term access keys directly on the instance. This significantly reduces the attack surface and simplifies credential management.

  • Use a Lambda function to generate temporary credentials for the EC2 instance and pass them via user data at launch.

    Why it's wrong here

    This approach is overly complex and introduces new security vulnerabilities. While a Lambda function could generate temporary credentials, passing them via user data means they are stored unencrypted on the instance, accessible to anyone with sufficient permissions to view instance details. Furthermore, these temporary credentials would still need to be refreshed and managed manually by the application, which is precisely what IAM roles and the Instance Metadata Service are designed to automate securely.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 11, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This DVA-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DVA-C02 exam.