1
1
import logging
2
- import time
3
2
from pathlib import Path
4
3
5
4
import boto3
@@ -61,29 +60,6 @@ def clean_all_integ_buckets():
61
60
clean_bucket (bucket .name , s3_client )
62
61
63
62
64
- def _delete_unused_network_interface_by_subnet (ec2_client , subnet_id ):
65
- """Deletes unused network interface under the provided subnet"""
66
- paginator = ec2_client .get_paginator ("describe_network_interfaces" )
67
- response_iterator = paginator .paginate (
68
- Filters = [
69
- {"Name" : "subnet-id" , "Values" : [subnet_id ]},
70
- {"Name" : "status" , "Values" : ["available" ]},
71
- ]
72
- )
73
- network_interface_ids = []
74
- for page in response_iterator :
75
- network_interface_ids += [ni ["NetworkInterfaceId" ] for ni in page ["NetworkInterfaces" ]]
76
-
77
- for ni_id in network_interface_ids :
78
- try :
79
- ec2_client .delete_network_interface (NetworkInterfaceId = ni_id )
80
- except ClientError as e :
81
- LOG .error ("Unable to delete network interface %s" , ni_id , exc_info = e )
82
- time .sleep (0.5 )
83
-
84
- LOG .info ("Deleted %s unused network interfaces under subnet %s" , len (network_interface_ids ), subnet_id )
85
-
86
-
87
63
@pytest .fixture ()
88
64
def setup_companion_stack_once (tmpdir_factory , get_prefix ):
89
65
tests_integ_dir = Path (__file__ ).resolve ().parents [1 ]
@@ -95,15 +71,6 @@ def setup_companion_stack_once(tmpdir_factory, get_prefix):
95
71
companion_stack = Stack (stack_name , companion_stack_tempalte_path , cfn_client , output_dir )
96
72
companion_stack .create_or_update (_stack_exists (stack_name ))
97
73
98
- ec2_client = ClientProvider ().ec2_client
99
- precreated_subnet_ids = [
100
- resource ["PhysicalResourceId" ]
101
- for resource in companion_stack .stack_resources ["StackResourceSummaries" ]
102
- if resource ["LogicalResourceId" ].startswith ("PreCreatedSubnet" )
103
- ]
104
- for subnet_id in precreated_subnet_ids :
105
- _delete_unused_network_interface_by_subnet (ec2_client , subnet_id )
106
-
107
74
108
75
@pytest .fixture ()
109
76
def get_serverless_application_repository_app ():
0 commit comments