From be755a4b8deb42f348ab421948763a0f97f7dc25 Mon Sep 17 00:00:00 2001 From: xpk Date: Fri, 5 Aug 2022 16:03:12 +0800 Subject: [PATCH] FIX: bug fix --- modules/networking/delete-default-vpcs/exec.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/networking/delete-default-vpcs/exec.sh b/modules/networking/delete-default-vpcs/exec.sh index 2db118e..db63db5 100755 --- a/modules/networking/delete-default-vpcs/exec.sh +++ b/modules/networking/delete-default-vpcs/exec.sh @@ -7,14 +7,13 @@ if [ "${vpc}" = "null" ]; then 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 +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 +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 @@ -22,4 +21,3 @@ done echo "Removing vpc ${vpc}" aws ec2 --region ${region} delete-vpc --vpc-id ${vpc} -