<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Toqeer Afzal</title>
    <description>The latest articles on DEV Community by Toqeer Afzal (@toqeer_afzal_d1e337ddf67f).</description>
    <link>https://dev.to/toqeer_afzal_d1e337ddf67f</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4124760%2F1aea28cb-efb8-4d13-b6b8-cf32974482de.png</url>
      <title>DEV Community: Toqeer Afzal</title>
      <link>https://dev.to/toqeer_afzal_d1e337ddf67f</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/toqeer_afzal_d1e337ddf67f"/>
    <language>en</language>
    <item>
      <title>NAT Gateway vs VPC Endpoints: Which Path Should Your Private AWS Traffic Take?</title>
      <dc:creator>Toqeer Afzal</dc:creator>
      <pubDate>Sat, 17 Oct 2026 16:23:17 +0000</pubDate>
      <link>https://dev.to/toqeer_afzal_d1e337ddf67f/nat-gateway-vs-vpc-endpoints-which-path-should-your-private-aws-traffic-take-5f3p</link>
      <guid>https://dev.to/toqeer_afzal_d1e337ddf67f/nat-gateway-vs-vpc-endpoints-which-path-should-your-private-aws-traffic-take-5f3p</guid>
      <description>&lt;p&gt;Private subnets are one of the first good habits you learn in AWS. Put your EC2 instances, containers and databases where the internet cannot start a connection to them, and you remove a large class of risk.&lt;/p&gt;

&lt;p&gt;The catch is that private workloads still need to talk to things: operating system repositories, third-party APIs, and AWS services such as Amazon S3. AWS gives you more than one way to make that happen, and they are &lt;strong&gt;not interchangeable&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This article walks through three tools:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;NAT Gateway&lt;/strong&gt; for outbound access from private subnets.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;S3 Gateway Endpoint&lt;/strong&gt; for free, route-table-based access to S3 from inside one VPC.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;S3 Interface Endpoint (AWS PrivateLink)&lt;/strong&gt; for private S3 access that can extend beyond the VPC, for example to on-premises networks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By the end you should be able to look at a requirement and pick the right one, and explain why.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note on sources.&lt;/strong&gt; Technical statements here are based on the official AWS documentation and blog posts listed in the References section. Prices change and differ by Region, so I describe the &lt;em&gt;cost model&lt;/em&gt; and point you to the AWS pricing pages instead of quoting numbers as universal facts. Console labels may change over time.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Understanding AWS VPC networking
&lt;/h2&gt;

&lt;p&gt;A quick vocabulary pass before the comparisons.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;VPC&lt;/strong&gt;: your isolated virtual network in AWS, defined by one or more CIDR ranges.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Public subnet&lt;/strong&gt;: a subnet whose route table has a route to an &lt;strong&gt;Internet Gateway (IGW)&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Private subnet&lt;/strong&gt;: a subnet with no direct route to an IGW. Its resources use private IP addresses only.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Route table&lt;/strong&gt;: the list of rules that decides where traffic leaves a subnet. The most specific matching route wins.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Internet Gateway&lt;/strong&gt;: the VPC component that connects public subnets to the internet. It handles the mapping between a public IPv4 address and a private one for resources that have a public address.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;NAT Gateway&lt;/strong&gt;: a managed service that lets resources in a private subnet start outbound connections without exposing them to unsolicited inbound traffic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ENI (Elastic Network Interface)&lt;/strong&gt;: a virtual network card with a private IP address. Interface endpoints are built from ENIs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  How does a private instance reach an AWS service?
&lt;/h3&gt;

&lt;p&gt;An EC2 instance in a private subnet that runs &lt;code&gt;aws s3 cp&lt;/code&gt; has three realistic options:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Go out through a &lt;strong&gt;NAT Gateway&lt;/strong&gt; to the service's public endpoint.&lt;/li&gt;
&lt;li&gt;Use an &lt;strong&gt;S3 Gateway Endpoint&lt;/strong&gt;, selected by a route in the subnet's route table.&lt;/li&gt;
&lt;li&gt;Use an &lt;strong&gt;S3 Interface Endpoint&lt;/strong&gt;, reached at a private IP address inside the VPC.
&lt;/li&gt;
&lt;/ol&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart LR
    EC2["Private EC2 instance"] --&amp;gt; RT{"Private route table"}
    RT --&amp;gt;|"0.0.0.0/0"| NAT["NAT Gateway (public subnet)"]
    NAT --&amp;gt; IGW["Internet Gateway"]
    IGW --&amp;gt; NET["Public internet / external service"]
    RT --&amp;gt;|"S3 prefix list"| GWE["S3 Gateway Endpoint"]
    GWE --&amp;gt; S3A["Amazon S3 (same Region)"]
    RT --&amp;gt;|"VPC CIDR (local)"| IFE["S3 Interface Endpoint (ENI + private IP)"]
    IFE --&amp;gt; S3B["Amazon S3 via PrivateLink"]&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;&lt;em&gt;Figure 1. Three exit paths from a private subnet. The route table, plus DNS for the interface endpoint, decides which one is used.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  What is an AWS NAT Gateway?
&lt;/h2&gt;

&lt;p&gt;A NAT Gateway performs &lt;strong&gt;network address translation&lt;/strong&gt; for resources in private subnets. Instances keep private IPv4 addresses. The NAT Gateway replaces the source address of outgoing packets and translates replies back.&lt;/p&gt;

&lt;h3&gt;
  
  
  Public vs private NAT Gateway
&lt;/h3&gt;

&lt;p&gt;According to the AWS documentation, a NAT Gateway has one of two connectivity types:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Public NAT Gateway (default)&lt;/th&gt;
&lt;th&gt;Private NAT Gateway&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Purpose&lt;/td&gt;
&lt;td&gt;Outbound internet access from private subnets&lt;/td&gt;
&lt;td&gt;Connectivity to other VPCs or on-premises networks&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Elastic IP&lt;/td&gt;
&lt;td&gt;Required, associated at creation&lt;/td&gt;
&lt;td&gt;Cannot be associated&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Internet Gateway&lt;/td&gt;
&lt;td&gt;Used for internet access&lt;/td&gt;
&lt;td&gt;If traffic is sent to an IGW, the IGW drops it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Placement&lt;/td&gt;
&lt;td&gt;In a public subnet&lt;/td&gt;
&lt;td&gt;In a subnet, routed via a transit gateway or virtual private gateway&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Inbound connections&lt;/td&gt;
&lt;td&gt;No unsolicited inbound connections from the internet&lt;/td&gt;
&lt;td&gt;No unsolicited inbound connections from the connected networks&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two points trip people up:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;public&lt;/strong&gt; NAT Gateway needs an Elastic IP &lt;strong&gt;and&lt;/strong&gt; a route toward an Internet Gateway for internet access.&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;private&lt;/strong&gt; NAT Gateway does &lt;strong&gt;not&lt;/strong&gt; give you internet access. It is for translating addresses toward other private networks, for example when CIDR ranges overlap.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Traffic flow
&lt;/h3&gt;



&lt;pre data-lang="mermaid"&gt;&lt;code&gt;sequenceDiagram
    participant I as Private EC2
    participant R as Private route table
    participant N as NAT Gateway (public subnet)
    participant G as Internet Gateway
    participant E as External service
    I-&amp;gt;&amp;gt;R: Packet to 203.0.113.10
    R-&amp;gt;&amp;gt;N: 0.0.0.0/0 targets the NAT Gateway
    N-&amp;gt;&amp;gt;G: Source translated to NAT address
    G-&amp;gt;&amp;gt;E: Source becomes the Elastic IP
    E--&amp;gt;&amp;gt;G: Response
    G--&amp;gt;&amp;gt;N: Translated back
    N--&amp;gt;&amp;gt;I: Delivered to the original instance&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;&lt;em&gt;Figure 2. Outbound flow through a public NAT Gateway. The external address 203.0.113.10 is a documentation example.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The setup requires:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A NAT Gateway in a &lt;strong&gt;public subnet&lt;/strong&gt;, with an Elastic IP.&lt;/li&gt;
&lt;li&gt;The public subnet's route table has &lt;code&gt;0.0.0.0/0&lt;/code&gt; pointing to the &lt;strong&gt;IGW&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;The private subnet's route table has &lt;code&gt;0.0.0.0/0&lt;/code&gt; pointing to the &lt;strong&gt;NAT Gateway&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Availability and design
&lt;/h3&gt;

&lt;p&gt;Classic (zonal) NAT Gateways live in &lt;strong&gt;one Availability Zone&lt;/strong&gt;. For resilience, a common design is one NAT Gateway per AZ, with each private route table pointing to the NAT Gateway in its own AZ. This also avoids sending traffic across AZs just to reach NAT, which can add data transfer cost.&lt;/p&gt;

&lt;p&gt;AWS also documents &lt;strong&gt;regional NAT Gateways&lt;/strong&gt;, which expand across the AZs where you have workloads and simplify routing. They do not support private connectivity, so private NAT still uses zonal gateways. Check the documentation for current Region availability and limits before choosing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where NAT is the right tool
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Downloading OS updates and packages from public repositories.&lt;/li&gt;
&lt;li&gt;Calling third-party SaaS APIs.&lt;/li&gt;
&lt;li&gt;Any destination on the public internet that has no private path.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Limits to keep in mind
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It is billed by time and by data processed (see the cost section), so heavy traffic to AWS services through NAT can become expensive.&lt;/li&gt;
&lt;li&gt;It is outbound-only. It is not a way to publish services.&lt;/li&gt;
&lt;li&gt;Traffic to S3 through NAT leaves your VPC through the internet path, even though S3 is an AWS service. That is often not what security teams want.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What is a VPC endpoint?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;VPC endpoint&lt;/strong&gt; lets resources in your VPC connect privately to supported AWS services (and to services powered by PrivateLink) without needing an internet gateway, NAT device, or VPN for that traffic.&lt;/p&gt;

&lt;p&gt;There are two types relevant here:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Gateway endpoint.&lt;/strong&gt; A target in your route table. Available only for Amazon S3 and Amazon DynamoDB.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Interface endpoint (AWS PrivateLink).&lt;/strong&gt; One or more ENIs with private IPs in your subnets, protected by security groups. Available for many AWS services and for partner or your own PrivateLink services.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Both support &lt;strong&gt;endpoint policies&lt;/strong&gt;, which control which principals can do which actions on which resources through the endpoint. The default policy is full access, so tightening it is worth doing.&lt;/p&gt;




&lt;h2&gt;
  
  
  S3 Gateway Endpoint vs S3 Interface Endpoint
&lt;/h2&gt;

&lt;p&gt;This is the part that causes most confusion, because both are "an endpoint for S3" and both keep traffic on the AWS network.&lt;/p&gt;

&lt;h3&gt;
  
  
  S3 Gateway Endpoint
&lt;/h3&gt;

&lt;p&gt;How it works:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You create the endpoint in a VPC and associate it with route tables.&lt;/li&gt;
&lt;li&gt;AWS adds a route that sends S3-bound traffic to the endpoint, using the &lt;strong&gt;S3 managed prefix list&lt;/strong&gt;. In the route table you will see the prefix list ID as the destination and the endpoint ID (&lt;code&gt;vpce-...&lt;/code&gt;) as the target.&lt;/li&gt;
&lt;li&gt;There is &lt;strong&gt;no ENI&lt;/strong&gt; and &lt;strong&gt;no endpoint security group&lt;/strong&gt;. In security groups you can reference the prefix list ID. Network ACLs cannot reference prefix lists, so use the IP ranges instead.&lt;/li&gt;
&lt;li&gt;The AWS documentation states there is no additional charge for gateway endpoints.&lt;/li&gt;
&lt;li&gt;The endpoint must be in the &lt;strong&gt;same Region&lt;/strong&gt; as the S3 buckets.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Limits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The documentation says gateway endpoints do not allow access from on-premises networks.&lt;/li&gt;
&lt;li&gt;They also do not allow access from peered VPCs in other Regions or through a transit gateway. The endpoint connection cannot be extended out of the VPC, so resources across VPN, VPC peering, Transit Gateway or Direct Connect cannot use it.&lt;/li&gt;
&lt;li&gt;For Amazon-provided DNS, both &lt;strong&gt;DNS hostnames&lt;/strong&gt; and &lt;strong&gt;DNS resolution&lt;/strong&gt; must be enabled on the VPC.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;aws:SourceIp&lt;/code&gt; cannot be used in policies for requests that traverse a VPC endpoint. Use &lt;code&gt;aws:VpcSourceIp&lt;/code&gt; or the VPC/endpoint conditions instead.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  S3 Interface Endpoint
&lt;/h3&gt;

&lt;p&gt;How it works:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PrivateLink creates &lt;strong&gt;endpoint ENIs&lt;/strong&gt; with private IPs in the subnets you choose (typically one per AZ).&lt;/li&gt;
&lt;li&gt;Security groups on those ENIs control who can connect, typically TCP 443.&lt;/li&gt;
&lt;li&gt;Each endpoint gets &lt;strong&gt;regional and zonal DNS names&lt;/strong&gt; that resolve to the endpoint's private IPs. For S3 you reach buckets with a bucket-prefixed name such as &lt;code&gt;bucket.vpce-&amp;lt;id&amp;gt;-&amp;lt;suffix&amp;gt;.s3.&amp;lt;region&amp;gt;.vpce.amazonaws.com&lt;/code&gt;. You can point the AWS CLI at it with &lt;code&gt;--endpoint-url&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Because the endpoint is just private IPs in your network, &lt;strong&gt;on-premises systems connected over Direct Connect (private VIF) or Site-to-Site VPN&lt;/strong&gt; can reach it, as AWS describes in its hybrid access guidance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Other VPCs&lt;/strong&gt; can reach the endpoint IPs over routed connectivity such as Transit Gateway or peering, provided routing, DNS and security groups allow it.&lt;/li&gt;
&lt;li&gt;Cost model: hourly charge per endpoint per AZ, plus a per-GB data processing charge.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The DNS wrinkle (worth reading twice)
&lt;/h3&gt;

&lt;p&gt;The S3 interface endpoint supports a &lt;strong&gt;Private DNS&lt;/strong&gt; option with a special mode: &lt;strong&gt;private DNS only for the inbound Resolver endpoint&lt;/strong&gt;. According to AWS:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;With this mode, &lt;strong&gt;on-premises DNS queries&lt;/strong&gt; (forwarded to a Route 53 Resolver inbound endpoint) resolve S3 names to the interface endpoint's private IPs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Queries from inside the VPC&lt;/strong&gt; resolve to S3's public IPs, and those requests use the &lt;strong&gt;gateway endpoint&lt;/strong&gt; (no extra charge).&lt;/li&gt;
&lt;li&gt;This mode requires an &lt;strong&gt;S3 gateway endpoint in the same VPC&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;If you enable private DNS for all traffic instead, VPC traffic also goes through the interface endpoint and you pay interface endpoint data processing for it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is the cost-friendly hybrid pattern: gateway endpoint for workloads in the VPC, interface endpoint for on-premises and other networks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Comparison table
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;S3 Gateway Endpoint&lt;/th&gt;
&lt;th&gt;S3 Interface Endpoint&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Connectivity model&lt;/td&gt;
&lt;td&gt;Route table target using S3 prefix list&lt;/td&gt;
&lt;td&gt;ENI with private IPs (PrivateLink)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Route table requirement&lt;/td&gt;
&lt;td&gt;Yes, route per associated route table&lt;/td&gt;
&lt;td&gt;No special S3 route; normal VPC routing to the ENI IPs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ENI / private IP&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;Yes, per subnet/AZ&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Security groups&lt;/td&gt;
&lt;td&gt;No (use prefix list in your own SGs; policy controls on the endpoint)&lt;/td&gt;
&lt;td&gt;Yes, on the endpoint ENIs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;On-premises access&lt;/td&gt;
&lt;td&gt;Not supported&lt;/td&gt;
&lt;td&gt;Supported over Direct Connect or VPN, with DNS set up&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cross-VPC / Transit Gateway&lt;/td&gt;
&lt;td&gt;Not supported&lt;/td&gt;
&lt;td&gt;Possible with correct routing, DNS and security&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DNS&lt;/td&gt;
&lt;td&gt;Standard S3 names; VPC DNS settings required&lt;/td&gt;
&lt;td&gt;Endpoint-specific names; optional private DNS (inbound-only mode needs a gateway endpoint)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost model&lt;/td&gt;
&lt;td&gt;No additional endpoint charge&lt;/td&gt;
&lt;td&gt;Hourly per AZ plus per-GB processing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Typical use&lt;/td&gt;
&lt;td&gt;Workloads inside one VPC&lt;/td&gt;
&lt;td&gt;Hybrid access, shared-services VPCs, strict private access designs&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;They are not interchangeable.&lt;/strong&gt; If an on-premises server needs private S3 access, a gateway endpoint will not do it. If a workload inside the VPC only needs cheap private S3 access, an interface endpoint is usually unnecessary spend.&lt;/p&gt;




&lt;h2&gt;
  
  
  Understanding the architecture image
&lt;/h2&gt;

&lt;p&gt;![Architecture diagram comparing an S3 Gateway Endpoint, which routes traffic from a private subnet through a route table prefix list and cannot be reached from on-premises or peered VPCs, with an S3 Interface Endpoint, which uses an ENI and security group reachable from on-premises servers and spoke VPCs via Transit Gateway.]&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 3. Gateway vs Interface endpoint for S3. Place this image right after this heading.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The image uses four numbered callouts. Here is each one, with a few checks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Route injected (Gateway).&lt;/strong&gt; The route table gets an entry whose destination is the S3 prefix list and whose target is the gateway endpoint. Traffic to S3 follows that route; everything else follows the other routes. This matches the AWS documentation. One refinement: the route is added when you associate the route table with the endpoint, and removed when you disassociate it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Gateway = $0.&lt;/strong&gt; The AWS documentation says there is no additional charge for gateway endpoints. Note that this refers to the endpoint itself. Normal S3 request and storage charges still apply, and other data transfer charges can apply in specific cases such as cross-Region access.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Interface = ENI + SG.&lt;/strong&gt; The interface endpoint is an ENI with a private IP, protected by a security group that you configure (for example, allow HTTPS 443 from your sources). The image abbreviates the hostname as &lt;code&gt;bucket.vpce-....s3.amazonaws.com&lt;/code&gt;. The real endpoint-specific name follows the pattern &lt;code&gt;bucket.vpce-&amp;lt;id&amp;gt;-&amp;lt;suffix&amp;gt;.s3.&amp;lt;region&amp;gt;.vpce.amazonaws.com&lt;/code&gt;, so copy it from your endpoint's details rather than from the picture.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Transitive routing.&lt;/strong&gt; The image shows on-premises servers (Direct Connect or VPN) and spoke VPCs (via Transit Gateway) reaching the interface endpoint. That is achievable, but "transitive" is shorthand. It works because the endpoint is a private IP in your network, so anything with a &lt;strong&gt;route to that IP&lt;/strong&gt;, &lt;strong&gt;DNS that resolves to it&lt;/strong&gt;, and &lt;strong&gt;security group permission&lt;/strong&gt; can connect. An interface endpoint does not make every connected network able to reach S3 automatically.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The red "no route in" warning.&lt;/strong&gt; This shows that on-premises and peered networks cannot use the gateway endpoint. The AWS documentation confirms the limitation, and the underlying reason is that gateway endpoints cannot be extended out of the VPC. It is less about a missing route and more about how the feature works.&lt;/p&gt;

&lt;p&gt;Two more assumptions to be aware of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The image says "reachable from any routed network". In practice you also need DNS and security groups to line up, and the AWS hybrid guidance describes specific DNS steps for on-premises.&lt;/li&gt;
&lt;li&gt;The image shows a single S3 bucket. Remember the endpoint must be in the &lt;strong&gt;same Region&lt;/strong&gt; as the bucket for the gateway type.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  NAT Gateway vs VPC endpoint
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;NAT Gateway&lt;/th&gt;
&lt;th&gt;VPC Endpoint&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Main purpose&lt;/td&gt;
&lt;td&gt;Outbound connectivity with address translation&lt;/td&gt;
&lt;td&gt;Private connectivity to supported AWS and PrivateLink services&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Traffic destination&lt;/td&gt;
&lt;td&gt;Public internet (public NAT) or other private networks (private NAT)&lt;/td&gt;
&lt;td&gt;A specific AWS service or PrivateLink service&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Internet dependency&lt;/td&gt;
&lt;td&gt;Public NAT needs an IGW and Elastic IP&lt;/td&gt;
&lt;td&gt;None for the endpoint path itself&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Security&lt;/td&gt;
&lt;td&gt;Blocks unsolicited inbound; outbound is broad unless filtered&lt;/td&gt;
&lt;td&gt;Endpoint policies, security groups (interface), bucket and IAM conditions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Routing&lt;/td&gt;
&lt;td&gt;Default route (&lt;code&gt;0.0.0.0/0&lt;/code&gt;) to the NAT Gateway&lt;/td&gt;
&lt;td&gt;Gateway: prefix list route. Interface: private IPs and DNS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cost model&lt;/td&gt;
&lt;td&gt;Hourly plus per-GB processed (check AWS pricing)&lt;/td&gt;
&lt;td&gt;Gateway: no additional charge. Interface: hourly per AZ plus per GB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Common use&lt;/td&gt;
&lt;td&gt;OS updates, third-party APIs&lt;/td&gt;
&lt;td&gt;S3, DynamoDB and other AWS services without internet egress&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;They solve different problems, and you will often use them &lt;strong&gt;together&lt;/strong&gt;: NAT for the internet, endpoints for AWS services.&lt;/p&gt;




&lt;h2&gt;
  
  
  A real-world production architecture
&lt;/h2&gt;

&lt;p&gt;Requirements for an example company:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Private EC2 instances download OS updates and call external repositories.&lt;/li&gt;
&lt;li&gt;Logs and backups go to Amazon S3, kept on a private AWS path.&lt;/li&gt;
&lt;li&gt;Selected on-premises systems also need private S3 access.&lt;/li&gt;
&lt;li&gt;NAT data-processing costs should stay low.
&lt;/li&gt;
&lt;/ul&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TB
    subgraph ONPREM["On-premises"]
        SRV["Backup servers"]
        DNS["On-prem DNS (conditional forwarder)"]
    end

    subgraph VPC["Application VPC (2 AZs)"]
        subgraph PUB["Public subnets"]
            NATA["NAT Gateway AZ-a"]
            NATB["NAT Gateway AZ-b"]
        end
        subgraph PRIV["Private subnets"]
            EC2A["EC2 AZ-a"]
            EC2B["EC2 AZ-b"]
        end
        subgraph ENDPOINTS["Endpoints"]
            GWE["S3 Gateway Endpoint"]
            IFE["S3 Interface Endpoint (ENIs, SG: 443 from on-prem)"]
            RES["Route 53 Resolver inbound endpoint"]
        end
        IGW["Internet Gateway"]
    end

    S3[("Amazon S3 buckets")]
    NET["Public repositories / external APIs"]

    EC2A --&amp;gt;|"S3 prefix list"| GWE
    EC2B --&amp;gt;|"S3 prefix list"| GWE
    GWE --&amp;gt; S3
    EC2A --&amp;gt;|"0.0.0.0/0"| NATA
    EC2B --&amp;gt;|"0.0.0.0/0"| NATB
    NATA --&amp;gt; IGW
    NATB --&amp;gt; IGW
    IGW --&amp;gt; NET
    SRV --&amp;gt;|"Direct Connect or VPN"| IFE
    DNS -.-&amp;gt;|"S3 domain forwarded"| RES
    IFE --&amp;gt; S3&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;&lt;em&gt;Figure 4. Gateway endpoint for in-VPC S3 traffic, NAT for the internet, and an interface endpoint for on-premises S3 access.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Which traffic uses what
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Traffic&lt;/th&gt;
&lt;th&gt;Path&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;OS updates, external repositories&lt;/td&gt;
&lt;td&gt;NAT Gateway&lt;/td&gt;
&lt;td&gt;Public internet destinations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;EC2 to S3 (logs, backups)&lt;/td&gt;
&lt;td&gt;S3 Gateway Endpoint&lt;/td&gt;
&lt;td&gt;No additional endpoint charge, stays on the AWS network&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;On-premises to S3&lt;/td&gt;
&lt;td&gt;S3 Interface Endpoint&lt;/td&gt;
&lt;td&gt;Gateway endpoints are not reachable from on-premises&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Design points
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Multi-AZ.&lt;/strong&gt; One NAT Gateway per AZ with matching route tables, and interface endpoint ENIs in each AZ you use. Alternatively evaluate a regional NAT Gateway.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Routing.&lt;/strong&gt; The gateway endpoint's S3 prefix-list route covers S3 public IP ranges, which are more specific than the default route, so S3 traffic is steered to the endpoint instead of NAT.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DNS.&lt;/strong&gt; Use the &lt;strong&gt;inbound-resolver-only&lt;/strong&gt; private DNS option on the interface endpoint, with a gateway endpoint in the VPC. Forward the S3 domain from on-premises DNS to the Route 53 Resolver inbound endpoint.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security groups.&lt;/strong&gt; On the interface endpoint, allow TCP 443 only from the on-premises ranges (and other networks you intend to allow).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IAM.&lt;/strong&gt; Instances use instance profiles (roles), never long-lived keys. Grant only the S3 actions and prefixes they need.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bucket policy.&lt;/strong&gt; Restrict the bucket to your endpoints with &lt;code&gt;aws:sourceVpce&lt;/code&gt; or &lt;code&gt;aws:sourceVpc&lt;/code&gt;. Be careful: AWS notes that a policy limiting access to a specific endpoint also blocks console access.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Endpoint policy.&lt;/strong&gt; Limit the endpoint to the buckets you own, for example with &lt;code&gt;s3:ResourceAccount&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When is the S3 interface endpoint justified? When something &lt;strong&gt;outside the VPC&lt;/strong&gt; needs private S3 access: on-premises systems, or other VPCs and Regions over private links. If everything is inside one VPC, the gateway endpoint is usually enough.&lt;/p&gt;




&lt;h2&gt;
  
  
  Practical implementation
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Console labels and options change over time, so treat the names below as a guide.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  S3 Gateway Endpoint (console)
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Open the &lt;strong&gt;VPC console&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Go to &lt;strong&gt;Endpoints&lt;/strong&gt; and choose &lt;strong&gt;Create endpoint&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Choose the &lt;strong&gt;AWS services&lt;/strong&gt; category and search for &lt;code&gt;com.amazonaws.&amp;lt;region&amp;gt;.s3&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Select the service entry whose type is &lt;strong&gt;Gateway&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select the correct &lt;strong&gt;VPC&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select the &lt;strong&gt;private route tables&lt;/strong&gt; used by your private subnets.&lt;/li&gt;
&lt;li&gt;Set an &lt;strong&gt;endpoint policy&lt;/strong&gt;. Replace the default full-access policy with one limited to your buckets.&lt;/li&gt;
&lt;li&gt;Create the endpoint, then confirm the route table now shows an S3 prefix list route targeting the &lt;code&gt;vpce-&lt;/code&gt; ID.&lt;/li&gt;
&lt;li&gt;From a private instance, run &lt;code&gt;aws s3 ls s3://&amp;lt;your-bucket&amp;gt; --region &amp;lt;region&amp;gt;&lt;/code&gt; using an instance role. Check the result using the route table, VPC Flow Logs and, if needed, CloudTrail.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  S3 Gateway Endpoint (AWS CLI)
&lt;/h3&gt;

&lt;p&gt;Replace everything in angle brackets with your own values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws ec2 create-vpc-endpoint &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--vpc-id&lt;/span&gt; &amp;lt;vpc-id&amp;gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--vpc-endpoint-type&lt;/span&gt; Gateway &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--service-name&lt;/span&gt; com.amazonaws.&amp;lt;region&amp;gt;.s3 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--route-table-ids&lt;/span&gt; &amp;lt;rtb-id-1&amp;gt; &amp;lt;rtb-id-2&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  S3 Interface Endpoint (console)
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;In &lt;strong&gt;Endpoints&lt;/strong&gt;, choose &lt;strong&gt;Create endpoint&lt;/strong&gt; and search for the S3 service for your Region.&lt;/li&gt;
&lt;li&gt;Choose the &lt;strong&gt;Interface&lt;/strong&gt; type entry (S3 lists both types).&lt;/li&gt;
&lt;li&gt;Select the VPC and &lt;strong&gt;subnets in each AZ&lt;/strong&gt; you need.&lt;/li&gt;
&lt;li&gt;Attach a &lt;strong&gt;security group&lt;/strong&gt; allowing inbound TCP 443 from the networks that should connect.&lt;/li&gt;
&lt;li&gt;Configure DNS to match your design: either endpoint-specific names only, or private DNS. For the hybrid pattern, choose the &lt;strong&gt;inbound-resolver-only&lt;/strong&gt; option, which needs the gateway endpoint in the same VPC.&lt;/li&gt;
&lt;li&gt;Build the DNS path for on-premises: a Route 53 Resolver inbound endpoint in the VPC, and a conditional forwarder on your on-premises DNS.&lt;/li&gt;
&lt;li&gt;Confirm routing from on-premises (Direct Connect or VPN) to the endpoint subnets.&lt;/li&gt;
&lt;li&gt;Test and review logs.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  S3 Interface Endpoint (AWS CLI sketch)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws ec2 create-vpc-endpoint &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--vpc-id&lt;/span&gt; &amp;lt;vpc-id&amp;gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--vpc-endpoint-type&lt;/span&gt; Interface &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--service-name&lt;/span&gt; com.amazonaws.&amp;lt;region&amp;gt;.s3 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--subnet-ids&lt;/span&gt; &amp;lt;subnet-id-a&amp;gt; &amp;lt;subnet-id-b&amp;gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--security-group-ids&lt;/span&gt; &amp;lt;sg-id&amp;gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--private-dns-enabled&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--dns-options&lt;/span&gt; &lt;span class="nv"&gt;PrivateDnsOnlyForInboundResolverEndpoint&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the current &lt;code&gt;create-vpc-endpoint&lt;/code&gt; reference for the exact option names before using this in a real account.&lt;/p&gt;

&lt;p&gt;To test through the endpoint-specific DNS name from a machine with network access to the endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;aws s3 &lt;span class="nb"&gt;ls &lt;/span&gt;s3://&amp;lt;your-bucket&amp;gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--region&lt;/span&gt; &amp;lt;region&amp;gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--endpoint-url&lt;/span&gt; https://bucket.&amp;lt;vpce-dns-name-from-the-console&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy &lt;code&gt;&amp;lt;vpce-dns-name-from-the-console&amp;gt;&lt;/code&gt; from the endpoint's &lt;strong&gt;Details&lt;/strong&gt; page. Do not paste credentials into commands or scripts. Use roles or your normal credential provider.&lt;/p&gt;

&lt;p&gt;Example bucket policy that denies access outside a specific gateway endpoint (adapt carefully, and test with a non-critical bucket first because it can lock you out of the console):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"Version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2012-10-17"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"Statement"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"Sid"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"DenyUnlessFromMyEndpoint"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"Effect"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Deny"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"Principal"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"Action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"s3:*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"Resource"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"arn:aws:s3:::&amp;lt;your-bucket&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"arn:aws:s3:::&amp;lt;your-bucket&amp;gt;/*"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"Condition"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"StringNotEquals"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="nl"&gt;"aws:sourceVpce"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;vpce-id&amp;gt;"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Security best practices
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use IAM roles&lt;/strong&gt;, not hard-coded access keys. Instance profiles and task roles avoid secrets in code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Least privilege.&lt;/strong&gt; Scope IAM policies, endpoint policies and bucket policies to the buckets and actions required.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Layer your controls.&lt;/strong&gt; IAM says who, the endpoint policy says what can pass through this door, the bucket policy says who may enter the bucket.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use HTTPS/TLS.&lt;/strong&gt; Enforce it with a bucket policy condition on &lt;code&gt;aws:SecureTransport&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lock down interface endpoint security groups.&lt;/strong&gt; Allow 443 only from known sources.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Log and review.&lt;/strong&gt; VPC Flow Logs show network flows. CloudTrail records API activity.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Avoid unintended public access.&lt;/strong&gt; Keep S3 Block Public Access on unless you have a reviewed reason.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Review cross-account and cross-network access&lt;/strong&gt; carefully, especially when many VPCs and on-premises ranges can reach one shared interface endpoint.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Cost optimization
&lt;/h2&gt;

&lt;p&gt;Cost is the main reason many teams adopt endpoints, so here is the model.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;NAT Gateway.&lt;/strong&gt; Billed for each hour it is available and for each GB of data it processes. Check the VPC pricing page for your Region. Heavy S3 traffic sent through NAT pays the processing charge on every GB.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;S3 Gateway Endpoint.&lt;/strong&gt; AWS documents no additional charge for the endpoint. Moving large S3 traffic off NAT onto a gateway endpoint can remove that NAT processing cost for that traffic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;S3 Interface Endpoint.&lt;/strong&gt; Billed per hour for each endpoint in each AZ, plus per-GB data processing. The AWS PrivateLink pricing page shows example rates for US East (N. Virginia) of $0.01 per hour per endpoint ENI and $0.01 per GB for the first tier. Rates are Region-specific, so verify them for your own Region.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Placement matters.&lt;/strong&gt; If you enable private DNS for all traffic on the interface endpoint, in-VPC traffic goes through it and incurs its data charges. The inbound-resolver-only mode lets VPC traffic use the free gateway endpoint instead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Other charges still apply.&lt;/strong&gt; S3 requests, storage, and some data transfer scenarios (such as cross-Region or cross-AZ traffic) are billed separately.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I have not run cost benchmarks for this article, so I am not claiming any specific saving. Estimate with the AWS Pricing Calculator using your own traffic.&lt;/p&gt;




&lt;h2&gt;
  
  
  Common mistakes and troubleshooting
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Problem&lt;/th&gt;
&lt;th&gt;What to check&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Route table not associated&lt;/td&gt;
&lt;td&gt;In the endpoint details, confirm the private route tables are listed. Check the subnet's actual route table.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No S3 prefix-list route&lt;/td&gt;
&lt;td&gt;In the route table, look for a route with an S3 prefix list destination and a &lt;code&gt;vpce-&lt;/code&gt; target.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;IAM or bucket policy denies&lt;/td&gt;
&lt;td&gt;Check the instance role, bucket policy and endpoint policy. Read the exact &lt;code&gt;AccessDenied&lt;/code&gt; message and CloudTrail event.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Security group blocks HTTPS&lt;/td&gt;
&lt;td&gt;For interface endpoints, allow 443 inbound from the client. Check the client's outbound rules and NACLs.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wrong DNS&lt;/td&gt;
&lt;td&gt;Run &lt;code&gt;nslookup&lt;/code&gt; or &lt;code&gt;dig&lt;/code&gt; for the S3 name from the failing host. Private IP means the interface endpoint, public IP means the gateway path or internet. Verify VPC DNS hostnames and resolution, and any on-premises forwarders.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Expecting the gateway endpoint to work from peered VPCs or via Transit Gateway&lt;/td&gt;
&lt;td&gt;It does not extend out of its VPC. Create an endpoint in that VPC, or use an interface endpoint.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Expecting the interface endpoint to open S3 to every connected network&lt;/td&gt;
&lt;td&gt;You still need routing to the ENI IPs, DNS that returns them, and security group access.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Subnet or AZ coverage gaps&lt;/td&gt;
&lt;td&gt;Confirm the interface endpoint has a subnet in each AZ that needs it, and that the NAT and route tables match your AZ layout.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bucket in a different Region&lt;/td&gt;
&lt;td&gt;A gateway endpoint serves buckets in its own Region. Traffic to other Regions will take another path, such as NAT, and can cost more.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wrong credentials or a restrictive bucket policy during tests&lt;/td&gt;
&lt;td&gt;Confirm which identity the CLI uses with &lt;code&gt;aws sts get-caller-identity&lt;/code&gt;. Remember that a &lt;code&gt;aws:sourceVpce&lt;/code&gt; deny also blocks the console.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A good habit is to test in order: &lt;strong&gt;DNS, then route, then security group, then policies&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;NAT Gateway:&lt;/strong&gt; use it for outbound access to the public internet, or for private NAT toward other private networks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;S3 Gateway Endpoint:&lt;/strong&gt; use it as the default for workloads inside one VPC that need S3. No additional endpoint charge, but it does not leave the VPC.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;S3 Interface Endpoint:&lt;/strong&gt; use it when on-premises systems or other networks need private S3 access, and prefer the inbound-resolver-only DNS option so the VPC itself keeps using the gateway endpoint.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Decision rule: gateway inside, interface outside, NAT for the open internet.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What does your S3 and NAT setup look like today? Have you found NAT charges you did not expect, or run a hybrid design with interface endpoints? Share it in the comments, I would love to compare patterns.&lt;/p&gt;




&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/vpc/latest/privatelink/vpc-endpoints-s3.html" rel="noopener noreferrer"&gt;Gateway endpoints for Amazon S3 (Amazon VPC)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html" rel="noopener noreferrer"&gt;NAT gateways (Amazon VPC User Guide)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/vpc/latest/userguide/nat-gateways-regional.html" rel="noopener noreferrer"&gt;Regional NAT gateways (Amazon VPC User Guide)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/privatelink-interface-endpoints.html" rel="noopener noreferrer"&gt;AWS PrivateLink for Amazon S3 (S3 User Guide)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/blogs/networking-and-content-delivery/secure-hybrid-access-to-amazon-s3-using-aws-privatelink/" rel="noopener noreferrer"&gt;Secure hybrid access to Amazon S3 using AWS PrivateLink (AWS Networking blog)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/blogs/storage/introducing-private-dns-support-for-amazon-s3-with-aws-privatelink/" rel="noopener noreferrer"&gt;Introducing private DNS support for Amazon S3 with AWS PrivateLink (AWS Storage blog)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/privatelink/pricing/" rel="noopener noreferrer"&gt;AWS PrivateLink pricing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/vpc/pricing/" rel="noopener noreferrer"&gt;Amazon VPC pricing (NAT Gateway)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>devops</category>
      <category>networking</category>
    </item>
    <item>
      <title>AWS VPC Peering vs Transit Gateway: A Practical Guide to Scalable Cloud Networking</title>
      <dc:creator>Toqeer Afzal</dc:creator>
      <pubDate>Wed, 07 Oct 2026 17:47:15 +0000</pubDate>
      <link>https://dev.to/toqeer_afzal_d1e337ddf67f/aws-vpc-peering-vs-transit-gateway-a-practical-guide-to-scalable-cloud-networking-11m6</link>
      <guid>https://dev.to/toqeer_afzal_d1e337ddf67f/aws-vpc-peering-vs-transit-gateway-a-practical-guide-to-scalable-cloud-networking-11m6</guid>
      <description>&lt;h2&gt;
  
  
  AWS VPC Peering vs Transit Gateway: A Practical Guide to Scalable Cloud Networking
&lt;/h2&gt;

&lt;p&gt;*&lt;em&gt;Modern cloud environments rarely stay simple.&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
A startup may begin with a single Amazon VPC and a few EC2 instances. As the organization grows, separate environments are introduced for production, development, testing, security, monitoring, analytics, and shared services.&lt;/p&gt;

&lt;p&gt;Soon, an important question appears:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How should these networks communicate securely, privately, and at scale?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Two important AWS networking solutions commonly used to solve this problem are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Amazon VPC Peering&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;AWS Transit Gateway&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both can connect VPCs using private networking, but they are designed for different architectural requirements.&lt;/p&gt;

&lt;p&gt;In this article, we will compare VPC Peering and Transit Gateway from a practical cloud-engineering perspective, including routing, scalability, network design, real-world use cases, cost considerations, and hands-on AWS scenarios.&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;## The Short Answer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before going deeper, remember this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;VPC Peering connects two VPCs directly.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Transit Gateway provides a centralized hub for connecting multiple VPCs and networks.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A simple VPC Peering architecture looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌───────────────┐   **    VPC Peering  **     ┌───────────────┐
│    VPC-A      │────────────────────────│    VPC-B      │
│ 10.0.0.0/16   │                        │ 10.1.0.0/16   │
└───────────────┘                        └───────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A Transit Gateway architecture looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                    ┌───────────────┐
                    │    Transit    │
                    │    Gateway    │
                    └───────┬───────┘
                            │
             ┌──────────────┼──────────────┐
             │              │              │
             ▼              ▼              ▼
          VPC-A           VPC-B           VPC-C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The difference may look simple, but it becomes extremely important as your cloud environment grows.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. What Is Amazon VPC Peering?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Amazon VPC Peering&lt;/strong&gt; is a networking connection between two VPCs that allows resources in those VPCs to communicate using private IP addresses.&lt;/p&gt;

&lt;p&gt;The VPCs can be in the same AWS Region or, where supported, across AWS Regions.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application VPC
10.0.0.0/16
      │
      │
      │ VPC Peering
      │
      ▼
Database VPC
10.1.0.0/16
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An EC2 instance in the application VPC can communicate with a database or service in the second VPC using private addressing, assuming routing and security controls allow the traffic.&lt;/p&gt;

&lt;p&gt;VPC Peering is particularly useful when you have a relatively small number of VPCs and a clear requirement for direct connectivity.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. How VPC Peering Works
&lt;/h2&gt;

&lt;p&gt;Creating a peering connection does not automatically make all traffic work.&lt;/p&gt;

&lt;p&gt;Three major areas need to be considered:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;VPC Peering connection&lt;/li&gt;
&lt;li&gt;Route tables&lt;/li&gt;
&lt;li&gt;Security controls&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Suppose we have:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VPC-A
CIDR: 10.0.0.0/16

VPC-B
CIDR: 10.1.0.0/16
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The route table associated with the relevant subnet in VPC-A could contain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Destination       Target
10.1.0.0/16       pcx-xxxxxxxx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;VPC-B needs the return route:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Destination       Target
10.0.0.0/16       pcx-xxxxxxxx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The security groups and network ACLs must also permit the required traffic.&lt;/p&gt;

&lt;p&gt;This leads to an important AWS networking principle:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Connectivity is not the same thing as reachability.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A connection can exist while traffic still fails because of missing routes or security rules.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. A Practical VPC Peering Scenario
&lt;/h2&gt;

&lt;p&gt;Imagine a SaaS company has separated its application and data workloads.&lt;/p&gt;

&lt;h3&gt;
  
  
  Application VPC
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CIDR: 10.10.0.0/16
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Database VPC
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CIDR: 10.20.0.0/16
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The application needs private access to a database service.&lt;/p&gt;

&lt;p&gt;The architecture could be:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──────────────────────┐
│   Application VPC    │
│    10.10.0.0/16     │
│                      │
│      EC2 / App       │
└──────────┬───────────┘
           │
           │ VPC Peering
           │
┌──────────▼───────────┐
│     Database VPC     │
│    10.20.0.0/16      │
│                      │
│    Database Tier     │
└──────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The application subnet needs a route toward the database CIDR.&lt;/p&gt;

&lt;p&gt;The database side needs a return route.&lt;/p&gt;

&lt;p&gt;The database security group should allow only the required application traffic.&lt;/p&gt;

&lt;p&gt;For example, if the application requires HTTPS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Source: 10.10.0.0/16
Protocol: TCP
Port: 443
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In a production environment, avoid opening unnecessary ports or using broader access rules when more restrictive rules are possible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. The Most Important VPC Peering Limitation&lt;/strong&gt;: No Transitive Routing&lt;/p&gt;

&lt;p&gt;This is one of the most important concepts to understand.&lt;/p&gt;

&lt;p&gt;Suppose:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VPC-A
   │
   │ Peering
   │
VPC-B
   │
   │ Peering
   │
VPC-C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A common assumption is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VPC-A → VPC-B → VPC-C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But VPC Peering does not automatically provide this kind of transitive routing.&lt;/p&gt;

&lt;p&gt;In other words:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A VPC cannot use another VPC as a router simply because both have peering connections.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If VPC-A needs direct connectivity to VPC-C, an appropriate connectivity design is required.&lt;/p&gt;

&lt;p&gt;This becomes increasingly difficult to manage as the number of VPCs increases.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;5. Why VPC Peering Can Become Difficult at Scale&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
Imagine an organization with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Production VPC&lt;/li&gt;
&lt;li&gt;Development VPC&lt;/li&gt;
&lt;li&gt;Testing VPC&lt;/li&gt;
&lt;li&gt;Security VPC&lt;/li&gt;
&lt;li&gt;Monitoring VPC&lt;/li&gt;
&lt;li&gt;Shared Services VPC&lt;/li&gt;
&lt;li&gt;Analytics VPC&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If many of these VPCs need direct communication, a mesh of peering connections can become difficult to manage.&lt;/p&gt;

&lt;p&gt;For a full mesh, the number of point-to-point connections is:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;N × (N − 1) / 2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For example:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;| Number of VPCs *&lt;/em&gt;| *&lt;em&gt;Full-Mesh Connections *&lt;/em&gt;|&lt;br&gt;
| -------------: | --------------------: |&lt;br&gt;
|              2 |                     1 |&lt;br&gt;
|              3 |                     3 |&lt;br&gt;
|              4 |                     6 |&lt;br&gt;
|              5 |                    10 |&lt;br&gt;
|             10 |                    45 |&lt;br&gt;
|             20 |                   190 |&lt;/p&gt;

&lt;p&gt;The mathematical problem is not the only concern.&lt;/p&gt;

&lt;p&gt;You also have to think about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Route tables&lt;/li&gt;
&lt;li&gt;Security rules&lt;/li&gt;
&lt;li&gt;Connection lifecycle&lt;/li&gt;
&lt;li&gt;Network documentation&lt;/li&gt;
&lt;li&gt;Troubleshooting&lt;/li&gt;
&lt;li&gt;Change management&lt;/li&gt;
&lt;li&gt;Operational ownership&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is where a centralized networking architecture becomes attractive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. What Is AWS Transit Gateway?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AWS Transit Gateway&lt;/strong&gt; is a centralized network transit service that can connect multiple VPCs and supported network environments through a central hub.&lt;/p&gt;

&lt;p&gt;Instead of creating direct connections between every VPC, each VPC can attach to the Transit Gateway.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                    ┌────────────────────┐
                    │   AWS Transit      │
                    │      Gateway       │
                    └─────────┬──────────┘
                              │
          ┌───────────────────┼───────────────────┐
          │                   │                   │
          ▼                   ▼                   ▼
       VPC-A                VPC-B                VPC-C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is commonly described as a &lt;strong&gt;hub-and-spoke architecture&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The Transit Gateway acts as the hub.&lt;/p&gt;

&lt;p&gt;The VPCs become the spokes.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Practical Transit Gateway Architecture**
&lt;/h2&gt;

&lt;p&gt;Consider an organization with separate AWS environments:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                    AWS Transit Gateway
                            │
       ┌────────────────────┼────────────────────┐
       │                    │                    │
       ▼                    ▼                    ▼
 Production VPC       Security VPC        Shared Services
       │                                         │
       ▼                                         ▼
 Application                               Monitoring
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Additional VPCs can be connected to the same Transit Gateway according to the organization's architecture and routing requirements.&lt;/p&gt;

&lt;p&gt;This approach can simplify connectivity management compared with maintaining a large collection of direct VPC-to-VPC connections.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;## 8. Transit Gateway Routing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Transit Gateway introduces another important concept:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Transit Gateway route tables.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These allow network administrators to control how traffic is routed between Transit Gateway attachments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                 Transit Gateway
                       │
             ┌─────────┴─────────┐
             │   TGW Route Table │
             └─────────┬─────────┘
                       │
          ┌────────────┼────────────┐
          ▼            ▼            ▼
        VPC-A        VPC-B        VPC-C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The VPC route tables still matter.&lt;/p&gt;

&lt;p&gt;For example, VPC-A may need:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Destination: 10.20.0.0/16
Target: Transit Gateway
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Transit Gateway then needs the appropriate route toward the attachment containing that destination.&lt;/p&gt;

&lt;p&gt;A useful troubleshooting mindset is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Source
  ↓
VPC Route Table
  ↓
Transit Gateway
  ↓
TGW Route Table
  ↓
Destination VPC
  ↓
Security Controls
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If connectivity fails, each layer should be checked.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;## 9. Transit Gateway and Network Segmentation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of the powerful features of a centralized architecture is the ability to design different connectivity domains.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                Transit Gateway
                       │
       ┌───────────────┼────────────────┐
       │               │                │
       ▼               ▼                ▼
   Production      Development       Security
      VPC              VPC             VPC
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An organization might want:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Production → Security       ✓
Production → Monitoring     ✓
Development → Shared        ✓
Development → Production    ✕
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The exact implementation depends on the organization's routing and security design, but the centralized model makes this kind of segmentation easier to manage.&lt;/p&gt;

&lt;p&gt;This is especially useful in environments following principles such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Least privilege&lt;/li&gt;
&lt;li&gt;Network segmentation&lt;/li&gt;
&lt;li&gt;Environment isolation&lt;/li&gt;
&lt;li&gt;Centralized security controls&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;## 10. VPC Peering vs Transit Gateway&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here is the practical comparison:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;| Area                 *&lt;em&gt;| VPC Peering     *&lt;/em&gt;                 |&lt;/strong&gt; Transit *&lt;em&gt;Gateway   *&lt;/em&gt;                            |&lt;br&gt;
| -------------------- | -------------------------------- | --------------------------------------------- |&lt;br&gt;
| Connectivity model   | Point-to-point                   | Hub-and-spoke                                 |&lt;br&gt;
| Best suited for      | Smaller/simple environments      | Larger/multi-VPC environments                 |&lt;br&gt;
| Centralized routing  | No                               | Yes                                           |&lt;br&gt;
| Transitive routing   | No                               | Supports centralized transit                  |&lt;br&gt;
| Management           | Distributed                      | More centralized                              |&lt;br&gt;
| Network segmentation | More distributed                 | Centralized design option                     |&lt;br&gt;
| Hybrid connectivity  | Not its primary role             | Strong use case                               |&lt;br&gt;
| Initial complexity   | Low                              | Higher                                        |&lt;br&gt;
| Scalability          | Can become operationally complex | Designed for large-scale connectivity         |&lt;br&gt;
| Pricing model        | Data transfer considerations     | Attachment and data-processing considerations |&lt;/p&gt;

&lt;p&gt;Pricing varies by architecture, traffic patterns, AWS Region, and service usage, so always check current AWS pricing when estimating costs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;## 11. When Should You Use VPC Peering?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;VPC Peering is a good candidate when:&lt;/p&gt;
&lt;h3&gt;
  
  
  You have a small number of VPCs
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;For example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Application VPC
      │
      │
   Peering
      │
      ▼
Shared Services VPC
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;### You need direct connectivity&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If two VPCs have a specific and well-defined communication requirement, direct peering may be simpler.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;### You want a straightforward architecture&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Fewer components can mean easier initial implementation and troubleshooting.&lt;/p&gt;

&lt;h2&gt;
  
  
  12. When Should You Use Transit Gateway?**
&lt;/h2&gt;

&lt;p&gt;Transit Gateway becomes attractive when you have:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;### Multiple VPCs&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VPC-A ──┐
VPC-B ──┤
VPC-C ──┼── Transit Gateway
VPC-D ──┤
VPC-E ──┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;### Centralized network management&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You want routing and connectivity decisions to follow a centralized architecture.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;### Hybrid networking requirements&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Organizations may need to connect AWS environments with on-premises networks through supported connectivity architectures.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;### Network segmentation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Different environments may need different communication policies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;### A growing cloud footprint&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As AWS accounts, VPCs, Regions, and environments grow, a scalable network architecture becomes increasingly important.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;13. Hands-On AWS Lab: Build VPC Peering&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you're learning AWS networking, don't stop at theory.&lt;/p&gt;

&lt;p&gt;Try this lab.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1 — Create VPC-A&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Name: VPC-A
CIDR: 10.0.0.0/16
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2 — Create VPC-B
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Name: VPC-B
CIDR: 10.1.0.0/16
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure the CIDR ranges do not overlap.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3 — Create the Peering Connection
&lt;/h3&gt;

&lt;p&gt;In the AWS VPC console:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;VPC → Peering connections → Create peering connection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Select the requester and accepter VPC.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4 — Accept the Connection
&lt;/h3&gt;

&lt;p&gt;Accept the peering request from the other VPC.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5 — Update Route Tables
&lt;/h3&gt;

&lt;p&gt;VPC-A:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10.1.0.0/16 → Peering Connection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;VPC-B:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10.0.0.0/16 → Peering Connection
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 6 — Configure Security Groups
&lt;/h3&gt;

&lt;p&gt;Allow only the traffic required for your test.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 7 — Test Connectivity
&lt;/h3&gt;

&lt;p&gt;Launch test instances and verify connectivity using an appropriate protocol.&lt;/p&gt;

&lt;p&gt;Then intentionally remove a route and observe the failure.&lt;/p&gt;

&lt;p&gt;This is a great way to understand how AWS routing actually works.&lt;/p&gt;

&lt;p&gt;14.** Hands-On AWS Lab: Build a Transit Gateway**&lt;/p&gt;

&lt;p&gt;Create three VPCs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VPC-A → 10.0.0.0/16
VPC-B → 10.1.0.0/16
VPC-C → 10.2.0.0/16
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 1
&lt;/h3&gt;

&lt;p&gt;Create a Transit Gateway.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2
&lt;/h3&gt;

&lt;p&gt;Create Transit Gateway attachments for the VPCs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VPC-A ──┐
VPC-B ──┼── Transit Gateway
VPC-C ──┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3
&lt;/h3&gt;

&lt;p&gt;Update VPC route tables.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;10.1.0.0/16 → Transit Gateway
10.2.0.0/16 → Transit Gateway
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4
&lt;/h3&gt;

&lt;p&gt;Configure the Transit Gateway route table according to your desired connectivity.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5
&lt;/h3&gt;

&lt;p&gt;Check security groups and network ACLs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 6
&lt;/h3&gt;

&lt;p&gt;Test traffic between the instances.&lt;/p&gt;

&lt;p&gt;Then make the lab more interesting:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Try blocking Development → Production while allowing Development → Shared Services.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This turns a simple connectivity lab into a real network-design exercise.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;15. A Real-World Cloud Architecture&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine an organization operating an e-commerce platform.&lt;/p&gt;

&lt;p&gt;Its AWS environment contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Production&lt;/li&gt;
&lt;li&gt;Development&lt;/li&gt;
&lt;li&gt;Security&lt;/li&gt;
&lt;li&gt;Monitoring&lt;/li&gt;
&lt;li&gt;Shared Services&lt;/li&gt;
&lt;li&gt;Analytics&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A scalable architecture could look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                         ┌──────────────────┐
                         │ Transit Gateway  │
                         └────────┬─────────┘
                                  │
          ┌───────────────┬───────┼────────┬───────────────┐
          │               │       │        │               │
          ▼               ▼       ▼        ▼               ▼
     Production     Development Security Monitoring   Shared Services
        VPC              VPC        VPC       VPC          VPC
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each environment can have its own CIDR range and security controls.&lt;/p&gt;

&lt;p&gt;The network architecture can then define which environments are allowed to communicate.&lt;/p&gt;

&lt;p&gt;This is closer to how enterprise cloud networking is designed than simply connecting every VPC to every other VPC.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;16. Common AWS Networking Mistakes&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Mistake 1: Assuming a connection automatically creates routes
&lt;/h3&gt;

&lt;p&gt;It doesn't.&lt;/p&gt;

&lt;p&gt;Always check the relevant route tables.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mistake 2: Forgetting return traffic
&lt;/h3&gt;

&lt;p&gt;Networking is bidirectional.&lt;/p&gt;

&lt;p&gt;A route from A to B is not enough if B has no route back to A.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mistake 3: Ignoring security groups
&lt;/h3&gt;

&lt;p&gt;Correct routing does not override security controls.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mistake 4: Assuming VPC Peering is transitive
&lt;/h3&gt;

&lt;p&gt;It isn't.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mistake 5: Choosing architecture only based on price
&lt;/h3&gt;

&lt;p&gt;A low initial cost can become expensive operationally if the architecture becomes difficult to manage.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mistake 6: Using overlapping CIDRs
&lt;/h3&gt;

&lt;p&gt;Overlapping address ranges can create major networking limitations.&lt;/p&gt;

&lt;p&gt;Good IP address planning should happen before connecting networks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;17. How to Choose Between Them&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A useful way to approach the decision is to ask five questions.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. How many VPCs do I have?
&lt;/h3&gt;

&lt;p&gt;Two VPCs?&lt;/p&gt;

&lt;p&gt;Peering may be enough.&lt;/p&gt;

&lt;p&gt;Many VPCs?&lt;/p&gt;

&lt;p&gt;Start evaluating a centralized architecture.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Do the VPCs need direct connectivity?
&lt;/h3&gt;

&lt;p&gt;If only two environments need to communicate, direct peering may be simpler.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Do I need centralized routing?
&lt;/h3&gt;

&lt;p&gt;If yes, Transit Gateway becomes more attractive.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Do I need network segmentation?
&lt;/h3&gt;

&lt;p&gt;If different environments need different connectivity policies, a centralized architecture can simplify the design.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Will the environment grow?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Today's two-VPC architecture may become tomorrow's twenty-VPC architecture.&lt;/p&gt;

&lt;p&gt;Good cloud architecture considers not only today's requirements but also reasonable future growth.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;18. Interview Question: What Is the Difference?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Q*&lt;em&gt;: What is the difference between VPC Peering and Transit Gateway?&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
A professional answer:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;VPC Peering provides direct private connectivity between two VPCs, while Transit Gateway provides a centralized hub through which multiple VPCs and supported networks can connect. VPC Peering is often suitable for simple point-to-point requirements, whereas Transit Gateway is better suited to larger environments that require centralized routing, segmentation, and scalable network connectivity.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;19. Interview Question: Does VPC Peering Support Transitive Routing?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A ↔ B
B ↔ C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you cannot assume:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A ↔ C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;through B.&lt;/p&gt;

&lt;p&gt;This is one of the most important differences to remember when designing AWS networks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;20. Is Transit Gateway Always Better?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Architecture should be based on requirements.&lt;/p&gt;

&lt;p&gt;For two VPCs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VPC-A ───── VPC-B
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;VPC Peering may be perfectly reasonable.&lt;/p&gt;

&lt;p&gt;For dozens of VPCs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VPC-A ──┐
VPC-B ──┤
VPC-C ──┤
VPC-D ──┼── **Transit Gateway**
VPC-E ──┤
VPC-F ──┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Transit Gateway may provide a much cleaner architecture.&lt;/p&gt;

&lt;p&gt;The goal is not to use the most advanced service.&lt;/p&gt;

&lt;p&gt;The goal is to use the &lt;strong&gt;right architecture for the problem&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;21. Final Architecture Comparison&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;VPC Peering&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                Direct Connectivity

┌───────────┐                  ┌───────────┐
│   VPC-A   │══════════════════│   VPC-B   │
└───────────┘                  └───────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Think:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"I need these two VPCs to communicate directly."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Transit Gateway
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                    ┌──────────────┐
                    │   Transit    │
                    │   Gateway    │
                    └──────┬───────┘
                           │
              ┌────────────┼────────────┐
              │            │            │
              ▼            ▼            ▼
           VPC-A         VPC-B        VPC-C
              │
              ▼
        Shared Network
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Think:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"I need a scalable central network architecture."&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;strong&gt;## Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;AWS VPC Peering and Transit Gateway solve related but different networking problems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;VPC Peering&lt;/strong&gt; is a direct connectivity model that works well when the number of VPCs and connectivity requirements are relatively simple.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Transit Gateway&lt;/strong&gt; provides a centralized network hub that becomes increasingly valuable as environments grow and require scalable routing, segmentation, and connectivity between multiple networks.&lt;/p&gt;

&lt;p&gt;The most important lesson is not simply memorizing the definitions.&lt;/p&gt;

&lt;p&gt;It is understanding the architectural trade-off:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Simple network → consider direct connectivity.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Growing network → consider centralized connectivity.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Good cloud networking is not just about making two systems communicate.&lt;/p&gt;

&lt;p&gt;It is about designing connectivity that remains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Secure&lt;/li&gt;
&lt;li&gt;Understandable&lt;/li&gt;
&lt;li&gt;Scalable&lt;/li&gt;
&lt;li&gt;Maintainable&lt;/li&gt;
&lt;li&gt;Cost-conscious&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're learning AWS networking, build both architectures yourself.&lt;/p&gt;

&lt;p&gt;Create the VPCs.&lt;/p&gt;

&lt;p&gt;Configure the routes.&lt;/p&gt;

&lt;p&gt;Test connectivity.&lt;/p&gt;

&lt;p&gt;Break a route.&lt;/p&gt;

&lt;p&gt;Fix it.&lt;/p&gt;

&lt;p&gt;Then build the same scenario with Transit Gateway.&lt;/p&gt;

&lt;p&gt;That's when networking stops being a diagram and starts becoming a real engineering skill.&lt;/p&gt;




&lt;p&gt;**## Key Takeaways&lt;/p&gt;

&lt;h3&gt;
  
  
  VPC Peering**
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Direct VPC-to-VPC connectivity&lt;/li&gt;
&lt;li&gt;Simple for smaller environments&lt;/li&gt;
&lt;li&gt;No transitive routing&lt;/li&gt;
&lt;li&gt;Distributed route management&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;** Transit Gateway**&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Centralized hub-and-spoke architecture&lt;/li&gt;
&lt;li&gt;Designed for connecting multiple networks&lt;/li&gt;
&lt;li&gt;Centralized routing capabilities&lt;/li&gt;
&lt;li&gt;Useful for scalable and hybrid cloud architectures&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Final Thought&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The real cloud-engineering skill is not knowing the definition of VPC Peering or Transit Gateway.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloudstorage</category>
      <category>networking</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Hands-On with Amazon S3: Buckets, Permissions, Lifecycle Rules and Static Hosting published: true tags: aws, devops, s3 cover</title>
      <dc:creator>Toqeer Afzal</dc:creator>
      <pubDate>Mon, 14 Sep 2026 15:17:36 +0000</pubDate>
      <link>https://dev.to/toqeer_afzal_d1e337ddf67f/hands-on-with-amazon-s3-buckets-permissions-lifecycle-rules-and-static-hosting-published-true-2g51</link>
      <guid>https://dev.to/toqeer_afzal_d1e337ddf67f/hands-on-with-amazon-s3-buckets-permissions-lifecycle-rules-and-static-hosting-published-true-2g51</guid>
      <description>&lt;p&gt;Hands-On with Amazon S3: Buckets, Permissions, Lifecycle Rules, and Static Hosting Explained&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F65r6eq3vsfn8v2b0ov6m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F65r6eq3vsfn8v2b0ov6m.png" alt=" " width="800" height="500"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbjylui693p6ewaiqt3qx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbjylui693p6ewaiqt3qx.png" alt=" " width="800" height="489"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
Cloud storage sounds abstract until you actually create a bucket, upload a file into it, and watch access rules decide who can — and can't — see that file. That's exactly the exercise this article is built on: a hands-on AWS lab covering S3 buckets, object uploads, storage classes, bucket policies, ACLs/permissions, intelligent tiering through a lifecycle rule, and static website hosting.&lt;/p&gt;

&lt;p&gt;If you're learning cloud computing or preparing for DevOps/cloud work, S3 is one of the first services worth understanding deeply — not just because it's common but because it forces you to think about storage, access control, cost, and availability all at once.&lt;/p&gt;

&lt;p&gt;In this post, you'll learn what each of these S3 concepts means, how they connect to each other, and how a bucket goes from "empty storage" to a fully configured, cost-optimized, publicly hosted resource.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Quick Overview&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The lab covered the following core building blocks:&lt;/p&gt;

&lt;p&gt;Buckets — the top-level container for storing data in S3.&lt;br&gt;
Objects — the actual files uploaded into a bucket.&lt;br&gt;
Upload — the process of putting objects into a bucket.&lt;br&gt;
Storage Classes — different tiers for storing objects based on access needs.&lt;br&gt;
Bucket Policy — a resource-level, JSON-based permission set attached to a bucket.&lt;br&gt;
ACL (Access Control List) &amp;amp; Permissions — access control at the bucket/object level.&lt;br&gt;
Intelligent Tiering — an S3 storage class that automatically optimizes cost based on access patterns.&lt;br&gt;
Lifecycle Configuration Rule — automated rules that transition or expire objects over time.&lt;br&gt;
Static Website Hosting — configuring a bucket to serve content directly as a website.&lt;br&gt;
&lt;strong&gt;Core Concepts&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Buckets&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A bucket is the container that holds your data in S3. Every object you store must live inside a bucket, and every bucket name must be globally unique across all of AWS. Think of a bucket as the top-level folder for a project or application's storage needs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Objects &amp;amp; Upload&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An object is simply a file — an image, a document, a video, a JSON file, anything — stored inside a bucket. Upload is the action of transferring that file from your local machine (or another system) into the bucket. Once uploaded, each object is identified by a unique key (essentially its path/name inside the bucket).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Storage Classes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;S3 offers multiple storage classes, each designed for a different access pattern — frequently accessed data, infrequently accessed data, and long-term archival data. Choosing the right class is a balance between accessibility and cost efficiency.&lt;/p&gt;

&lt;p&gt;Note: Exact pricing figures for each storage class were not provided in the source data, so no cost numbers are stated here. Refer to official AWS pricing pages for current rates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bucket Policy&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A bucket policy is a JSON-based access control document attached directly to a bucket. It defines who (which AWS account, user, or role) can perform what actions (read, write, delete, etc.) on the bucket or its objects. This is the primary mechanism for controlling access at the bucket level.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ACL &amp;amp; Permissions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;ACLs (Access Control Lists) are an older, more granular way to control access to individual buckets and objects, alongside standard permissions. While bucket policies are generally the modern, recommended approach, understanding ACLs is still useful, especially when working with legacy configurations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Intelligent Tiering &amp;amp; Lifecycle Configuration Rule&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Intelligent Tiering is a storage class that automatically moves objects between access tiers based on how frequently they're used — without manual intervention. This is configured through a lifecycle configuration rule, which defines automated actions on objects over time (for example, transitioning objects to a different storage class after a certain period, or expiring them altogether).&lt;/p&gt;

&lt;p&gt;In the lab, intelligent tiering was set up specifically as a lifecycle configuration rule — meaning the automation of "move this data to a cheaper tier when it's not being accessed" is handled through S3's lifecycle rule engine.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Static Website Hosting&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;S3 buckets can be configured to host static websites directly — serving HTML, CSS, JS, and other static assets straight from the bucket via a website endpoint. This turns a plain storage bucket into a publicly accessible website, without needing a traditional web server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cloud Architecture / Structure&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Based on the components covered in the lab, here's how they relate to one another inside a single S3 bucket setup:&lt;/p&gt;

&lt;p&gt;S3 Bucket&lt;br&gt;
Upload&lt;br&gt;
Controls access to&lt;br&gt;
Controls access to&lt;br&gt;
Triggers&lt;br&gt;
Moves&lt;br&gt;
Serves&lt;br&gt;
HTTP Request&lt;br&gt;
Objects (Uploaded Files)&lt;br&gt;
Bucket Policy&lt;br&gt;
ACL &amp;amp; Permissions&lt;br&gt;
Lifecycle Configuration Rule&lt;br&gt;
Intelligent Tiering&lt;br&gt;
Static Website Hosting&lt;br&gt;
User / Client&lt;br&gt;
Website Visitor&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Component labels:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Objects — the files stored in the bucket.&lt;br&gt;
Bucket Policy / ACL &amp;amp; Permissions — the two access-control layers governing who can interact with objects.&lt;br&gt;
Lifecycle Configuration Rule — the automation engine that triggers storage-class transitions.&lt;br&gt;
Intelligent Tiering — the storage class that lifecycle rules move eligible objects into.&lt;br&gt;
Static Website Hosting — the feature that exposes bucket objects as a browsable website.&lt;br&gt;
Workflow / Process&lt;/p&gt;

&lt;p&gt;Here's the step-by-step process the lab followed, from an empty bucket to a fully configured one:&lt;/p&gt;

&lt;p&gt;Create Bucket&lt;br&gt;
Upload Objects&lt;br&gt;
Set Bucket Policy&lt;br&gt;
Configure ACL / Permissions&lt;br&gt;
Set Lifecycle ConfigurationRule&lt;br&gt;
Enable Intelligent Tiering&lt;br&gt;
Enable Static WebsiteHosting&lt;br&gt;
Bucket Serves ContentPublicly&lt;br&gt;
Create Bucket — a globally unique bucket is created.&lt;br&gt;
Upload Objects — files are added into the bucket.&lt;br&gt;
Set Bucket Policy — access rules are defined at the bucket level.&lt;br&gt;
Configure ACL / Permissions — finer-grained or legacy-style access control is applied.&lt;br&gt;
Set Lifecycle Configuration Rule — automation rules are defined for object transitions.&lt;br&gt;
Enable Intelligent Tiering — objects become eligible for automatic cost-optimized storage movement.&lt;br&gt;
Enable Static Website Hosting — the bucket is exposed as a website endpoint.&lt;br&gt;
Bucket Serves Content — end users/visitors can now access the hosted content.&lt;br&gt;
*&lt;em&gt;Practical / Real-World Example&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
A common real-world use case that matches this exact configuration: hosting a personal portfolio or documentation site directly from S3.&lt;/p&gt;

&lt;p&gt;The bucket stores the site's HTML, CSS, JS, and image files (the objects).&lt;br&gt;
A bucket policy allows public GetObject access so visitors can view the site, while restricting write/delete access to the account owner.&lt;br&gt;
ACLs/permissions can be used to fine-tune access on specific objects if needed.&lt;br&gt;
A lifecycle configuration rule with intelligent tiering can be applied to older assets (e.g., archived blog images) so they move to lower-cost tiers automatically if they stop being accessed frequently.&lt;br&gt;
Static website hosting is enabled so the bucket serves an index.html directly to browsers via the S3 website endpoint.&lt;/p&gt;

&lt;p&gt;This mirrors exactly the sequence of concepts covered in the lab — access control, cost optimization, and public content delivery, all from a single bucket.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages&lt;/strong&gt;&lt;br&gt;
Simple, durable storage — buckets provide a straightforward way to store and organize objects.&lt;br&gt;
Granular access control — bucket policies and ACLs give precise control over who can access what.&lt;br&gt;
Automated cost optimization — lifecycle rules and intelligent tiering reduce the need for manual storage-class management.&lt;br&gt;
No server required for static content — static website hosting lets you serve a website directly from storage, without provisioning a web server.&lt;br&gt;
&lt;strong&gt;Challenges / Limitations&lt;/strong&gt;&lt;br&gt;
Access control complexity — having two overlapping mechanisms (bucket policy and ACLs) can make permissions harder to reason about if not managed carefully.&lt;br&gt;
Public bucket risk — enabling static website hosting or public policies requires care, since misconfigured public access exposes data broadly.&lt;br&gt;
Specific limitations around storage-class transition timing, minimum storage durations, or request pricing are not provided in the source data.&lt;br&gt;
&lt;strong&gt;Best Practices&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Tip: Prefer bucket policies over ACLs for new configurations, since AWS recommends policies as the modern standard — ACL usage here reflects what was covered in the lab, not a general recommendation against policies.&lt;/p&gt;

&lt;p&gt;Important: Double-check any bucket intended for static website hosting to ensure only the intended objects are public, and nothing else in the bucket is unintentionally exposed.&lt;/p&gt;

&lt;p&gt;Review lifecycle rules periodically to confirm objects are transitioning as intended.&lt;br&gt;
Keep bucket policies and ACLs documented so access logic doesn't become guesswork later.&lt;br&gt;
Test static website hosting configuration in a non-production bucket first.&lt;/p&gt;

&lt;p&gt;(These are general cloud best practices; none of them are numeric claims from the source data.)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This lab walks through the full lifecycle of an S3 bucket: creating it, filling it with objects, locking down access with policies and ACLs, optimizing cost automatically through lifecycle rules and intelligent tiering, and finally exposing it as a public static website. Each piece — storage, access control, and cost management — is a core skill for anyone working with cloud infrastructure, and S3 is one of the clearest services to learn them on.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Takeaways&lt;/strong&gt;&lt;br&gt;
A bucket is S3's top-level storage container; objects are the files inside it.&lt;br&gt;
Bucket policies and ACLs/permissions are the two layers controlling access to a bucket and its objects.&lt;br&gt;
Storage classes let you match storage cost to how often data is actually accessed.&lt;br&gt;
Lifecycle configuration rules automate storage-class transitions — including into intelligent tiering.&lt;br&gt;
Static website hosting turns a bucket into a public website endpoint, no server required.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>devops</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
