AWS CLI에서 VPC의 네트워크 환경을 구축하는 방법

2199 단어 vpc
이런 식으로 하고 싶다



VPC 만들기


aws ec2 create-vpc --cidr-block 10.0.0.0/16
aws ec2 create-tags --resources vpc-XXXXXXXX --tags Key=Name,Value=sample-vpc

gateway 서브넷 측 설정



서브넷 생성


aws ec2 create-subnet --vpc-id vpc-XXXXXXXX --cidr-block 10.0.0.0/24
aws ec2 create-tags --resources subnet-gwXXXXXX --tags Key=Name,Value=sample-vpc-gw

인터넷 게이트웨이 만들기 ~ VPC에 연결


aws ec2 create-internet-gateway
aws ec2 create-tags --resources igw-XXXXXXXX --tags Key=Name,Value=sample-vpc-igw
aws ec2 attach-internet-gateway --vpc-id vpc-XXXXXXXX --internet-gateway-id igw-XXXXXXXX

라우팅 테이블 만들기


aws ec2 create-route-table --vpc-id vpc-XXXXXXXX
aws ec2 create-tags --resources rtb-gwXXXXXX --tags Key=Name,Value=sample-vpc-gw-rtb
aws ec2 create-route --route-table-id rtb-gwXXXXXX --destination-cidr-block 0.0.0.0/0 --gateway-id igw-XXXXXXXX
aws ec2 associate-route-table --subnet-id subnet-gwXXXXXX --route-table-id rtb-gwXXXXXX

NAT 게이트웨이 생성


aws ec2 allocate-address --domain vpc
aws ec2 create-nat-gateway --subnet-id subnet-gwXXXXXX --allocation-id eipalloc-XXXXXXXX
aws ec2 create-tags --resources nat-XXXXXXXXXXXXXXXXX --tags Key=Name,Value=sample-vpc-nat-gw

서비스 측 서브넷 생성



서브넷 생성


aws ec2 create-subnet --vpc-id vpc-XXXXXXXX --cidr-block 10.255.1.0/24
aws ec2 create-tags --resources subnet-service1X --tags Key=Name,Value=sample-vpc-service1

라우팅 테이블 만들기


aws ec2 create-route-table --vpc-id vpc-XXXXXXXX
aws ec2 create-tags --resources rtb-serviceXX --tags Key=Name,Value=sample-vpc-service1-rtb
aws ec2 create-route --route-table-id rtb-serviceXX --destination-cidr-block 0.0.0.0/0 --nat-gateway-id nat-XXXXXXXXXXXXXXXXX
aws ec2 associate-route-table --subnet-id subnet-service1X --route-table-id rtb-serviceXX

좋은 웹페이지 즐겨찾기