Without Transit Gateway
With Transit Gateway
Routing Sample:
Here we are doing the setup of Transite gateway on same aws account across three diffrent VPC's.
Demo Setup:
Steps:
-
Create 3 VPC's and public and private subnets using below cloud formation tempalates.
aws cloudformation --region us-east-2 create-stack --stack-name vpc1 --template-body file://vpc1_cfn.yaml aws cloudformation --region us-east-2 create-stack --stack-name vpc2 --template-body file://vpc2_cfn.yaml aws cloudformation --region us-east-2 create-stack --stack-name vpc3 --template-body file://vpc3_cfn.yaml
-
Now create EC2 instance in each VPC's private subnet.
- Now will create transit gateway in default VPC
Uder VPC --> Transit Gateways --> create transit gateway
Keep all default options as it is.
- Create transit gateway attachment to all 3 vpc's
Goto VPC --> TRANSIT GATEWAYS --> Transit gateway attachments --> Create transit gateway attachment
Select private subnet.
Follow the same process for remaining two VPC's.
- Now will add Route Table entry for all 3 vpc Transit Gateway in respective VPC's private subnet route table.
For now we have added route from VPC1 to VPC2 and in VPC2 to VPC1
Now connect to private EC2 instance in VPC1 using session manager and try to do ssh. In the initial check I have not added route so it was giving timeout, later I added route then its started working.
Currently we dont have route from VPC2 to VPC3 so if we try to do ssh from vpc2 to vpc3 EC2 instance we should get error.
Now add the routes as below for all VPC's.