How to use describe_managed_prefix_lists method in localstack

Best Python code snippet using localstack_python

make_prefix_list.py

Source:make_prefix_list.py Github

copy

Full Screen

...36def only_cidr(entry):37 return entry["Cidr"]38def remove_entries_from_list(prefix_list_name):39 try: 40 lookup_res = ec2_client.describe_managed_prefix_lists(41 Filters = [ { "Name": "prefix-list-name", "Values": [ prefix_list_name ]}]42 )43 for prefix_list in lookup_res["PrefixLists"]:44 logging.debug("Clearing entries from %s" %(prefix_list["PrefixListId"]))45 entries_result = ec2_client.get_managed_prefix_list_entries(46 PrefixListId = prefix_list["PrefixListId"],47 MaxResults = MAX_ENTRIES48 )49 entries_to_clear = map(only_cidr, entries_result["Entries"])50 clear_result = ec2_client.modify_managed_prefix_list(51 PrefixListId = prefix_list["PrefixListId"],52 RemoveEntries = entries_to_clear53 )54 except Exception as e:55 logging.error("Trouble clearing prefix list %s:\n====\n%s\n====\n" %(prefix_list_name, e))56def remove_prefix_list(prefix_list_name):57 try: 58 lookup_res = ec2_client.describe_managed_prefix_lists(59 Filters = [ { "Name": "prefix-list-name", "Values": [ prefix_list_name ]}]60 )61 for prefix_list in lookup_res["PrefixLists"]:62 logging.debug("Removing list named %s" %(prefix_list["PrefixListId"]))63 ec2_client.delete_managed_prefix_list(64 PrefixListId = prefix_list["PrefixListId"]65 )66 except Exception as e:67 logging.error("Trouble removing prefix list %s:\n====\n%s\n====\n" %(prefix_list_name, e)) 68def tidy_name(name):69 return name.lower().replace(".", "-")70def create_ipv4_entries(prefixes):71 entries = []72 for prefix in prefixes:...

Full Screen

Full Screen

modify_managed_prefix_list.py

Source:modify_managed_prefix_list.py Github

copy

Full Screen

...41 logging.error("Error", exc_info = e)42# get managed_prefix_list version number43def get_version(PrefixId):44 try:45 response = client.describe_managed_prefix_lists( PrefixListIds = [ PrefixId ] )46 version = [str(i['Version']) for i in response['PrefixLists']]47 version_string = "".join(version)48 return int(version_string)49 except Exception as e:50 logging.error("Error", exc_info = e)51# update managed prefix list52def update_managed_prefix_list(PrefixId):53 try:54 logging.info("Count of new entries: {0}".format(len(compare(PrefixId))))55 if len(compare(PrefixId)) < 1:56 logging.info("No new entries to add")57 else:58 for i in compare(PrefixId):59 # update list with new entries60 logging.info("Adding new CIDR block {0}".format(i))61 response = client.modify_managed_prefix_list(62 PrefixListId = PrefixId, 63 CurrentVersion = get_version(PrefixId),64 AddEntries = [ { 'Cidr': i }] )65 logging.info('Check state...')66 response = client.describe_managed_prefix_lists( PrefixListIds = [ PrefixId] )67 if [i['State'] for i in response['PrefixLists']] != ['modify-complete']:68 logging.info('Sleep...')69 time.sleep(2)70 else:71 continue72 except Exception as e:...

Full Screen

Full Screen

AwsManagedPrefixList.py

Source:AwsManagedPrefixList.py Github

copy

Full Screen

...8 self._tags = TagSet({"CreatedBy": "CloudPrep"})9 @AwsElement.capture_method10 def capture(self):11 ec2 = boto3.client("ec2")12 source_data = ec2.describe_managed_prefix_lists(PrefixListIds=[self._physical_id])["PrefixLists"][0]13 if source_data["OwnerId"] == "AWS":14 raise Exception("Prefix list " + self._physical_id + " appears to be AWS-managed.")15 self.copy_if_exists("AddressFamily", source_data)16 self.copy_if_exists("MaxEntries", source_data)17 self.copy_if_exists("PrefixListName", source_data)18 self.copy_if_exists("Entries", ec2.get_managed_prefix_list_entries(PrefixListId=self._physical_id))19 self._tags.from_api_result(source_data)...

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