Courseiva
Question 767 of 724
SecuritymediumMultiple ChoiceObjective-mapped

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 without internet access. Which method should be used to grant the instance access to DynamoDB securely?

⚠ Common exam trap

Candidates often confuse security groups with network routing, assuming that allowing outbound traffic to DynamoDB's IP range is sufficient, but without a VPC endpoint or internet gateway, the traffic has no route to reach the DynamoDB service.

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 a VPC endpoint for DynamoDB and attach an IAM role to the instance

A VPC Gateway Endpoint for DynamoDB allows EC2 instances in a private subnet to access DynamoDB without traversing the internet or requiring a NAT gateway. By attaching an IAM role to the EC2 instance, the application can securely obtain temporary credentials via the instance metadata service, eliminating the need to store long-term credentials 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.

  • Store AWS credentials in a file on the instance and use them in the application

    Why it's wrong here

    Storing AWS credentials directly in a file on an EC2 instance is a significant security risk. If the instance is compromised, these static, long-term credentials could be exfiltrated and used to access AWS resources indefinitely, leading to unauthorized access and potential data breaches. This method also complicates credential rotation and management, making it non-compliant with security best practices for production environments.

  • Configure security group rules to allow outbound traffic to DynamoDB

    Why it's wrong here

    Configuring security group rules to allow outbound traffic is insufficient for accessing DynamoDB because security groups operate at the network layer, controlling TCP/UDP ports and IP addresses. DynamoDB is an AWS service accessed via its API endpoints over HTTPS, not through a direct network connection to a specific IP address or port range that a security group would typically manage for a database instance. While outbound internet access might be a prerequisite for reaching public API endpoints, security groups do not provide the necessary authentication or authorization for the API calls themselves.

  • Attach a NAT gateway to the private subnet and use IAM user credentials

    Why it's wrong here

    Attaching a NAT Gateway enables instances in a private subnet to initiate outbound connections to the internet, which could include public AWS service endpoints, but it does not address authentication. Using IAM user credentials directly on an EC2 instance is insecure because these are long-term credentials designed for human users or programmatic access outside of AWS compute services. They lack the temporary, automatically rotated nature of IAM roles, posing a significant risk if compromised and requiring manual management.

  • Create a VPC endpoint for DynamoDB and attach an IAM role to the instance

    Why this is correct

    Creating a VPC endpoint for DynamoDB establishes a private, secure connection directly from the VPC to the DynamoDB service, bypassing the public internet and enhancing data security and network performance. Concurrently, attaching an IAM role to the EC2 instance provides temporary, automatically rotated credentials that the application can assume, adhering to the principle of least privilege and eliminating the need to store static credentials on the instance. This combination offers both secure network access and robust authentication.

Visual reference

Inside (Private) PC-A 10.0.0.1 PC-B 10.0.0.2 NAT Router Outside (Public) 203.0.113.1 Inside Global Server PAT: many private IPs share one public IP via unique port numbers

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

Same concept, more angles

1 more way this is tested on DVA-C02

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. 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?

hard
  • A.Create a VPC endpoint for DynamoDB and attach a security group to allow access.
  • B.Store IAM user access keys in the application configuration file.
  • C.Create an IAM role with DynamoDB access and attach it to the EC2 instance profile.
  • D.Use a security group to allow the EC2 instance to communicate with DynamoDB.

Why C: 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.

Last reviewed: Jun 24, 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.