Question 445 of 724
DVA-C02 Security Practice Question
An application running on an EC2 instance needs to access a DynamoDB table. The instance is in a private subnet. What is the most secure way to grant access without using long-lived credentials?
⚠ Common exam trap
Many candidates confuse network-level controls (VPC endpoints or security groups) with identity-based access control, mistakenly thinking that enabling private connectivity alone grants API access to DynamoDB.
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 DynamoDB access and attach it to the EC2 instance profile.
It uses an IAM role attached to the EC2 instance profile, which allows the instance to obtain temporary security credentials from the AWS Security Token Service (STS). This eliminates the need for long-lived credentials and follows the principle of least privilege. The instance can securely access DynamoDB without storing any secrets on the instance.
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 a VPC endpoint for DynamoDB and attach a security group to allow access.
Why it's wrong here
Creating a VPC endpoint for DynamoDB provides private network connectivity from your VPC to DynamoDB, bypassing the public internet. While a security group attached to the EC2 instance and the endpoint policy would control network reachability, VPC endpoints do not, by themselves, grant API-level permissions. An EC2 instance still requires explicit IAM authorization to perform actions on DynamoDB tables, making this option insufficient for granting access.
- ✗
Store IAM user access keys in the application configuration file.
Why it's wrong here
Storing static IAM user access keys (Access Key ID and Secret Access Key) directly in application configuration files is a severe security anti-pattern. These credentials are long-lived and, if compromised through source code repositories, misconfigured storage, or instance compromise, grant persistent access to the associated IAM user's permissions. This approach violates the principle of least privilege and significantly increases the attack surface, making it highly insecure.
- ✓
Create an IAM role with DynamoDB access and attach it to the EC2 instance profile.
Why this is correct
Attaching an IAM role with DynamoDB access to an EC2 instance profile is the AWS best practice for granting permissions to applications running on EC2 instances. This mechanism allows the EC2 instance to obtain temporary, frequently rotated credentials from the instance metadata service (IMDS). The application can then use these temporary credentials to make authorized API calls to AWS services like DynamoDB, eliminating the need to store static, long-lived credentials on the instance and enhancing security.
- ✗
Use a security group to allow the EC2 instance to communicate with DynamoDB.
Why it's wrong here
Security groups operate at the network layer, functioning as virtual firewalls to control inbound and outbound traffic to and from an EC2 instance. While a security group is necessary to permit outbound network connectivity to DynamoDB's service endpoints, it does not provide the necessary API-level authorization. An EC2 instance still requires explicit IAM permissions to perform actions like `dynamodb:PutItem` or `dynamodb:GetItem` on DynamoDB tables, regardless of network reachability.
Visual reference
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 →
Last reviewed: Jun 24, 2026
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.
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.
Sign in to join the discussion.