In most cases, your VPC needs to have a connection with the public internet. In this case, you need to create an IGW (internet gateway) to attach to your VPC.
In the following example, an IGW is created and attached to vpc-66eda61f:
//create IGW, it returns IGW id as igw-c3a695a5 $ aws ec2 create-internet-gateway { "InternetGateway": { "Tags": [], "InternetGatewayId": "igw-c3a695a5", "Attachments": [] } } //attach igw-c3a695a5 to vpc-66eda61f $ aws ec2 attach-internet-gateway --vpc-id vpc-66eda61f --internet-gateway-id igw-c3a695a5
Once the IGW is attached, then set a routing table (default gateway) for a subnet that points to the IGW. If a default gateway points to an IGW, this subnet is able to have a public ...