Skip to content

Instantly share code, notes, and snippets.

@smcelhinney
Created December 4, 2020 12:05
Show Gist options
  • Save smcelhinney/7a681101a345af7e757cb701276c4b02 to your computer and use it in GitHub Desktop.
Save smcelhinney/7a681101a345af7e757cb701276c4b02 to your computer and use it in GitHub Desktop.
Creating new subnets AWS
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