<?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>Forem: Bayu Wibowo</title>
    <description>The latest articles on Forem by Bayu Wibowo (@bayupw).</description>
    <link>https://forem.com/bayupw</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F854634%2F54a070e0-1d40-46d6-902b-3bdef02fc123.PNG</url>
      <title>Forem: Bayu Wibowo</title>
      <link>https://forem.com/bayupw</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/bayupw"/>
    <language>en</language>
    <item>
      <title>Single-Digit ms latency with AWS Local Zone</title>
      <dc:creator>Bayu Wibowo</dc:creator>
      <pubDate>Fri, 05 May 2023 23:31:07 +0000</pubDate>
      <link>https://forem.com/bayupw/single-digit-ms-latency-with-aws-local-zone-3pb</link>
      <guid>https://forem.com/bayupw/single-digit-ms-latency-with-aws-local-zone-3pb</guid>
      <description>&lt;p&gt;A few months back, AWS made an announcement about a new &lt;a href="https://aws.amazon.com/about-aws/whats-new/2023/03/aws-direct-connect-auckland-new-zealand/"&gt;Direct Connect (DX) location in Auckland&lt;/a&gt;, which was great news for businesses in the region looking to connect their on-prem to AWS. And just last week, AWS launched an &lt;a href="https://aws.amazon.com/about-aws/whats-new/2023/05/general-availability-aws-local-zones-auckland/"&gt;AWS Local Zone in Auckland&lt;/a&gt;, bringing AWS services even closer to NZ businesses.&lt;/p&gt;

&lt;p&gt;One of use case of AWS Local Zones is to deliver single-digit latency. But can the AWS Local Zones really achieve the single-digit latency? As I'm based in Auckland, it's a good opportunity for me to test out Auckland's Local Zone. But before that, let's take a quick review on what is AWS Local Zone, what features does it support and how does the pricing would look like.&lt;/p&gt;

&lt;h1&gt;
  
  
  AWS Local Zones Overview
&lt;/h1&gt;

&lt;p&gt;As explained on the &lt;a href="https://docs.aws.amazon.com/local-zones/latest/ug/what-is-aws-local-zones.html"&gt;AWS Local Zones User Guide&lt;/a&gt;, Local Zone is like a VPC extension of an AWS parent region. As you can see in below diagram, we have Sydney (ap-southeast-2) as a parent region and we extend the VPC into Auckland by creating a subnet in a Local Zone in Auckland (ap-southeast-2-akl-1a)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0DgCVE0j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2s2tnzemsqpwbpdxt29e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0DgCVE0j--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2s2tnzemsqpwbpdxt29e.png" alt="AWS Local Zones Architecture" width="800" height="523"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/local-zones/latest/ug/getting-started.html"&gt;Enabling a Local Zone&lt;/a&gt; is pretty straight forward, just go to the the EC2 console (not VPC) and make sure you're in the right region. Then under Account attribute section, go to Zones &amp;gt; select your desired Local Zone &amp;gt; click Manage and enable it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XJE0Q4Kd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mio8j60674msv81i7lia.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XJE0Q4Kd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mio8j60674msv81i7lia.png" alt="AWS Local Zones Settings" width="800" height="461"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once a Local Zone is enabled in the region, it will be seen like an additional Availability Zone in that region as shown below&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xI4qjwTD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/urladc09qaxsukwf7jna.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xI4qjwTD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/urladc09qaxsukwf7jna.png" alt="Creating New Subnet in AWS Local Zones" width="800" height="636"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  AWS Local Zones Features
&lt;/h1&gt;

&lt;p&gt;The next question would be, what features are supported in AWS Local Zones? From the &lt;a href="https://youtu.be/gsktWzP_yZw?t=250"&gt;AWS Local Zones Online Tech Talks session&lt;/a&gt;, it looks like it supports a number of services in LA, but outside of that it's mostly the core compute and networking like EC2, EBS, VPC, and DX.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NPhgGIIm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/52mlqigmtv09tqrlmlko.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NPhgGIIm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/52mlqigmtv09tqrlmlko.png" alt="AWS Local Zones Online Tech Talks Features" width="800" height="468"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Link to the latest AWS Local Zones features here: &lt;a href="https://aws.amazon.com/about-aws/global-infrastructure/localzones/features/"&gt;https://aws.amazon.com/about-aws/global-infrastructure/localzones/features/&lt;/a&gt;. Just looking at Auckland, it supports EC2 (t3, c5, r5, m5, upcoming g4dn), EBS (gp2 only), standard AWS Shield, ECS, EKS, VPC and DX.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GB7hGYXz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uab5j97x3fha25cqrnsh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GB7hGYXz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uab5j97x3fha25cqrnsh.png" alt="AWS Local Zones Features" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  AWS Local Zones Pricing
&lt;/h1&gt;

&lt;p&gt;It's important to note that the pricing for Local Zones is different from the pricing of the parent region. Let's compare a t3.medium EC2 Linux pricing between Sydney vs Auckland and estimate it for a month usage.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Location&lt;/th&gt;
&lt;th&gt;Instance Type&lt;/th&gt;
&lt;th&gt;On-Demand Hourly Rate&lt;/th&gt;
&lt;th&gt;Monthly Cost (730 hours)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Sydney&lt;/td&gt;
&lt;td&gt;t3.medium&lt;/td&gt;
&lt;td&gt;$0.0528&lt;/td&gt;
&lt;td&gt;$38.54&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Auckland&lt;/td&gt;
&lt;td&gt;t3.medium&lt;/td&gt;
&lt;td&gt;$0.0713&lt;/td&gt;
&lt;td&gt;$52.05&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kReGuFl0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g5d1jjfiltifykzh63b2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kReGuFl0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g5d1jjfiltifykzh63b2.png" alt="EC2 pricing Sydney vs Auckland" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another note is that &lt;a href="https://aws.amazon.com/ec2/pricing/on-demand/#Data_Transfer_within_the_same_AWS_Region"&gt;data transfer charge&lt;/a&gt; would be different as well, that includes data transfer between a Local Zone and an Availability Zone within the same AWS Region (e.g. Auckland and Sydney)&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pyZyWADa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/obmx37y9fzwy25awod75.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pyZyWADa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/obmx37y9fzwy25awod75.png" alt="Data Transfer Charge" width="800" height="258"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Latency Test and Comparison
&lt;/h1&gt;

&lt;p&gt;Lastly, let's see if it can really deliver a single-digit millisecond latency. I'm going create an EC2 instance in Sydney, an EC2 instance in Auckland, and ping/mtr from my laptop in Auckland.&lt;/p&gt;

&lt;p&gt;The diagram below shows the setup and quick ping/mtr test between my laptop and each of the EC2 instances as well as between them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mTQgPuoP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gzazqy2fefia8y2y1pel.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mTQgPuoP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gzazqy2fefia8y2y1pel.png" alt="Latency Summary" width="800" height="629"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZpYnTvtr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9znsbezqvbe84zamtxif.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZpYnTvtr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9znsbezqvbe84zamtxif.png" alt="EC2 Summary" width="800" height="362"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UUPMdro0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c9fpp21cgsxd5lxykslm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UUPMdro0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c9fpp21cgsxd5lxykslm.png" alt="Latency test result" width="800" height="624"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;If your business in NZ can't leverage AWS Services in Sydney due to latency or perhaps data residency requirements, this AWS Local Zone in Auckland might be worth a look. Make sure to double check the supported AWS services first, as some may only be available in the parent region, and data transfers between Local Zone and parent region Availability Zone may be subject to data transfer charge.&lt;/p&gt;

&lt;p&gt;While achieving single-digit latency may not be guaranteed, the Auckland's Local Zone has the potential to significantly improve performance and reduce latency for customers using AWS services from within New Zealand and can't wait for the Auckland Region to launch. In addition, this may be an option for organisations that want to leverage AWS services but don't want to manage physical infrastructure on-prem and can't use existing regions due to latency. Unlike AWS Outpost, the AWS Local Zones don't require customers to host any infrastructure on-premises.&lt;/p&gt;

</description>
      <category>localzone</category>
      <category>aws</category>
      <category>lowlatency</category>
    </item>
    <item>
      <title>Understanding the Networking Basics of Lambda to RDS Connectivity</title>
      <dc:creator>Bayu Wibowo</dc:creator>
      <pubDate>Fri, 07 Apr 2023 22:18:15 +0000</pubDate>
      <link>https://forem.com/bayupw/understanding-the-networking-basics-of-lambda-to-rds-connectivity-5424</link>
      <guid>https://forem.com/bayupw/understanding-the-networking-basics-of-lambda-to-rds-connectivity-5424</guid>
      <description>&lt;p&gt;When it comes to connecting AWS services that are managed by the cloud service providers (e.g., Lambda, RDS, DynamoDB), we tend to think everything is connected under the hood and all we have to do is to create inbound rules on the security group or grant permissions. Generally speaking, it usually works out fine when we use the default VPC. If you're new to VPC, private/public subnets, and route table concepts, feel free to head over my other blog post here: &lt;a href="https://dev.to/bayupw/learn-and-build-aws-vpc-networking-for-network-engineers-1fch"&gt;https://dev.to/bayupw/learn-and-build-aws-vpc-networking-for-network-engineers-1fch&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Being a network guy, I'm always curious about how things work on the networking side. In this blog post, I'll dive into some basics networking and relevant key concepts when connecting AWS Lambda function to RDS. By the end of this post, hopefully you'll have a good understanding on how to connect these two services and how to secure them from a network &amp;amp; security point of view especially if you're following the &lt;a href="https://www.linkedin.com/posts/andrew-wc-brown_welcome-to-the-free-aws-cloud-project-bootcamp-activity-7029276209087750145-ete2/"&gt;Andrew Brown's Free AWS Cloud Project Bootcamp&lt;/a&gt;. So, let's get started!&lt;/p&gt;

&lt;h2&gt;
  
  
  Amazon RDS Networking
&lt;/h2&gt;

&lt;p&gt;As ChatGPT said below, RDS is a managed service from AWS where we just provision a Database and the service will be accessible once provisioning is completed. &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xfbVBEWa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yxglr8s4230mebw5bdbe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xfbVBEWa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yxglr8s4230mebw5bdbe.png" alt="Amazon RDS" width="800" height="191"&gt;&lt;/a&gt; But how do we connect to it? Does it run on like a "Public Zone" of AWS or is it going to be on provisioned in a VPC? Let's take a look.&lt;/p&gt;

&lt;p&gt;If you go ahead and provision an RDS, you'll notice that there's a 'Connectivity' section where we need to choose a VPC and supply or select other relevant parameters related to network &amp;amp; security.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LFuQlsmv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4y7xj3b6ghlb5zxlr28w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LFuQlsmv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4y7xj3b6ghlb5zxlr28w.png" alt="RDS Connectivity Section" width="750" height="717"&gt;&lt;/a&gt; When a service need to run in a VPC, this is normally a good indicator that the service will create a network adapter - &lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html"&gt;ENI&lt;/a&gt; in the VPC. Notice the note: "&lt;em&gt;After a database is created, you can't change its VPC.&lt;/em&gt;" In a case where you need to change your RDS into another VPC for whatever reason, you may need to perform a migration instead. Here are some useful links on RDS migration to a different VPC/account:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://repost.aws/knowledge-center/change-vpc-rds-db-instance"&gt;Migrate an Amazon RDS DB instance to another VPC or account
&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/migrate-an-amazon-rds-db-instance-to-another-vpc-or-account.html"&gt;How do I change the VPC for an Amazon RDS DB instance?
&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.VPC2VPC.html"&gt;Updating the VPC for a DB instance
&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  DB Subnet Group
&lt;/h3&gt;

&lt;p&gt;After choosing a VPC, the next required parameter would normally be the subnet or subnet ID. But not quite with RDS, instead it is asking for something called &lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.WorkingWithRDSInstanceinaVPC.html"&gt;DB Subnet Group&lt;/a&gt;. As per the name, DB Subnet Group is essentially a logical grouping of subnets in at least 2 AZs - it will throw an error if you try to create a DB Subnet Group with in 1 AZ.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0kVfgMqU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/su1fw48mgjfidatrlcv4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0kVfgMqU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/su1fw48mgjfidatrlcv4.png" alt="DB Subnet Group Error" width="782" height="691"&gt;&lt;/a&gt; When deploying a &lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.MultiAZ.html"&gt;Multi-AZ RDS Deployment&lt;/a&gt;, additional IP will be created on the other AZ(s) for the standby DB instance(s). Note: while you can use IP address to connect to the DB instance, the IP might change during failover and therefore it is recommended to use the DNS name to connect to the DB.&lt;/p&gt;

