Created
December 4, 2020 12:05
-
-
Save smcelhinney/7a681101a345af7e757cb701276c4b02 to your computer and use it in GitHub Desktop.
Creating new subnets AWS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VPC_ID=<your-vpc-id> | |
SUBNET_CIDR_BLOCK=10.0.96.0/24 | |
AVAILABILITY_ZONE=us-east-1f | |
SUBNET_NAME="private-lambda-$AVAILABILITY_ZONE" | |
SUBNET_CREATE_RESPONSE=$(aws ec2 create-subnet \ | |
--cidr-block "$SUBNET_CIDR_BLOCK" \ | |
--availability-zone "$AVAILABILITY_ZONE" \ | |
--vpc-id "$VPC_ID" \ | |
--output json) | |
SUBNET_ID=$(echo -e "$SUBNET_CREATE_RESPONSE" | jq '.Subnet.SubnetId' | tr -d '"') | |
#name the subnet | |
aws ec2 create-tags \ | |
--resources "$SUBNET_ID" \ | |
--tags Key=Name,Value="$SUBNET_NAME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment