Skip to content

exporting traffic from private VPC using public VPC connected by transit gateway

0

I have 2 VPC's sitting on different accounts, VPC A (private) sits on account A, and is connected to transit gateway that sits on account B suing transit gateway attachment. VPC B (public) sits on account B, where the transit gateway is. The transit gateway works (we have another VPC on account B that works that way), we tried creating internet gateway in the VPC B, (including all the route tables, etc.), we tried to use NAT but it requires a specific subnet (and we have 3 of those). So basically we failed to connect VPC A to the internet.

How should we do it?

2 Answers
3

The scenario you have described should work. Please see the example below: Centralized outbound routing to the internet:

https://docs.aws.amazon.com/vpc/latest/tgw/transit-gateway-nat-igw.html

AWS
EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

EXPERT

reviewed 2 years ago

2

Hello,

please try this steps it will be helpful for you & please look at AWS Document link you will get more information.

https://docs.aws.amazon.com/vpc/latest/tgw/transit-gateway-nat-igw.html

STEPS VPC A is private and located in Account A. VPC B is public, contains an Internet Gateway (IGW), and is located in Account B with the TGW. TGW is in Account B and connects both VPC A and VPC B.

Steps to Achieve Internet Access from VPC A:

1. Ensure Transit Gateway Attachments

VPC A Attachment: Ensure VPC A is attached to the TGW in Account B. VPC B Attachment: Ensure VPC B is attached to the TGW in Account B.

2. Configure Route Tables

VPC A (Private VPC in Account A) Route Table for Private Subnets: Route: 0.0.0.0/0 Target: Transit Gateway (TGW Attachment ID for VPC A)

VPC B (Public VPC in Account B) Route Table for Public Subnets: Route: 0.0.0.0/0 Target: Internet Gateway (IGW)

Transit Gateway Route Table

TGW Route Table: Route: CIDR of VPC A Target: TGW Attachment ID for VPC A Route: 0.0.0.0/0 Target: TGW Attachment ID for VPC B

3. Configure Security Groups

VPC A Security Groups:

Allow outbound traffic to the internet.

VPC B Security Groups:

Allow inbound and outbound traffic from VPC A and the internet.

Example Configuration

  1. Route Table for VPC A Private Subnets Go to the VPC console in Account A. Navigate to Route Tables. Select the route table associated with the private subnets. Add the following route: Destination: 0.0.0.0/0 Target: TGW Attachment ID for VPC A

  2. Route Table for VPC B Public Subnets Go to the VPC console in Account B. Navigate to Route Tables. Select the route table associated with the public subnets. Ensure the following route exists: Destination: 0.0.0.0/0 Target: Internet Gateway (IGW)

Transit Gateway Route Table

Go to the TGW console in Account B. Navigate to Route Tables. Select the route table associated with the TGW. Add the following routes: Destination: CIDR of VPC A Target: TGW Attachment ID for VPC A Destination: 0.0.0.0/0 Target: TGW Attachment ID for VPC B

Test:

Launch an EC2 Instance in VPC A (in the private subnet). Test Internet Access: Try to ping a public IP or resolve a domain name to ensure internet connectivity.

EXPERT

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.