Best Python code snippet using localstack_python
lambda_function.py
Source:lambda_function.py
...131 create_traffic_mirror_filter_rule(tmf_id, 'ingress', 100)132 create_traffic_mirror_filter_rule(tmf_id, 'egress', 100)133 return tmf_id134 135def create_traffic_mirror_session(source_network_interface_id, tmt_id, tmf_id):136 if tmf_id == '':137 return138 tms = ec2.create_traffic_mirror_session(139 NetworkInterfaceId=source_network_interface_id,140 TrafficMirrorTargetId=tmt_id,141 TrafficMirrorFilterId=tmf_id,142 SessionNumber=1,143 Description='blstsecurity traffic mirror session'144 )145 146def add_tgw_route_table(route_table_id, tgw_id):147 try:148 ec2.create_route(149 DestinationCidrBlock=blstsec_destination,150 TransitGatewayId=tgw_id,151 RouteTableId=route_table_id152 )153 return 'traffic mirroring integration installed successfully'154 except:155 return 'Wait until blstsecurity will accept the transit gateway attachment and then run the lambda again'156 157def lambda_handler(event, context):158 source_instance_data = get_instance_data()159 shared_resources_ids = get_resource_share_ids(get_resource_share_list())160 if len(shared_resources_ids):161 create_transit_gateway_attachment(shared_resources_ids['tgw'], source_instance_data['vpc_id'] , source_instance_data['subnet_id'])162 create_traffic_mirror_session(source_instance_data['network_interface_id'], shared_resources_ids['tmt'], create_traffic_mirror_filter())163 return add_tgw_route_table(source_instance_data['route_table_id'], shared_resources_ids['tgw'])164 else:...
create-mirror-session.py
Source:create-mirror-session.py
...9 client = boto3.client('ec2', region_name='eu-west-1')10 session = 111 for eni in eni_list:12 # https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.create_traffic_mirror_session13 response = client.create_traffic_mirror_session(14 NetworkInterfaceId=eni,15 TrafficMirrorTargetId=tmt,16 TrafficMirrorFilterId=tmf,17 SessionNumber=session,18 Description='Created by aws-mirror.py',19 )20 session += 121 if args.verbose:22 tms = response['TrafficMirrorSession']['TrafficMirrorSessionId']23 print("Created session " + tms + " for eni " + eni)24def list_instances(panos_image_id, VpcId):25 instance_list = []26 eni_list = []27 response = client.describe_instances(...
create_filter.py
Source:create_filter.py
...51 )52session = 153for eni in eni_list:54 # https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.create_traffic_mirror_session55 response = client.create_traffic_mirror_session(56 NetworkInterfaceId=eni,57 TrafficMirrorTargetId=tmt,58 TrafficMirrorFilterId=tmf,59 SessionNumber=session,60 Description='Created by aws-mirror.py',61 )62 session += 163 if args.verbose:64 tms = response['TrafficMirrorSession']['TrafficMirrorSessionId']...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!