This repository contains commands for creating basic network structure which contains private, public subnet within single VPC. Before executing commands in execute section, IAM user with Administrator authority(ex. admin.kim) has to be prepared after following instructions explained in this page. Then, corresponding access key and password has to be configured into local configuration file using aws configure
command.
Execution environment setup
python3 --version # Python 3.10.10
python3 -m venv venv
source venv/bin/activate
pip3 install typer==0.9.0 boto3==1.26.140
If administrator user profile is configured, use name of the profile as parameter of --profile-name
argument. For example, every command below uses configured credential that corresponds to admin.kim
.
- create a VPC
- create configured security group and attach it to created VPC
- create internet gateway and attach it to created VPC
python main.py configure-vpc \
--profile-name=admin.kim \
--region=ap-northeast-2 \
--vpc-name=prod \
--vpc-cidr=172.20.0.0/16 \
--sg-name=prod-sg \
--igw-name=prod-igw
To create public subnet within VPC, use --is-public
option.
- create a subnet
- create route table and add route to internet gateway
- associate created subnet with created route table
python main.py configure-subnet \
--profile-name=admin.kim \
--vpc-name=prod \
--subnet-name=pub-a \
--cidr-substitute=100 \
--availability-zone-postfix=a \
--route-table-name=rt-pub-a \
--is-public
To create private subnet within VPC, use --no-is-public
option.
- create a subnet
- create a route table
- associate created subnet with created route table
python main.py configure-subnet \
--profile-name=admin.kim \
--vpc-name=prod \
--subnet-name=prv-c \
--cidr-substitute=101 \
--availability-zone-postfix=c \
--route-table-name=rt-prv-c \
--no-is-public
Delete objects in reverse order of their creation.
- delete association between subnet and route table
- delete the route table
- delete the subnet
python main.py remove-subnet \
--profile-name=admin.kim \
--subnet-name=pub-a
Delete objects in reverse order of their creation.
- detach internet gateway from VPC and delete it
- delete security group
- delete VPC
python main.py remove-vpc \
--profile-name=admin.kim \
--vpc-name=prod