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

Commit

Permalink
Merge pull request #107 from zalando-stups/fix-kms-cleanup
Browse files Browse the repository at this point in the history
Fix cleanup of KMS VPC endpoint
  • Loading branch information
aermakov-zalando committed Apr 1, 2021
2 parents 83c38f8 + b62df0d commit d61a93d
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 d61a93d

Please sign in to comment.