To provide both incoming and outgoing connectivity to the internet for EC2 instances, you need to ensure that the instances are in a subnet that has a route to an internet gateway. Here are the required steps:
Create an Internet Gateway:
Open the Amazon VPC console at Amazon VPC Console.
In the navigation pane, choose Internet Gateways.
Choose Create Internet Gateway.
Enter a name for the internet gateway and choose Create.
Attach the internet gateway to your VPC by selecting the created internet gateway, then choosing Actions, and Attach to VPC.
Modify Route Table:
In the Amazon VPC console, go to the Route Tables section.
Select the route table associated with the subnet where your EC2 instances are located.
Choose Edit routes and add a new route:
Destination: 0.0.0.0/0
Target: Select the internet gateway you created.
These steps ensure that the instances can send and receive traffic to and from the internet.
Creating and Attaching an Internet Gateway
Route Tables
Submit