Created
November 2, 2023 17:18
-
-
Save netologist/f70938a35203833f72e5d865f24f8967 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# Define your CIDR block | |
CIDR_BLOCK="10.0.0.0/16" | |
# Create VPC and store the VPC ID | |
VPC_ID=$(aws ec2 create-vpc --cidr-block $CIDR_BLOCK --query 'Vpc.VpcId' --output text) | |
# Check if VPC_ID is not empty | |
if [ -z "$VPC_ID" ]; then | |
echo "Failed to create VPC" | |
exit 1 | |
fi | |
echo "Created VPC with ID: $VPC_ID" | |
# Enable DNS Hostnames | |
aws ec2 modify-vpc-attribute --vpc-id $VPC_ID --enable-dns-hostnames "{\"Value\":true}" | |
# Enable DNS Support | |
aws ec2 modify-vpc-attribute --vpc-id $VPC_ID --enable-dns-support "{\"Value\":true}" | |
echo "DNS hostnames and support enabled for VPC with ID: $VPC_ID" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment