diff --git a/hack/aws-acceptance-test-cleanup/main.go b/hack/aws-acceptance-test-cleanup/main.go index e4094ec47e..c708940104 100644 --- a/hack/aws-acceptance-test-cleanup/main.go +++ b/hack/aws-acceptance-test-cleanup/main.go @@ -196,7 +196,7 @@ func realMain(ctx context.Context) error { if err != nil { return err } - toDeleteVPCs = append(vpcsOutput.Vpcs) + toDeleteVPCs = append(toDeleteVPCs, vpcsOutput.Vpcs...) nextToken = vpcsOutput.NextToken if nextToken == nil { break @@ -366,6 +366,11 @@ func realMain(ctx context.Context) error { }, }, }) + + if err != nil { + return err + } + vpcPeeringConnectionsToDelete := append(vpcPeeringConnectionsWithAcceptor.VpcPeeringConnections, vpcPeeringConnectionsWithRequester.VpcPeeringConnections...) // Delete NAT gateways. @@ -377,9 +382,11 @@ func realMain(ctx context.Context) error { }, }, }) + if err != nil { return err } + for _, gateway := range natGateways.NatGateways { fmt.Printf("NAT gateway: Destroying... [id=%s]\n", *gateway.NatGatewayId) _, err = ec2Client.DeleteNatGatewayWithContext(ctx, &ec2.DeleteNatGatewayInput{ @@ -484,6 +491,11 @@ func realMain(ctx context.Context) error { }, }, }) + + if err != nil { + return err + } + for _, igw := range igws.InternetGateways { fmt.Printf("Internet gateway: Detaching from VPC... [id=%s]\n", *igw.InternetGatewayId) if err := destroyBackoff(ctx, "Internet Gateway", *igw.InternetGatewayId, func() error { @@ -520,6 +532,11 @@ func realMain(ctx context.Context) error { }, }, }) + + if err != nil { + return err + } + for _, subnet := range subnets.Subnets { fmt.Printf("Subnet: Destroying... [id=%s]\n", *subnet.SubnetId) if err := destroyBackoff(ctx, "Subnet", *subnet.SubnetId, func() error { @@ -547,6 +564,11 @@ func realMain(ctx context.Context) error { }, }, }) + + if err != nil { + return err + } + for _, routeTable := range routeTables.RouteTables { // Find out if this is the main route table. var mainRouteTable bool @@ -580,6 +602,11 @@ func realMain(ctx context.Context) error { }, }, }) + + if err != nil { + return err + } + for _, sg := range sgs.SecurityGroups { if len(sg.IpPermissions) > 0 { revokeSGInput := &ec2.RevokeSecurityGroupIngressInput{GroupId: sg.GroupId}