Certopolis

AWS Certified Solutions Architect – Associate

VPC gateway endpoint vs interface endpoint for S3 and DynamoDB

A gateway endpoint is a route-table target for Amazon S3 and DynamoDB only. It has no additional charge and serves only traffic from inside the VPC. An interface endpoint (AWS PrivateLink) puts network interfaces with private IP addresses in your subnets, is billed per hour per Availability Zone and per GB, and can be reached from on premises and from other Regions.

How a gateway endpoint works

When you create a gateway endpoint you choose route tables. AWS adds a route to each one with the service's prefix list as the destination and the endpoint as the target. Instances in subnets that use those route tables reach the service through the endpoint. Subnets whose route tables are not associated keep using the public service endpoint, through a NAT gateway or internet gateway if they have one.

Routing uses the longest prefix match. If a route table sends 0.0.0.0/0 to an internet gateway, the endpoint route still wins for S3 or DynamoDB in the same Region. Traffic to the service in a different Region goes to the internet gateway, because prefix lists are specific to a Region.

Traffic through a gateway endpoint still goes to the service's public IP addresses. The instances' security groups must allow it, for example an outbound rule for TCP 443 with the service's prefix list as the destination. Network ACLs cannot reference prefix lists, so a network ACL rule needs the service's CIDR blocks.

How an interface endpoint works

An interface endpoint creates a network interface in one subnet per Availability Zone you choose. Each interface gets IP addresses from its subnet, and those addresses do not change for the life of the endpoint. Traffic for the service resolves through DNS to those private addresses.

With private DNS enabled, AWS creates a hidden private hosted zone so that the service's normal Regional name resolves to the endpoint. Existing SDK calls then use the endpoint without code changes. For production, AWS recommends at least two Availability Zones per endpoint.

Choosing for Amazon S3

S3 supports both types, and in both cases traffic stays on the AWS network. A gateway endpoint uses S3 public IP addresses and the normal S3 DNS names, is not billed, and cannot be used from on premises or from another Region. An interface endpoint uses private IP addresses from your VPC, needs endpoint-specific DNS names unless private DNS is on, is billed, and can be reached from on premises over Direct Connect or Site-to-Site VPN, and from a VPC in another Region over VPC peering or Transit Gateway.

You can run both in one VPC. In-VPC applications use the gateway endpoint, which is not billed, and on-premises applications use the interface endpoint. The S3 option "Enable private DNS only for inbound endpoints" depends on this setup and requires a gateway endpoint in the VPC.

Restricting a bucket to an endpoint

A bucket policy can deny every request where aws:sourceVpce is not your endpoint ID. This also blocks console access to the bucket, because console requests do not come from the endpoint. An endpoint policy works from the other side and limits which buckets or accounts can be reached through the endpoint.

Where the exam catches people

  • Believing a gateway endpoint serves on-premises clients over Direct Connect: gateway endpoints do not allow access from on premises, so use an interface endpoint.
  • Believing a gateway endpoint covers every subnet in the VPC: only subnets whose route tables are associated with it use it.
  • Believing a gateway endpoint reaches S3 in another Region: prefix lists are Region-specific, so that traffic goes to the internet gateway or fails.
  • Believing endpoint traffic skips security groups: the instances' security groups must allow outbound traffic to the service prefix list.
  • Believing every AWS service has a gateway endpoint: only Amazon S3 and DynamoDB do.

Written from Amazon Web Services's documentation

Try 3 questions on this

Pick an answer to see why each option is right or wrong.

  1. An application in a private subnet reads objects from an Amazon S3 bucket in the same Region, and a second workload on premises reads the same bucket across an AWS Direct Connect connection. A solutions architect must keep both paths off the public internet and wants one endpoint that serves both. Cost is a secondary concern. Which approach will meet these requirements?

    Right. In the game that’s Renown for your Design Secure Architectures building.

    Not that one: A is right. In the game your Design Secure Architectures building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    And "all instances in the subnets associated with a route table associated with a gateway endpoint automatically use the gateway endpoint." That is an in-VPC mechanism, and an on-premises host has no VPC route table. An interface endpoint is an elastic network interface with a private IP address in a subnet, which a network connected by AWS Direct Connect can route to, so it is the one endpoint that serves both halves. The cost note in the stem is the qualifier that makes the cheaper option tempting rather than correct.

    Written from docs.aws.amazon.com/vpc/latest/privatelink/gateway-endpoints.html

  2. A VPC has a gateway endpoint for Amazon S3 associated with the route table used by two of its six private subnets. An audit shows that instances in the other four subnets still reach S3 over the public service endpoint through a NAT gateway, and all six subnets must use the gateway endpoint. Which approach will meet these requirements?

    Right. In the game that’s Renown for your Design Secure Architectures building.

    Not that one: B is right. In the game your Design Secure Architectures building would lose a little Renown, and this question would come back later.

  3. A team creates a gateway endpoint for Amazon S3 and associates the right route table. The instances run under a security group whose outbound rules list only a database port and the corporate proxy. S3 calls from those instances now time out, and the security group must not be opened to all destinations. Which approach will meet these requirements?

    Right. In the game that’s Renown for your Design Secure Architectures building.

    Not that one: D is right. In the game your Design Secure Architectures building would lose a little Renown, and this question would come back later.