Best Python code snippet using localstack_python
ec2_starter.py
Source:ec2_starter.py
...104 result = xmltodict.unparse(result)105 return result106 vpcs.VPCs.describe_vpc_endpoint_services = describe_vpc_endpoint_services107 # DescribePrefixLists API108 def describe_prefix_lists(self):109 if not hasattr(self.ec2_backend, "_prefix_lists"):110 entries = self.ec2_backend._prefix_lists = []111 for service_id in GATEWAY_SERVICES:112 region = self.ec2_backend.region_name113 service_name = "com.amazonaws.%s.%s" % (region, service_id)114 entry = {115 "prefixListName": service_name,116 "prefixListId": "pl-%s" % short_uid(),117 "cidrSet": {"item": ["52.219.80.0/20"]},118 }119 entries.append(entry)120 entries = self.ec2_backend._prefix_lists121 search_filters = self._parse_search_filters()122 for filter in search_filters:...
get_prefix_lists.py
Source:get_prefix_lists.py
...27 resp = None28 while True:29 30 if next_token:31 resp = client.describe_prefix_lists(NextToken=next_token)32 else:33 resp = client.describe_prefix_lists()34 if len(resp.get('PrefixLists', [])):35 prefix_lists = prefix_lists + resp['PrefixLists']36 next_token = resp.get('NextToken', None)37 if not next_token:38 break39 return prefix_lists40def get_prefix_lists(region_name, service_name, keys):41 results = []42 details = get_prefix_lists_detail(region_name, service_name)43 for item in details:44 if service_name in item['PrefixListName']:45 ret_item = { 'PrefixListName' : item['PrefixListName'] }46 for k in keys:47 ret_item[k] = item.get(k, '')...
gateway_vpc_endpoint_prefix_lists.py
Source:gateway_vpc_endpoint_prefix_lists.py
1"""2A helper script to call describe_prefix_lists.3"""4import click5import logging6from helper.aws import AwsApiHelper7logging.getLogger().setLevel(logging.DEBUG)8class Helper(AwsApiHelper):9 def process_request(self, session, account_id, region, kwargs):10 cnt = 011 client = session.client("ec2", region_name=region)12 for item in self.paginate(client, "describe_prefix_lists"):13 print(f'{item["PrefixListName"]}, {item["PrefixListId"]}, {item["Cidrs"]}')14 cnt += 115 logging.debug(f"{account_id} {region}: Total items: {cnt}")16@click.command()17@click.option("--profile", "-p", help="AWS profile name. Use profiles in ~/.aws if not specified.")18@click.option("--region", "-r", default="ap-southeast-2", show_default=True, help="AWS Region. Use 'all' for all regions.")19def main(profile, region):20 Helper().start(profile, region, "ec2")21if __name__ == "__main__":...
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!!