FIX: bug fix

This commit is contained in:
xpk 2022-08-05 16:03:12 +08:00
parent d64630e924
commit be755a4b8d
Signed by: xpk
GPG Key ID: CD4FF6793F09AB86

View File

@ -7,14 +7,13 @@ if [ "${vpc}" = "null" ]; then
exit 0 exit 0
fi fi
aws ec2 --region ${region} describe-internet-gateways --filter Name=attachment.vpc-id,Values=${vpc} aws ec2 --region ${region} describe-internet-gateways --filter Name=attachment.vpc-id,Values=${vpc} | jq -r '.InternetGateways[0].InternetGatewayId' | while read igw; do
| jq -r .InternetGateways[0].InternetGatewayId | while read igw; do
echo "Removing internet gateway ${igw}" echo "Removing internet gateway ${igw}"
aws ec2 --region ${region} detach-internet-gateway --internet-gateway-id ${igw} --vpc-id ${vpc} 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} aws ec2 --region ${region} delete-internet-gateway --internet-gateway-id ${igw}
done done
aws ec2 --region ${region} describe-subnets --filters Name=vpc-id,Values=${vpc} | jq -r .Subnets[].SubnetId) | while read subnet; do aws ec2 --region ${region} describe-subnets --filters Name=vpc-id,Values=${vpc} | jq -r '.Subnets[].SubnetId' | while read subnet; do
echo "Removing subnet ${subnet}" echo "Removing subnet ${subnet}"
aws ec2 --region ${region} delete-subnet --subnet-id ${subnet} aws ec2 --region ${region} delete-subnet --subnet-id ${subnet}
done done
@ -22,4 +21,3 @@ done
echo "Removing vpc ${vpc}" echo "Removing vpc ${vpc}"
aws ec2 --region ${region} delete-vpc --vpc-id ${vpc} aws ec2 --region ${region} delete-vpc --vpc-id ${vpc}