&lt;p&gt;The DB Subnet Group typically consists of private subnets which don't have a default route towards the AWS Internet Gateway as you probably don't want your RDS to be accessible from the Internet in most cases. But if you do, then you will need to have public subnets in your DB Subnet Group.&lt;/p&gt;

&lt;h3&gt;
  
  
  Public Access
&lt;/h3&gt;

&lt;p&gt;The next part is the 'Public access' parameter which needs to be aligned with the DB Subnet Group configuration. When set to No, the provisioned &lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html"&gt;ENI&lt;/a&gt; will only have Private IP.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ln-H0NTf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8pqwls0krhqicz5n9010.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ln-H0NTf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8pqwls0krhqicz5n9010.png" alt="RDS with Public access set to Yes" width="800" height="402"&gt;&lt;/a&gt; If you try to access it from the Internet, your PC or a cloud development environment such as &lt;a href="https://www.gitpod.io/"&gt;Gitpod&lt;/a&gt; that would obviously not be accessible.&lt;br&gt;
However, if you set it to Yes, the &lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html"&gt;ENI&lt;/a&gt; will also have a Public IP and a Public hostname (DNS endpoint). This settings can be changed without the need to re-provision the RDS which is quite handy.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jwXqS_pX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1tcnlb23mmsyzhajsbjo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jwXqS_pX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1tcnlb23mmsyzhajsbjo.png" alt="RDS with Public access set to Yes" width="800" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  VPC Security Group
&lt;/h3&gt;

&lt;p&gt;Similar to an EC2 instance with ENI, access to RDS from network &amp;amp; security point of view can be controlled through a VPC Security Group rules. This can be an existing Security Group (e.g., default Security Group) or a &lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Tutorials.WebServerDB.CreateVPC.html#CHAP_Tutorials.WebServerDB.CreateVPC.SecurityGroupDB"&gt;new Security Group&lt;/a&gt;. A new dedicated Security Group for RDS might be easier to manage as we would know any rules being defined will be for the RDS access.&lt;/p&gt;

&lt;p&gt;In my case, I'll set the 'Public Access' to Yes and I'll go ahead and create a new Security Group and add inbound rules for my public IP to &lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ConnectToPostgreSQLInstance.html"&gt;Connect to PostgreSQL&lt;/a&gt;.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HKjblXEY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/woj09tzd352fg83nx00r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HKjblXEY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/woj09tzd352fg83nx00r.png" alt="Security Group Inbound rules" width="800" height="300"&gt;&lt;/a&gt; As per screenshot below, I can connect to the PostgreSQL using a Database Client UI or &lt;code&gt;psql&lt;/code&gt; CLI using Connection URI: &lt;code&gt;postgresql://&amp;lt;user&amp;gt;:&amp;lt;password&amp;gt;@&amp;lt;rds-endpoint&amp;gt;:&amp;lt;port&amp;gt;/&amp;lt;db-name&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qGeEqJ90--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fj16o1epm2wg8aa4r81o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qGeEqJ90--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fj16o1epm2wg8aa4r81o.png" alt="Connect to PostgreSQL" width="800" height="315"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  RDS Networking Diagram
&lt;/h3&gt;

&lt;p&gt;A picture says a thousand words and I love to draw everything when it comes to technical stuff. Let's take a look at all the components we've discussed so far in a technical diagram format.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--orApKYKK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qf0zgctgos5zhlhojl5w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--orApKYKK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qf0zgctgos5zhlhojl5w.png" alt="RDS Networking Diagram" width="800" height="391"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  AWS Lambda Networking
&lt;/h2&gt;

&lt;p&gt;Now that we have covered off RDS Networking, let's take a look at what we'll need to spin up a Lambda function from networking point of view so we can have it connected to RDS.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IcGRd81k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rw6tpiphlcqelhykh36w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IcGRd81k--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rw6tpiphlcqelhykh36w.png" alt="Lambda" width="800" height="271"&gt;&lt;/a&gt; In this case, I will create a &lt;a href="https://gist.github.com/bayupw/33784908af56e4a495ecca56ee553051"&gt;Lambda function with python&lt;/a&gt; to do database schema load into the PostgreSQL. Note: I'm storing connection URI on the environment variable for demo purpose. For production, you may want to use something like &lt;a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/retrieving-secrets_lambda.html"&gt;AWS Secrets Manager&lt;/a&gt; and Lambda dynamically fetch secrets from Secrets Manager. There's a good article in AWS blog that talks about using &lt;a href="https://aws.amazon.com/blogs/database/automate-post-database-creation-scripts-or-steps-in-an-amazon-rds-for-oracle-database/"&gt;AWS Lambda function to run post-database creation scripts&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;As per the &lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/foundation-networking.html"&gt;AWS Lambda docs under networking section&lt;/a&gt;, Lambda function always runs inside a VPC owned by the Lambda service and by default, is not connected to a VPC in your account. There's a section in the Lambda configuration where you can edit VPC related configuration and it requires certain IAM permissions to be able to create and manage network interfaces to create the HyperPlane ENI as per the &lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/configuration-vpc.html"&gt;AWS Lambda doc&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I'll go ahead and choose a VPC, 2 subnets and a new dedicated Security Group for the Lambda ENI.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rKNtw7BH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wqno0o70bss6a84f9cdm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rKNtw7BH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wqno0o70bss6a84f9cdm.png" alt="Lambda VPC configuration" width="800" height="692"&gt;&lt;/a&gt; The configuration will let you choose single subnet, but it will throw a warning that AWS recommends choosing 2 subnets for HA.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---qO2AhlR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1q7igxcblh1822ih7q7c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---qO2AhlR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1q7igxcblh1822ih7q7c.png" alt="Lambda subnets warning" width="698" height="81"&gt;&lt;/a&gt; Once the configuration is updated, you will see an ENI with a private IP. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SFD0Mf11--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9pwg0oicop5dtn764k9x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SFD0Mf11--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9pwg0oicop5dtn764k9x.png" alt="Lambda ENI" width="800" height="418"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  AWS Lambda and RDS Networking Diagram
&lt;/h2&gt;

&lt;p&gt;With the Lambda connected to VPC, here's the updated diagram for single AZ.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eyrXKHdT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wqqjxr0z31n3ke7trnn7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eyrXKHdT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wqqjxr0z31n3ke7trnn7.png" alt="AWS Lambda and RDS Networking Diagram" width="800" height="458"&gt;&lt;/a&gt; You can use the default Security Group for both RDS and Lambda and everything will just work. But, since I use dedicated Security Groups for each of the components, I will need to add inbound rules on the RDS Security Group to allow Lambda to connect. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oZ2QgwiV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t2c0cb0ezf24iu52wvef.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oZ2QgwiV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t2c0cb0ezf24iu52wvef.png" alt="RDS Security Group rule" width="800" height="255"&gt;&lt;/a&gt; While technically we can use IP address as the source, we want to allow all of the Lambda ENIs and the IP address may change in the future (added/removed), so it is better to use the Security Group ID of the Lambda as per the screenshot.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test Lambda to RDS Connectivity
&lt;/h2&gt;

&lt;p&gt;Now everything is ready, let's test this out by invoking the Lambda function. I'll do this via aws cli: &lt;code&gt;$ aws lambda invoke --function-name &amp;lt;function name&amp;gt; response.json&lt;/code&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YFMk2cH3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ad9s7fgsxwfeaqogi29.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YFMk2cH3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ad9s7fgsxwfeaqogi29.png" alt="Lambda Invoke" width="620" height="100"&gt;&lt;/a&gt; Let's double check the CloudWatch logs as well.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3FXY1VMc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bjgrmdia5ev6cwngosxh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3FXY1VMc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bjgrmdia5ev6cwngosxh.png" alt="Lambda CloudWatch logs" width="800" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Last thing is to check on the database itself to see if the schema has been successfully loaded by the Lambda function.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MWDoaxsL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/53l0gckbaz4uubcnfoxy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MWDoaxsL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/53l0gckbaz4uubcnfoxy.png" alt="Schema Load Check" width="800" height="363"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Everything looks to be working as expected! You may be wondering, will Lambda overload the RDS connectivity in this scenario? There's actually another AWS service that would be useful for this - Amazon RDS Proxy, see &lt;a href="https://aws.amazon.com/blogs/compute/using-amazon-rds-proxy-with-aws-lambda/"&gt;Using Amazon RDS Proxy with AWS Lambda&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  CloudFormation Template
&lt;/h2&gt;

&lt;p&gt;Want to test it out yourself? Feel free to use this &lt;a href="https://gist.github.com/bayupw/9d9e4af5d8317d3da27d357221f290d9"&gt;Lambda RDS Demo CloudFormation Template&lt;br&gt;
&lt;/a&gt; Note: this CFN template is for demo purposes only as it will output username, password, Database Connection URI which may be sensitive from security point of view.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion and Important Key Points
&lt;/h2&gt;

&lt;p&gt;As we can see, understanding cloud networking &amp;amp; security and their components is crucial when building cloud services, whether they're PaaS or managed. This is useful not just for planning or deployment, but also for troubleshooting, since we often need to figure out what are the building blocks and connectivity during a debug session. &lt;/p&gt;

&lt;p&gt;Here are some additional links that I find really useful in regards to connecting Lambda to RDS:&lt;br&gt;
&lt;a href="https://blog.thundra.io/can-lambda-and-rds-play-nicely-together"&gt;https://blog.thundra.io/can-lambda-and-rds-play-nicely-together&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/services-rds-tutorial.html"&gt;https://docs.aws.amazon.com/lambda/latest/dg/services-rds-tutorial.html&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I hope you enjoy reading this post and feel free to reach out if I have missed anything that you feel important!&lt;/p&gt;

</description>
      <category>aws</category>
      <category>rds</category>
      <category>lambda</category>
      <category>network</category>
    </item>
    <item>
      <title>How to Solve Overlapping IP Addresses in AWS</title>
      <dc:creator>Bayu Wibowo</dc:creator>
      <pubDate>Sat, 02 Jul 2022 23:58:02 +0000</pubDate>
      <link>https://forem.com/bayupw/how-to-solve-overlapping-ip-addresses-in-aws-1b9d</link>
      <guid>https://forem.com/bayupw/how-to-solve-overlapping-ip-addresses-in-aws-1b9d</guid>
      <description>&lt;p&gt;Recently, I got a chance to present at the &lt;a href="https://www.meetup.com/aws_nz/events/fwpcnsydchbhb/"&gt;Auckland AWS Community meetup&lt;/a&gt; to talk about &lt;a href="https://www.meetup.com/aws_nz/events/fwpcnsydchbhb/"&gt;"How to Solve Overlapping IP Addresses in AWS"&lt;/a&gt;. &lt;a href="https://github.com/bayupw/terraform-aviatrix-aws-overlapping-demo/raw/main/AWS%20Meetup%20-%20How%20to%20Solve%20Overlapping%20IP%20addresses%20in%20AWS.pdf"&gt;PDF slide deck is here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Every service, transaction, and everything you do with AWS or any public cloud uses networking. But it's quite common to see network and security design decisions made afterthoughts, which has led to overlapping IP addresses issues. But there are times when overlapping IP can't be avoided as well. &lt;/p&gt;

&lt;p&gt;In this post I'm going to share what those overlapping IP scenarios are, how we can solve the issue, and I hope everyone will find this helpful.&lt;/p&gt;

&lt;h2&gt;
  
  
  Overlapping IP Address Scenarios
&lt;/h2&gt;

&lt;p&gt;When organizations are starting to deploy services in the cloud and spin up VPCs, it's easy to fall into overlapping IPs between VPCs or with on-premises. There are a few common use cases where private networks with overlapping IP addresses need to be connected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NdFzdnIY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/65mx6n7twlc2ji7a7evd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NdFzdnIY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/65mx6n7twlc2ji7a7evd.png" alt="Overlapping IP address scenarios" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Connecting &lt;a href="https://docs.aws.amazon.com/vpc/latest/userguide/default-vpc.html"&gt;default VPCs&lt;/a&gt;. This may not necessarily be your VPC, but I've seen multiple organisations using the default VPC and they need to connect the two which is not possible out of the box.&lt;/p&gt;

&lt;p&gt;It's still possible for multiple VPC's to end up on the same CIDR block (e.g., 10.0.0.0/16, 192.168.0.0/16) whether it's within AWS or connecting another cloud provider. The reason could be mergers &amp;amp; acquisitions or connecting to other networks like third parties, partners, B2Bs.&lt;/p&gt;

&lt;p&gt;The most common scenario is when an organisation has cloud services and wants to deliver a service to a customer or partner using private IP addresses. They won't have the ability to ask their clients to change their IP space. &lt;/p&gt;

&lt;h2&gt;
  
  
  Solution Options to Overlapping IP Addresses
&lt;/h2&gt;

&lt;p&gt;During the meetup event, I discussed at least three possible solutions to this issue. This post will cover them at a high level, I may have to write separate posts to cover them in more detail.&lt;/p&gt;

&lt;h3&gt;
  
  
  1 | AWS Private Link
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://aws.amazon.com/privatelink/"&gt;AWS PrivateLink&lt;/a&gt; service has been around for a while, and it allows you to publish services from one VPC that you can access from another VPC. Through VPC Endpoint (VPCE), you can extend services behind an &lt;a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/network/introduction.html"&gt;NLB (Network Load Balancer)&lt;/a&gt; into a different VPC. PrivateLink is made up of NLB and VPCE. Few things to note, Private Link is uni-directional and only works with TCP traffic&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IT_-8Jjz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ri4k80hp7yz44c1qwc65.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IT_-8Jjz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ri4k80hp7yz44c1qwc65.png" alt="AWS Private Link" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's a sample terraform code that creates VPCs with overlapping IPs and connects them using Private Link: &lt;a href="https://github.com/bayupw/terraform-aws-overlapping-private-link-demo"&gt;https://github.com/bayupw/terraform-aws-overlapping-private-link-demo&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2 | AWS NAT Gateway
&lt;/h3&gt;

&lt;p&gt;Use &lt;a href="https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html"&gt;AWS NAT Gateway&lt;/a&gt; if PrivateLink isn't a feasible option, especially when you're having UDP traffic.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tqqfeyrd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rdii4c3kdu3tthwcs208.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tqqfeyrd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rdii4c3kdu3tthwcs208.gif" alt="AWS Private NAT Gateway" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To use AWS NAT Gateway, the services need to be created behind an ALB and published over a separate secondary VPC CIDR block that doesn't overlap. The secondary VPC CIDR blocks can then be connected using AWS Transit Gateway. Be sure to disable the route propagation as you don't want to advertise the overlapping IP spaces. One requirement for this solution is that the NAT Gateway needs to be deployed on the consumer VPC, which may not be feasible for some organisations. There's a blog post that covers it in detail here: &lt;a href="https://aws.amazon.com/blogs/networking-and-content-delivery/how-to-solve-private-ip-exhaustion-with-private-nat-solution/"&gt;https://aws.amazon.com/blogs/networking-and-content-delivery/how-to-solve-private-ip-exhaustion-with-private-nat-solution/&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Here's an example terraform code for deploying this solution: &lt;a href="https://github.com/bayupw/terraform-aws-overlapping-nat-gateway-demo"&gt;https://github.com/bayupw/terraform-aws-overlapping-nat-gateway-demo&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3 | Aviatrix Secure Cloud Networking Platform
&lt;/h3&gt;

&lt;p&gt;Another option is is to use Aviatrix to solve this overlapping IP issues. With Aviatrix gateways, you can solve overlapping IP addresses using an intelligent, flexible NAT solution. The Aviatrix Controller configures the routes to the AWS VPC route tables based on the Virtual CIDRs configuration. With this solution, all the NAT is done on the provider's end, so the consumer doesn't have to configure any complicated NAT.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xQ5vSYH5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ox5eei4iartdomlf76d7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xQ5vSYH5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ox5eei4iartdomlf76d7.png" alt="Aviatrix Overlapping IP" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's a sample terraform code to deploy the solution: &lt;a href="https://github.com/bayupw/terraform-aviatrix-aws-overlapping-demo"&gt;https://github.com/bayupw/terraform-aviatrix-aws-overlapping-demo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There's also a nicely written blog post written by &lt;a href="https://bradhedlund.com/"&gt;Brad Hedlund&lt;/a&gt; and AWS Solution Architects which covers this solution in detail from starting up the Aviatrix Controller, deploying the Aviatrix Gateways, configuring intelligent NAT, testing the traffic, and observing the traffic flow through Aviatrix CoPilot: &lt;a href="https://aws.amazon.com/blogs/awsmarketplace/how-to-solve-overlapping-ip-addresses-using-the-aviatrix-cloud-network-platform/"&gt;https://aws.amazon.com/blogs/awsmarketplace/how-to-solve-overlapping-ip-addresses-using-the-aviatrix-cloud-network-platform/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Besides solving overlapping IP issues, Aviatrix also provides additional features that organizations often need in an overlapping IP scenario, like the option for bi-directional traffic, policy-based segmentation, traffic inspection via Next-Generation Firewall and visibility of traffic flow regardless of the cloud provider. There was an Aviatrix TechTalk session which covered this overlapping scenario in a SaaS provider scenario with a nice demo.&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/XkOIYfI7EL0"&gt;
&lt;/iframe&gt;
&lt;br&gt;
Alternatively, you can read about the solution here: &lt;a href="https://aviatrix.com/resources/all-content/aviatrix-validated-design-saas-providers-infrastructure"&gt;https://aviatrix.com/resources/all-content/aviatrix-validated-design-saas-providers-infrastructure&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Those are the three options to solve overlapping IPs issues.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://aws.amazon.com/privatelink/"&gt;AWS PrivateLink&lt;/a&gt;: use this if you're only dealing with uni-directional TCP traffic&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.aws.amazon.com/vpc/latest/userguide/vpc-nat-gateway.html"&gt;AWS NAT Gateway&lt;/a&gt;: if PrivateLink isn't an option, you need UDP traffic and perhaps need to steer the traffic to a Security VPC, you can evaluate AWS NAT Gateway for hiding the overlapping IP space.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://aviatrix.com/learn-center/cloud-networking/handling-overlapping-ips/"&gt;Aviatrix&lt;/a&gt;: last but not least, if none of the other options work for you or you need extra features like visibility, network segmentation, policy-based traffic steering to a Next-Gen Firewall, which often required in a production enterprise network, I'd suggest exploring Aviatrix! 🙂&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mCvxSe8O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1isgavioqimp49qxolsq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mCvxSe8O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1isgavioqimp49qxolsq.png" alt="Summary" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope you found this article is informative and feel free to reach out if you have any questions!&lt;/p&gt;

</description>
      <category>aws</category>
      <category>networking</category>
      <category>overlapping</category>
      <category>aviatrix</category>
    </item>
    <item>
      <title>Learn and build AWS VPC Networking for Network Engineers</title>
      <dc:creator>Bayu Wibowo</dc:creator>
      <pubDate>Sat, 02 Jul 2022 21:25:19 +0000</pubDate>
      <link>https://forem.com/bayupw/learn-and-build-aws-vpc-networking-for-network-engineers-1fch</link>
      <guid>https://forem.com/bayupw/learn-and-build-aws-vpc-networking-for-network-engineers-1fch</guid>
      <description>&lt;p&gt;Many cloud projects forget Network Engineers and Network Architects and only bring them in afterward. Often, when network guys are in, things are already complicated and there's not much time for them to learn AWS from scratch. &lt;/p&gt;

&lt;p&gt;There are no prerequisites for AWS certifications anymore. So it's not mandatory to take the Associate certifications. I would still recommend taking at least the &lt;a href="https://aws.amazon.com/certification/certified-solutions-architect-associate/"&gt;AWS Solutions Architect Associate&lt;/a&gt; or even the &lt;a href="https://aws.amazon.com/certification/certified-cloud-practitioner/"&gt;Cloud Practitioner&lt;/a&gt; certification if you're new to cloud computing. In addition to AWS certification, Aviatrix offers a free course which covers an Intro to Public Networking in AWS through &lt;a href="https://aviatrix.teachable.com/"&gt;ACE-Associate&lt;/a&gt; as you can see below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wIPPKyut--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pjzgvcwm5xw1q1jnwwwz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wIPPKyut--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pjzgvcwm5xw1q1jnwwwz.png" alt="Intro to Public Cloud Networking in AWS" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's a good course on Cloud Networking whether or not you're considering Aviatrix. Here's the registration link and voucher code to make it free&lt;/p&gt;

&lt;p&gt;ACE-Associate registration link: &lt;a href="https://aviatrix.teachable.com/"&gt;https://aviatrix.teachable.com/&lt;/a&gt;&lt;br&gt;
Voucher code: &lt;strong&gt;AWSAKL&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To me, learning through practical experience or even parallel learning and building is the way I like to go. In this post, we'll learn and build networking constructs in AWS from scratch. Go ahead and create an AWS account or use an existing one if you want to follow along. If you're new to AWS, make sure to setup MFA to protect your account, see video below on how to setup MFA on your AWS account&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/e6A7z7FqQDE"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;We're going to use free resources as much as possible so you shouldn't be charged for anything. However, I'm not responsible for any charges you may incur. 🙂&lt;/p&gt;

&lt;h2&gt;
  
  
  VPC (Virtual Private Cloud)
&lt;/h2&gt;

&lt;p&gt;VPC is the foundation of AWS networking. Think of it like a logical data center you're building inside AWS. Similar to on-prem, before you can run a server or storage inside a data centre, you'll need a network switch and at least a network/subnet/VLAN to connect them. We will build from UI - ClickOps style and we'll explore using IaC tools like CloudFormation template or Terraform in other posts. So let's create a VPC and a CIDR block, and in this example, we'll create a VPC called "first-vpc" and we'll use "10.1.0.0/16" as our CIDR block. While you can use any IPv4 ranges, it is recommended to use the &lt;a href="http://www.faqs.org/rfcs/rfc1918.html"&gt;RFC1918 ranges&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Overall steps as follows:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Log on to AWS Console&lt;/li&gt;
&lt;li&gt;Select desired region &lt;/li&gt;
&lt;li&gt;Go to VPC&lt;/li&gt;
&lt;li&gt;Create VPC, enter VPC name (tag) and input CIDR block&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In this case, I'll be using Sydney (ap-southeast-2) region&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WE5wf0rM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/btpqaerzywu3plnmzr14.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WE5wf0rM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/btpqaerzywu3plnmzr14.PNG" alt="Select Region" width="348" height="220"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the search bar, type VPC and click the VPC hyperlink - you can click the star to add VPC into the &lt;a href="https://docs.aws.amazon.com/awsconsolehelpdocs/latest/gsg/add-remove-shortcut.html"&gt;favorites&lt;/a&gt; list/bar.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ez25JCiD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6q52llvudv1owrq9ixb0.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ez25JCiD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6q52llvudv1owrq9ixb0.PNG" alt="Search VPC" width="800" height="221"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If your using a new AWS account, you'll notice that there's an existing VPC also referred as the &lt;a href="https://docs.aws.amazon.com/vpc/latest/userguide/default-vpc.html"&gt;&lt;strong&gt;Default VPC&lt;/strong&gt;&lt;/a&gt; which is an Internet connected VPC, more about default VPC is documented here: &lt;a href="https://docs.aws.amazon.com/vpc/latest/userguide/default-vpc.html"&gt;https://docs.aws.amazon.com/vpc/latest/userguide/default-vpc.html&lt;/a&gt;. While you can use this VPC to deploy AWS services, it is recommended to create a custom VPC. Default VPC is also considered as a high severity in tfsec, see this link: &lt;a href="https://aquasecurity.github.io/tfsec/v1.8.0/checks/aws/vpc/no-default-vpc/"&gt;https://aquasecurity.github.io/tfsec/v1.8.0/checks/aws/vpc/no-default-vpc/&lt;/a&gt;. You can delete the default VPC if you're not planning to use it.&lt;/p&gt;

&lt;p&gt;Click the Create VPC button&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IheawjZC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/899prjzwqesnj8crhpfn.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IheawjZC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/899prjzwqesnj8crhpfn.PNG" alt="Create VPC" width="688" height="138"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;As we want to learn step by step and observe the components, choose the &lt;strong&gt;"VPC only"&lt;/strong&gt; option, we'll use the &lt;strong&gt;"VPC and more"&lt;/strong&gt; option later.&lt;br&gt;
Enter "first-vpc" as the name tag and "10.1.0.0/16" as the IPv4 CIDR. The "10.1.0.0/16" will be the primary IPv4 block and you can add a secondary IPv4 block e.g., "100.64.0.0/16". The use case of secondary CIDR block could be because you're running out of IPs and need to add additional block, or there's a VPC with overlapping CIDR which you need to peer or connect. See this blog post on how a secondary CIDR block is being used in an overlapping IP scenario: &lt;a href="https://aws.amazon.com/blogs/networking-and-content-delivery/how-to-solve-private-ip-exhaustion-with-private-nat-solution/"&gt;https://aws.amazon.com/blogs/networking-and-content-delivery/how-to-solve-private-ip-exhaustion-with-private-nat-solution/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8kYgaJ5Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ia0mt2qfjntmwftyyijw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8kYgaJ5Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ia0mt2qfjntmwftyyijw.png" alt="Create VPC - VPC only" width="800" height="734"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Leave the tags as default, you can add more tags if you want and click &lt;strong&gt;Create VPC&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--L3ZwmI81--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/smq687e6grmdhdr9c3tf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--L3ZwmI81--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/smq687e6grmdhdr9c3tf.png" alt="VPC tags" width="800" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As soon as the VPC is created, it's assigned with a vpc-id and there's a route table created that serves as the main route table - rtb-0b9c6e04cb2764aad in below example.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0PHzBoHc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3kod3hwxy8jm97ftowuy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0PHzBoHc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3kod3hwxy8jm97ftowuy.png" alt="VPC created" width="800" height="369"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Right click the rtb-id, open a new tab, and select the &lt;strong&gt;Routes&lt;/strong&gt; tab to observe the configuration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3q6qe94W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jdxo87xp1d4p6st4rjcd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3q6qe94W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jdxo87xp1d4p6st4rjcd.png" alt="RTB Routes" width="800" height="312"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The route table has a default local route which is used for communication within the VPC. If there's multiple CIDR blocks (secondary VPC CIDR), then you will have local route for each CIDR block as below example&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--T6y2FvWw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/to0kd7jhwd9hqt9h38n3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T6y2FvWw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/to0kd7jhwd9hqt9h38n3.png" alt="Multiple local routes" width="800" height="122"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you have a VPC and a route table, but you won't be able to put anything inside. If you try to create an EC2 instance for example, you can't proceed as it requires subnets.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XGJGL4N5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kviqoqcv1iei3gsbc43g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XGJGL4N5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kviqoqcv1iei3gsbc43g.png" alt="EC2 no subnets" width="800" height="316"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Subnets
&lt;/h2&gt;

&lt;p&gt;VPC can be created on a region basis, but a subnet where services run can only live in one availability zones (AZs). In order to offer services in multiple AZs, you'll need a subnet on each of them. For more details on regions and zones, check out this document:&lt;br&gt;
&lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html"&gt;https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html&lt;/a&gt;&lt;br&gt;
Let's create two subnets across two AZs as shown in below diagram (you can create more AZs if you want). The smallest subnet we can create is /28 with a total of 14 usable IP. 5 IP addresses are reserved by AWS as described in this document: &lt;a href="https://docs.aws.amazon.com/vpc/latest/userguide/configure-subnets.html#subnet-sizing"&gt;https://docs.aws.amazon.com/vpc/latest/userguide/configure-subnets.html#subnet-sizing&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OrepSaQE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tltjm3ncg30p6fsnhhay.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OrepSaQE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tltjm3ncg30p6fsnhhay.png" alt="Subnet diagram" width="800" height="693"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Subnet name&lt;/th&gt;
&lt;th&gt;AZ&lt;/th&gt;
&lt;th&gt;CIDR block&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;sydney-public1a&lt;/td&gt;
&lt;td&gt;ap-southeast-2a&lt;/td&gt;
&lt;td&gt;10.1.11.0/24&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;sydney-private1a&lt;/td&gt;
&lt;td&gt;ap-southeast-2a&lt;/td&gt;
&lt;td&gt;10.1.1.0/24&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;sydney-public2b&lt;/td&gt;
&lt;td&gt;ap-southeast-2b&lt;/td&gt;
&lt;td&gt;10.1.12.0/24&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;sydney-private2b&lt;/td&gt;
&lt;td&gt;ap-southeast-2b&lt;/td&gt;
&lt;td&gt;10.1.2.0/24&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Go to VPC &amp;gt; Subnets &amp;gt; Create Subnets and select the VPC that you've created previously - the &lt;strong&gt;"first-vpc"&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1qC7umHA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ezb7tm3yxmd73bnyuju.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1qC7umHA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ezb7tm3yxmd73bnyuju.png" alt="Create subnet" width="800" height="349"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enter the subnet settings detail. Don't click the &lt;strong&gt;"Create subnet"&lt;/strong&gt; button just yet, click the &lt;strong&gt;"Add new subnet"&lt;/strong&gt; button to add the remaining subnets then after completing all the required subnets, click &lt;strong&gt;"Create subnet"&lt;/strong&gt;&lt;br&gt;
Note: if you don't choose a zone, it will be randomly picked by AWS.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UDSxC8Qb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8env33z1k8x7t1scjeil.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UDSxC8Qb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8env33z1k8x7t1scjeil.png" alt="Subnet settings" width="800" height="758"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once done, you should see all the subnets you just created on the console. If you missed any, just create a subnet and select your desired VPC. As of now, you can deploy EC2 instances into the VPC by selecting one of the subnets, but the public subnet doesn't have any Internet access at this stage. When you select a public subnet &amp;gt; route, you'll see it uses the main route table and only has the local route, no default route for Internet access. &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iSTe-GTS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uddfu3y53386wbs4ypyy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iSTe-GTS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uddfu3y53386wbs4ypyy.png" alt="Public subnet route" width="800" height="443"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Public Subnets
&lt;/h2&gt;

