Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Fix cleanup of KMS VPC endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
  • Loading branch information
mikkeloscar committed Mar 23, 2021
1 parent 83c38f8 commit b62df0d
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions sevenseconds/config/vpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,17 +875,14 @@ def cleanup_vpc(account: AccountData, region: str):
time.sleep(10)
nat_gateway = ec2c.describe_nat_gateways(Filter=filters)['NatGateways']

with ActionOnExit("Delete Managed Network Interfaces"):
for eni in ec2c.describe_network_interfaces(Filters=[{
"Name": "group-name",
"Values": ["KMS VPC Endpoint"],
}])["NetworkInterfaces"]:
ec2c.delete_network_interface(NetworkInterfaceId=eni["NetworkInterfaceId"])

with ActionOnExit('Delete Endpoints..'):
for endpoint in ec2c.describe_vpc_endpoints()['VpcEndpoints']:
ec2c.delete_vpc_endpoints(VpcEndpointIds=[endpoint['VpcEndpointId']])

while len(ec2c.describe_vpc_endpoints()['VpcEndpoints']) > 0:
warning('VPC Endpoint is deleting.. waiting..')
time.sleep(10)

with ActionOnExit('Delete Subnets..'):
for subnet in ec2c.describe_subnets()['Subnets']:
ec2c.delete_subnet(SubnetId=subnet['SubnetId'])
Expand Down

0 comments on commit b62df0d

Please sign in to comment.