1
0

initial commit

This commit is contained in:
xpk
2026-02-13 15:44:24 +08:00
parent 66be8224f4
commit 09ce4c881a
570 changed files with 61807 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
#!/bin/bash
region=$1
vpc=$(aws ec2 --region ${region} describe-vpcs --filter Name=isDefault,Values=true | jq -r .Vpcs[0].VpcId)
if [ "${vpc}" = "null" ]; then
echo "No default vpc found"
exit 0
fi
aws ec2 --region ${region} describe-internet-gateways --filter Name=attachment.vpc-id,Values=${vpc} | jq -r '.InternetGateways[0].InternetGatewayId' | while read igw; do
echo "Removing internet gateway ${igw}"
aws ec2 --region ${region} detach-internet-gateway --internet-gateway-id ${igw} --vpc-id ${vpc}
aws ec2 --region ${region} delete-internet-gateway --internet-gateway-id ${igw}
done
aws ec2 --region ${region} describe-subnets --filters Name=vpc-id,Values=${vpc} | jq -r '.Subnets[].SubnetId' | while read subnet; do
echo "Removing subnet ${subnet}"
aws ec2 --region ${region} delete-subnet --subnet-id ${subnet}
done
echo "Removing vpc ${vpc}"
aws ec2 --region ${region} delete-vpc --vpc-id ${vpc}