&lt;p&gt;Technically, the subnets are still private. You'll need these to make it work as public subnets:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;An Internet Gateway (IGW) attached to the VPC&lt;/li&gt;
&lt;li&gt;Route table with default route towards the IGW&lt;/li&gt;
&lt;li&gt;Public IP assigned to the AWS resources (e.g., EC2 instances)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Go to VPC &amp;gt; Internet gateways and click &lt;strong&gt;"Create internet gateway"&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RCy9Wqs0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p8an7sn7j7um8unqd698.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RCy9Wqs0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p8an7sn7j7um8unqd698.png" alt="Create internet gateway button" width="800" height="180"&gt;&lt;/a&gt;&lt;br&gt;
Put a name tag and click create internet gateway&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PBLrEGBy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ztn379utiilhto535ds5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PBLrEGBy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ztn379utiilhto535ds5.png" alt="Create igw" width="800" height="637"&gt;&lt;/a&gt;&lt;br&gt;
Attach the IGW to the first-vpc &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UtXDHm_z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2wyptnxblcdmkhljmceg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UtXDHm_z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2wyptnxblcdmkhljmceg.png" alt="Attach IGW" width="800" height="310"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HzzXK9dE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/muockvmk01kj2kjzh7kg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HzzXK9dE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/muockvmk01kj2kjzh7kg.png" alt="Attach IGW 2" width="800" height="394"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We want the private subnets to be private, we don't want the private subnets to have a default route to the Internet. For that, we'll need to create a separate route table for the public subnets. Here's a diagram showing what we're trying to do.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9AtGThEE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r3d0zhdd1p9qiryh505j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9AtGThEE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r3d0zhdd1p9qiryh505j.png" alt="VPC diagram" width="800" height="462"&gt;&lt;/a&gt;&lt;br&gt;
Let's go to the route table menu and create a route table for the public subnets.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QhlCHWpA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zs5w7p62j678pf5ew0rs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QhlCHWpA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zs5w7p62j678pf5ew0rs.png" alt="Create route table" width="800" height="181"&gt;&lt;/a&gt;&lt;br&gt;
Put a name for the route table e.g., first-vpc-public-rtb and select the desired vpc - "first-vpc"&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8rFrbyu8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7rwn047xsmnzporz2t0n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8rFrbyu8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7rwn047xsmnzporz2t0n.png" alt="Create route table settings" width="800" height="733"&gt;&lt;/a&gt;&lt;br&gt;
Once created, edit the route table, add a default route to the IGW&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--U_x8uFuy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/534hk08sqyw3a3c2e1p7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U_x8uFuy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/534hk08sqyw3a3c2e1p7.png" alt="Add IGW route" width="800" height="239"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_X9ROTpl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hz98edmslr2ziisca3x7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_X9ROTpl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hz98edmslr2ziisca3x7.png" alt="IGW route added" width="800" height="279"&gt;&lt;/a&gt;&lt;br&gt;
Next, go to the &lt;strong&gt;"Subnet associations"&lt;/strong&gt; tab and click &lt;strong&gt;"Edit subnet associations"&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9ZSgYAF_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r5j93zndve3h5tymtjti.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9ZSgYAF_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r5j93zndve3h5tymtjti.png" alt="Edit subnet assoc" width="800" height="271"&gt;&lt;/a&gt;&lt;br&gt;
Select the public subnets and click &lt;strong&gt;"Save associations"&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_r8-2WvM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kasz7mouvigpzp0ao6t5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_r8-2WvM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kasz7mouvigpzp0ao6t5.png" alt="Save associations" width="800" height="308"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it! Now that the VPC is ready, you can run an EC2 instance in public subnets if they need Internet access or in private subnets if they don't.&lt;/p&gt;

&lt;p&gt;But let's create another VPC but now using the other option which will create required route tables and internet gateway for us. Create a New VPC and choose &lt;strong&gt;"VPC and more"&lt;/strong&gt; this time&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jBTPamkH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v6ez562yy7tos9gsg2we.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jBTPamkH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v6ez562yy7tos9gsg2we.png" alt="Create VPC and more" width="800" height="328"&gt;&lt;/a&gt;&lt;br&gt;
We'll create using below parameters&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Parameters&lt;/th&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Name tag (auto-generate)&lt;/td&gt;
&lt;td&gt;second&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;IPv4 CIDR block&lt;/td&gt;
&lt;td&gt;10.2.0.0/16&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Number of AZs&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;First AZ&lt;/td&gt;
&lt;td&gt;ap-southeast-2a&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Second AZ&lt;/td&gt;
&lt;td&gt;ap-southeast-2b&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Public subnet first AZ&lt;/td&gt;
&lt;td&gt;10.2.11.0/24&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Public subnet second AZ&lt;/td&gt;
&lt;td&gt;10.2.12.0/24&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Private subnet first AZ&lt;/td&gt;
&lt;td&gt;10.2.1.0/24&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Private subnet second AZ&lt;/td&gt;
&lt;td&gt;10.2.2.0/24&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;NAT gateways&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Enable DNS hostnames&lt;/td&gt;
&lt;td&gt;Checked (default)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Enable DNS resolution&lt;/td&gt;
&lt;td&gt;Checked (default)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Hit &lt;strong&gt;"Create VPC"&lt;/strong&gt; once completed, you can see that the wizard will create all of the required components similar to what we've created for the first-vpc.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uPwFlZ-t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rmgq63u6kjlbo2cnsq7a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uPwFlZ-t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rmgq63u6kjlbo2cnsq7a.png" alt="Second-vpc creation" width="751" height="752"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you have two VPCs and they are ready to take on workloads as shown in below diagram:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--z4u8a1J7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0xtlgv1gunecn6erl6o5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--z4u8a1J7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0xtlgv1gunecn6erl6o5.png" alt="Two VPCs" width="750" height="1041"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope this post helps you better understand AWS and cloud networking, especially some of the foundation of VPC networking. We haven't touched on security groups, NACL, how to give egress Internet access to the private subnets, how to connect VPCs, how to automate the build and manage the resources using IaC, I'll save that for future posts. Watch this space!&lt;/p&gt;

&lt;p&gt;References: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html"&gt;https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/vpc/faqs/"&gt;https://aws.amazon.com/vpc/faqs/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Route_Tables.html"&gt;https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Route_Tables.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/vpc/latest/userguide/configure-subnets.html"&gt;https://docs.aws.amazon.com/vpc/latest/userguide/configure-subnets.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>networking</category>
      <category>vpc</category>
      <category>aws</category>
    </item>
  </channel>
</rss>
