How To Create A Custom VPC Using AWS CLI
- Mohammad Abu Mattar
- Cloud Computing
- 15 Oct, 2022
- 02 Mins read
Introduction
In the sample that follows, an IPv4 CIDR block, a public subnet, and a private subnet are all created using AWS CLI instructions. You can run an instance in the public subnet and connect to it once the VPC and subnets have been configured. Additionally, you may start an instance on the private subnet and link to it from the instance on the public network.
Prerequisites
- AWS CLI
- AWS Account
Configure AWS CLI: aws configure
Create a VPC
Modify your custom VPC and enable DNS hostname support
Create a public subnet
NOTE: Availability zones:
us-east-1a
,us-east-1b
,us-east-1c
,us-east-1d
,us-east-1e
,us-east-1f
.
Enable Auto-assign Public IP on the subnet
Create an Internet Gateway
Attach the Internet gateway to your VPC
Create a custom route table
Associate the subnet with route table, making it a public subnet
Get security group ID’s
Add tags to the resources in your VPC
Delete the VPC (Cleanup)
References
- AWS CLI
- AWS CLI - Install
- AWS CLI - Configure
- AWS CLI - Create VPC
- AWS CLI - Modify VPC
- AWS CLI - Create Subnet
- AWS CLI - Modify Subnet
- AWS CLI - Create Internet Gateway
- AWS CLI - Attach Internet Gateway
- AWS CLI - Create Route Table
- AWS CLI - Associate Route Table
- AWS CLI - Describe Security Groups
- AWS CLI - Create Tags
- AWS CLI - Delete Security Group