Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Creating VPC + 1 public subnet + 2 private subnet using CLI tools
- =================================================================
- set comando=aws ec2 create-vpc --cidr-block 10.50.0.0/16 --query Vpc.VpcId
- FOR /F "tokens=* USEBACKQ" %F IN (`%comando%`) DO SET vpc=%F
- aws ec2 create-tags --resources %vpc% --tags Key=Name,Value=cntgvpc
- aws ec2 create-tags --resources %vpc% --tags Key=Proyecto,Value=cntg
- set comando=aws ec2 create-subnet --vpc-id %vpc% --availability-zone us-west-2a --cidr-block 10.50.0.0/24 --query Subnet.SubnetId
- FOR /F "tokens=* USEBACKQ" %F IN (`%comando%`) DO SET subnetPrivA=%F
- aws ec2 create-tags --resources %subnetPrivA% --tags Key=Name,Value=subnetPrivA
- aws ec2 create-tags --resources %subnetPrivA% --tags Key=Proyecto,Value=cntg
- set comando=aws ec2 create-subnet --vpc-id %vpc% --availability-zone us-west-2b --cidr-block 10.50.1.0/24 --query Subnet.SubnetId
- FOR /F "tokens=* USEBACKQ" %F IN (`%comando%`) DO SET subnetPrivB=%F
- aws ec2 create-tags --resources %subnetPrivB% --tags Key=Name,Value=subnetPrivB
- aws ec2 create-tags --resources %subnetPrivB% --tags Key=Proyecto,Value=cntg
- set comando=aws ec2 create-subnet --vpc-id %vpc% --availability-zone us-west-2a --cidr-block 10.50.2.0/24 --query Subnet.SubnetId
- FOR /F "tokens=* USEBACKQ" %F IN (`%comando%`) DO SET subnetPubA=%F
- aws ec2 create-tags --resources %subnetPubA% --tags Key=Name,Value=subnetPubA
- aws ec2 create-tags --resources %subnetPubA% --tags Key=Proyecto,Value=cntg
- set comando=aws ec2 create-internet-gateway --query InternetGateway.InternetGatewayId
- FOR /F "tokens=* USEBACKQ" %F IN (`%comando%`) DO SET igw=%F
- aws ec2 create-tags --resources %igw% --tags Key=Name,Value=igw
- aws ec2 create-tags --resources %igw% --tags Key=Proyecto,Value=cntg
- aws ec2 attach-internet-gateway --internet-gateway-id %igw% --vpc-id %vpc%
- set comando=aws ec2 create-route-table --vpc-id %vpc% --query RouteTable.RouteTableId
- FOR /F "tokens=* USEBACKQ" %F IN (`%comando%`) DO SET rtPub=%F
- aws ec2 create-tags --resources %rtPub% --tags Key=Name,Value=rtPub
- aws ec2 create-tags --resources %rtPub% --tags Key=Proyecto,Value=cntg
- aws ec2 create-route --route-table-id %rtPub% --destination-cidr-block "0.0.0.0/0" --gateway-id %igw%
- set comando=aws ec2 associate-route-table --subnet-id %subnetPubA% --route-table-id %rtPub% --query AssociationId
- FOR /F "tokens=* USEBACKQ" %F IN (`%comando%`) DO SET assRtPub=%F
- set comando=aws ec2 allocate-address --domain vpc --query AllocationId
- FOR /F "tokens=* USEBACKQ" %F IN (`%comando%`) DO SET natEip=%F
- set comando=aws ec2 create-nat-gateway --subnet-id %subnetPubA% --allocation-id %natEip% --query NatGateway.NatGatewayId
- FOR /F "tokens=* USEBACKQ" %F IN (`%comando%`) DO SET natgw=%F
- set comando=aws ec2 create-route-table --vpc-id %vpc% --query RouteTable.RouteTableId
- FOR /F "tokens=* USEBACKQ" %F IN (`%comando%`) DO SET rtPriv=%F
- aws ec2 create-tags --resources %rtPriv% --tags Key=Name,Value=rtPriv
- aws ec2 create-tags --resources %rtPriv% --tags Key=Proyecto,Value=cntg
- aws ec2 create-route --route-table-id %rtPriv% --destination-cidr-block "0.0.0.0/0" --nat-gateway-id %natgw%
- set comando=aws ec2 associate-route-table --subnet-id %subnetPrivA% --route-table-id %rtPriv% --query AssociationId
- FOR /F "tokens=* USEBACKQ" %F IN (`%comando%`) DO SET assRtPrivA=%F
- set comando=aws ec2 associate-route-table --subnet-id %subnetPrivB% --route-table-id %rtPriv% --query AssociationId
- FOR /F "tokens=* USEBACKQ" %F IN (`%comando%`) DO SET assRtPrivB=%F
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement