Bobcares

Add Routes to Main Route Table in VPC

by | Oct 20, 2021

We can use AWS CloudFormation to add routes to the main route table in VPC.

Here, at Bobcares, we assist our customers with several VPC queries as part of our AWS Support Services.

Today, let us see how our techs add the same.

 

Add Routes to Main Route Table in VPC

A main route table is created when we create a VPC using AWS CloudFormation. AWS CloudFormation fails to recognize this route table.

This means we cannot pass information about the routing table between the VPC and AWS CloudFormation.

Since we can’t reference the main route table from the AWS CloudFormation template we fail to add or remove routes from the main route table.

To resolve this, we use an AWS Lambda-backed custom resource in an AWS CloudFormation template.

This template will use a Lambda function to retrieve the main route table ID associated with the VPC.

Moving ahead, let us see the steps our Support Techs employ to perform the same.

1. Initially, we download the RouteTable.template and Routetable.py files from the AWS GitHub repository.

2. Then we create a zip file called Routetable.zip for the Lambda function.

For example, like the following:

-> Routetable.zip
|
|-> Routetable.py

However, make sure that the location of the Routetable.py is at the root level of the zip file.

3. After that, we upload the zip file to an Amazon S3 bucket that’s in the same AWS Region as the AWS CloudFormation stack with the Amazon S3 console.

Now, we need to upload the zip file using the AWS CLI. To do so, from the Routetable.zip folder we run:

aws s3 cp ./Routetable.zip s3://awsexamplebucket1/Routetable.zip

4. Later, to launch the stack with the RouteTable.template file, we use the AWS CloudFormation console or run:

aws cloudformation create-stack --stack-name myvpcstack --template-body file://RouteTable.template --parameters ParameterKey=Bucket,ParameterValue=awsexamplebucket1 ParameterKey=Key,ParameterValue=Routetable.zip ParameterKey=Lambdahandler,ParameterValue=Routetable --capabilities CAPABILITY_NAMED_IAM --region us-east-1

Make sure to pass the name of the Amazon S3 bucket, the zip file name, and the name of the file where we created the Lambda function as parameters when we create or update the AWS CloudFormation stack.

[Need further assistance? We are here for you]

 

Conclusion

In short, we saw how our Support Techs add routes to main route tables.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.