How to use describe_traffic_mirror_targets method in localstack

Best Python code snippet using localstack_python

mirroring.py

Source:mirroring.py Github

copy

Full Screen

...185 ])186 return response['TrafficMirrorTarget']['TrafficMirrorTargetId']187 @staticmethod188 def find_traffic_targets_by_nics(ec2_client, target_nics):189 response = ec2_client.describe_traffic_mirror_targets(Filters=[{190 'Name': 'network-interface-id',191 'Values': target_nics}])192 return {x['NetworkInterfaceId']: x['TrafficMirrorTargetId'] for x in response['TrafficMirrorTargets']}193 @staticmethod194 def find_traffic_mirror_targets_by_reservation_id(ec2_client, reservation_id):195 traffic_mirror_targets = []196 response = ec2_client.describe_traffic_mirror_targets(197 Filters=[198 {199 'Name': 'tag:ReservationId',200 'Values': [201 str(reservation_id)202 ]203 },204 ],205 MaxResults=123)206 traffic_mirror_targets.extend(response['TrafficMirrorTargets'])207 while 'NextToken' in response:208 response = ec2_client.describe_traffic_mirror_filters(NextToken=response['NextToken'])209 traffic_mirror_targets.extend(response['TrafficMirrorTargets'])210 return [target['TrafficMirrorTargetId'] for target in traffic_mirror_targets]211 @staticmethod212 def find_traffic_mirror_target_ids_by_target_nic_ids(ec2_client, traffic_target_nic_ids):213 """214 :param list[str] traffic_target_nic_ids:215 """216 traffic_mirror_targets = []217 response = ec2_client.describe_traffic_mirror_targets(218 Filters=[219 {220 'Name': 'network-interface-id',221 'Values': traffic_target_nic_ids222 },223 ],224 MaxResults=100)225 traffic_mirror_targets.extend(response['TrafficMirrorTargets'])226 while 'NextToken' in response:227 response = ec2_client.describe_traffic_mirror_filters(NextToken=response['NextToken'])228 traffic_mirror_targets.extend(response['TrafficMirrorTargets'])229 return [target['TrafficMirrorTargetId'] for target in traffic_mirror_targets]230 @staticmethod231 def find_traffic_mirror_target_nic_id_by_target_id(ec2_client, traffic_mirror_target_id):232 """233 :param str traffic_mirror_target_id:234 """235 traffic_mirror_targets = []236 response = ec2_client.describe_traffic_mirror_targets(237 Filters=[238 {239 'Name': 'traffic-mirror-target-id',240 'Values': [traffic_mirror_target_id]241 },242 ],243 MaxResults=100)244 traffic_mirror_targets.extend(response['TrafficMirrorTargets'])245 while 'NextToken' in response:246 response = ec2_client.describe_traffic_mirror_filters(NextToken=response['NextToken'])247 traffic_mirror_targets.extend(response['TrafficMirrorTargets'])248 return next((target['TrafficMirrorTargetId'] for target in traffic_mirror_targets))249 # endregion250 def _empty(self):...

Full Screen

Full Screen

nlb_target_factory.py

Source:nlb_target_factory.py Github

copy

Full Screen

...10 return target_id11 return self.create(nlb_or_eni_arn=nlb_or_eni_arn)12 def find_target(self, nlb_or_eni_arn: str) -> Union[str, None]:13 try:14 response = self.ec2_client.describe_traffic_mirror_targets(15 Filters=[{"Name": "network-load-balancer-arn", "Values": [nlb_or_eni_arn]}]16 )["TrafficMirrorTargets"]17 except Exception as e:18 if "not found" not in str(e):19 raise20 return None21 if not response:22 return None23 if len(response) > 1:24 raise ValueError("invalid target count")25 return response[0]["TrafficMirrorTargetId"]26 def create(self, nlb_or_eni_arn: str) -> str:27 # create the target (of the mirroring)28 kwargs = {...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful