Question 332 of 1,616
SecurityhardMultiple ChoiceObjective-mapped

Quick Answer

The correct answer is to create a VPC endpoint for API Gateway and attach a resource policy that restricts access to that endpoint. This is the most secure approach because the resource policy uses the `aws:SourceVpce` condition key to explicitly allow traffic only from your specific VPC endpoint, ensuring that requests originating outside your VPC are denied at the API Gateway level. On the AWS Certified Developer Associate DVA-C02 exam, this question tests your understanding of combining network-level controls (VPC endpoints) with identity-based or resource-based policies for defense in depth. A common trap is assuming a private API Gateway alone is sufficient—it makes the API unreachable from the public internet, but without a resource policy, any service or resource inside the VPC can still invoke it. Another trap is confusing security groups (which apply to EC2 or Lambda network interfaces) with API Gateway, which operates at the application layer. Memory tip: think "VPCe + policy = locked down API," where the VPC endpoint is the door and the resource policy is the key that only lets your VPC in.

DVA-C02 Security Practice Question

This DVA-C02 practice question tests your understanding of security. Match the stated requirement to the specific cloud service, access model, or configuration option — many options are valid in isolation but not for this scenario. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

A developer is building a serverless application using AWS Lambda and API Gateway. The API should be accessible only from a specific VPC. What is the MOST secure way to achieve this?

Question 1hardmultiple choice
Full question →

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 API Gateway and attach a resource policy to the API that allows access only from the VPC endpoint.

Option D is correct because using a resource policy on API Gateway with aws:SourceVpce condition restricts access to requests originating from the VPC endpoint. Option A is wrong because private API Gateway endpoints are accessible from within a VPC without a resource policy. Option B is wrong because VPC Peering does not restrict access to API Gateway. Option C is wrong because security groups are for network interfaces, not API Gateway.

Key principle: NAT direction and interface roles matter as much as the IP address mapping. Inside/outside designation controls which traffic is translated.

Answer analysis

Option-by-option breakdown

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

  • Attach a security group to the API Gateway that only allows traffic from the VPC.

    Why it's wrong here

    Security groups cannot be attached to API Gateway.

  • Create a private API Gateway endpoint and associate it with the VPC.

    Why it's wrong here

    Private endpoints are accessible from within the VPC but still need a resource policy to restrict access.

  • Set up VPC Peering between the VPC and the API Gateway's VPC.

    Why it's wrong here

    API Gateway is a managed service, not in a VPC.

  • Create a VPC endpoint for API Gateway and attach a resource policy to the API that allows access only from the VPC endpoint.

    Why this is correct

    This restricts access to the VPC using aws:SourceVpce condition.

    Related concept

    Static NAT maps one inside address to one outside address.

Common exam traps

Common exam trap: NAT rules depend on direction and matching traffic

NAT is not only about the public address. The inside/outside interface roles and the ACL or rule that matches traffic are just as important.

Detailed technical explanation

How to think about this question

NAT questions usually test address translation, overload/PAT behaviour, static mappings and whether the right traffic is being translated. Read the interface direction and address terms carefully.

KKey Concepts to Remember

  • Static NAT maps one inside address to one outside address.
  • PAT allows many inside hosts to share one public address using ports.
  • Inside local and inside global describe the private and translated addresses.
  • NAT ACLs identify traffic for translation, not always security filtering.

TExam Day Tips

  • Identify inside and outside interfaces first.
  • Check whether the scenario needs static NAT, dynamic NAT or PAT.
  • Do not confuse NAT matching ACLs with normal packet-filtering intent.

Key takeaway

NAT direction and interface roles matter as much as the IP address mapping. Inside/outside designation controls which traffic is translated.

Real-world example

How this comes up in practice

A company's IT admin needs to give a contractor read-only access to production logs without sharing account credentials. Using role-based access control (RBAC) and temporary scoped permissions — not a permanent shared password — is the correct pattern. Questions like this test whether you can apply least-privilege access across cloud identity services.

What to study next

Got this wrong? Here's your next step.

Review the four NAT address types (inside local, inside global, outside local, outside global), PAT port overload, and static vs dynamic NAT use cases. Then practise related DVA-C02 NAT questions on configuration and troubleshooting.

Related practice questions

Related DVA-C02 practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free DVA-C02 practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this DVA-C02 question test?

Security — This question tests Security — Static NAT maps one inside address to one outside address..

What is the correct answer to this question?

The correct answer is: Create a VPC endpoint for API Gateway and attach a resource policy to the API that allows access only from the VPC endpoint. — Option D is correct because using a resource policy on API Gateway with aws:SourceVpce condition restricts access to requests originating from the VPC endpoint. Option A is wrong because private API Gateway endpoints are accessible from within a VPC without a resource policy. Option B is wrong because VPC Peering does not restrict access to API Gateway. Option C is wrong because security groups are for network interfaces, not API Gateway.

What should I do if I get this DVA-C02 question wrong?

Review the four NAT address types (inside local, inside global, outside local, outside global), PAT port overload, and static vs dynamic NAT use cases. Then practise related DVA-C02 NAT questions on configuration and troubleshooting.

What is the key concept behind this question?

Static NAT maps one inside address to one outside address.

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 ways 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. A developer is building a serverless application using API Gateway and Lambda. The API must be accessible only from a specific VPC. How can the developer achieve this?

medium
  • A.Use security groups to restrict access to the API Gateway.
  • B.Create the API Gateway inside the VPC.
  • C.Use CloudFront with an origin access identity to restrict access.
  • D.Create a VPC endpoint for API Gateway and attach a resource policy to the API that allows access only from the VPC endpoint.

Why D: Option B is correct because resource policies on API Gateway can restrict access to a VPC or VPC endpoint. Option A is incorrect because API Gateway is a regional service and cannot be placed inside a VPC. Option C is incorrect because security groups are for EC2, not API Gateway. Option D is incorrect because CloudFront does not restrict access to a specific VPC.

Keep practising

More DVA-C02 practice questions

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