VPC Setup for Lambda Function#
On this page, you can read the instructions on how to configure the Security Group for a relational database (RDS) on AWS.

Go to the VPC console.
In the side navigation pane, click Subnets >> Create subnet.
Choose your VPC ID.
Name your subnet, e.g. lambda-private.
In IPv4 CIDR block field, select the IP address that is not in use in your VPC. IPv4 CIDRs is provided in the VPC section under Associated VPC CIDRs.
Leave the other fields unchanged.
Click Create subnet.
Follow the same process with creating another subnet, but call it lambda-public, and provide a unique IPv4 address.
Locate your lambda-public Subnet ID and click on it.
To change the Auto-assign public IPv4 address value from no to yes, click Actions in the right corner.
Click Edit subnet settings.
Check the Enable auto-assign public IPv4 address box and hit Save.
On the left sidebar, select NAT gateways and click Create NAT gateway.
Name your NAT gateway, e.g. lambda-nat.
Select your lambda-public subnet (or rather your equivalent subnet name).
Click on the Allocate Elastic IP button.
Click Create NAT gateway.
In the side navigation pane, select Route tables and click Create route table.
Name your route table, e.g. lambda-nat (private route table).
Select your VPC from the drop-down menu.
Click Create route table.
Associate the lambda-nat route with the private subnet (lambda-private in our case) by clicking on Edit routes.
Click Add route with the value 0.0.0.0/0 that will allow you to go to any destination in the Destination column.
In the Target column, select Nat Gateway >> lambda-nat.
In your route table ID, click on Subnet associations >> Edit subnet associations.
Click on your private subnet (lambda-private in our case) and hit Save association.
Follow the same process with creating another route table, but call it public-internet, choose select Internet Gateway >> {public network} (you will only have one starting with igw-) in the Target column upon editing the route table, and associate it with a public subnet (lambda-public in our case).