Created
May 28, 2025 13:58
-
-
Save cablehead/c5122f2ab7bbcd0e0ad076ffbd2f3bff 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
| # Create VPC | |
| VPC_ID=$(aws ec2 create-vpc \ | |
| --cidr-block 10.0.0.0/28 \ | |
| --tag-specifications 'ResourceType=vpc,Tags=[{Key=Project,Value=vibenv}]' \ | |
| --query 'Vpc.VpcId' \ | |
| --output text) | |
| # Disable DNS Support and Hostnames | |
| aws ec2 modify-vpc-attribute --vpc-id $VPC_ID --enable-dns-support "{\"Value\": false}" | |
| aws ec2 modify-vpc-attribute --vpc-id $VPC_ID --enable-dns-hostnames "{\"Value\": false}" | |
| # Create Internet Gateway | |
| IGW_ID=$(aws ec2 create-internet-gateway \ | |
| --tag-specifications 'ResourceType=internet-gateway,Tags=[{Key=Project,Value=vibenv}]' \ | |
| --query 'InternetGateway.InternetGatewayId' \ | |
| --output text) | |
| # Attach Internet Gateway to VPC | |
| aws ec2 attach-internet-gateway --vpc-id $VPC_ID --internet-gateway-id $IGW_ID | |
| # Create Subnet | |
| SUBNET_ID=$(aws ec2 create-subnet \ | |
| --vpc-id $VPC_ID \ | |
| --cidr-block 10.0.0.0/28 \ | |
| --availability-zone ca-central-1a \ | |
| --tag-specifications 'ResourceType=subnet,Tags=[{Key=Project,Value=vibenv}]' \ | |
| --query 'Subnet.SubnetId' \ | |
| --output text) | |
| # Create Route Table | |
| ROUTE_TABLE_ID=$(aws ec2 create-route-table \ | |
| --vpc-id $VPC_ID \ | |
| --tag-specifications 'ResourceType=route-table,Tags=[{Key=Project,Value=vibenv}]' \ | |
| --query 'RouteTable.RouteTableId' \ | |
| --output text) | |
| # Associate Subnet with Route Table | |
| aws ec2 associate-route-table --route-table-id $ROUTE_TABLE_ID --subnet-id $SUBNET_ID | |
| # Create Route to Internet Gateway | |
| aws ec2 create-route \ | |
| --route-table-id $ROUTE_TABLE_ID \ | |
| --destination-cidr-block 0.0.0.0/0 \ | |
| --gateway-id $IGW_ID | |
| # Create Security Group | |
| SG_ID=$(aws ec2 create-security-group \ | |
| --group-name vibenv-ssh-only \ | |
| --description "SSH access from specific IP" \ | |
| --vpc-id $VPC_ID \ | |
| --tag-specifications 'ResourceType=security-group,Tags=[{Key=Project,Value=vibenv}]' \ | |
| --query 'GroupId' \ | |
| --output text) | |
| # Add SSH Ingress Rule | |
| aws ec2 authorize-security-group-ingress \ | |
| --group-id $SG_ID \ | |
| --protocol tcp \ | |
| --port 22 \ | |
| --cidr 38.147.250.103/32 | |
| # Output key details | |
| echo "VPC ID: $VPC_ID" | |
| echo "Subnet ID: $SUBNET_ID" | |
| echo "Security Group ID: $SG_ID" | |
| echo "Internet Gateway ID: $IGW_ID" | |
| echo "Route Table ID: $ROUTE_TABLE_ID" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment