Best Python code snippet using localstack_python
util_config.py
Source:util_config.py
...6 for a in args:7 print(a)8 print(e)9 return "Unexpected error calling {}".format(op)10def describe_conformance_packs(session):11 fn = "describe_conformance_packs"12 try:13 cfg_client = session.client('config')14 paginator = cfg_client.get_paginator(fn)15 page_iterator = paginator.paginate()16 for page in page_iterator:17 results = page["ConformancePackDetails"]18 for result in results:19 print(result)20 except botocore.exceptions.ClientError as e:21 erm = _fail(e, fn)22 raise Exception(erm)23def list_resource_noncompliance_by_rule(session, configRuleName):24 fn = "get_compliance_details_by_config_rule"25 complianceTypes = ['NON_COMPLIANT']26 map = {}27 try:28 cfg_client = session.client('config')29 paginator = cfg_client.get_paginator(fn)30 page_iterator = paginator.paginate(ConfigRuleName=configRuleName, ComplianceTypes=complianceTypes)31 for page in page_iterator:32 results = page["EvaluationResults"]33 for result in results:34 erq = result['EvaluationResultIdentifier']['EvaluationResultQualifier']35 resourceType = erq['ResourceType']36 resourceId = erq['ResourceId']37 if not (resourceType in map):38 map[resourceType] = []39 map[resourceType].append(resourceId)40 return map41 except botocore.exceptions.ClientError as e:42 erm = _fail(e, fn, '{}={}'.format("rule", configRuleName))43 raise Exception(erm)44def list_resource_noncompliance(session, cpackName):45 fn = "get_conformance_pack_compliance_details"46 filters = {47 'ComplianceType': 'NON_COMPLIANT' 48 }49 try:50 map = {}51 cfg_client = session.client('config')52 paginator = cfg_client.get_paginator(fn)53 page_iterator = paginator.paginate(ConformancePackName=cpackName, Filters=filters)54 for page in page_iterator:55 results = page["ConformancePackRuleEvaluationResults"]56 for result in results:57 erq = result['EvaluationResultIdentifier']['EvaluationResultQualifier']58 configRuleName = erq['ConfigRuleName']59 resourceType = erq['ResourceType']60 resourceId = erq['ResourceId']61 if not (configRuleName in map):62 map[configRuleName] = {}63 crmap = map[configRuleName]64 if not (resourceType in crmap):65 crmap[resourceType] = []66 crmap[resourceType].append(resourceId)67 return map68 except botocore.exceptions.ClientError as e:69 erm = _fail(e, fn, '{}={}'.format("cpackName", cpackName))70 raise Exception(erm)71def list_noncompliant_rules(session):72 fn = "describe_compliance_by_config_rule"73 complianceTypes = ['NON_COMPLIANT']74 try:75 map = {}76 cfg_client = session.client('config')77 paginator = cfg_client.get_paginator(fn)78 page_iterator = paginator.paginate(ComplianceTypes=complianceTypes)79 for page in page_iterator:80 results = page["ComplianceByConfigRules"]81 for result in results:82 print(result)83 return map84 except botocore.exceptions.ClientError as e:85 erm = _fail(e, fn)86 raise Exception(erm)87homeSession = boto3.session.Session()88# describe_conformance_packs(homeSession)89m = list_noncompliant_rules(homeSession)90print(m)91# m = list_resource_noncompliance_by_rule(homeSession, 'ebs-in-backup-plan-conformance-pack-msjja9vn7')...
config_stubber.py
Source:config_stubber.py
...39 expected_params = {'ConfigRuleName': rule_name}40 response = {}41 self._stub_bifurcator(42 'delete_config_rule', expected_params, response, error_code=error_code)43 def stub_describe_conformance_packs(self, packs, error_code=None):44 expected_params = {}45 response = {'ConformancePackDetails': [{46 'ConformancePackName': pack,47 'ConformancePackArn': f'arn:{pack}',48 'ConformancePackId': f'{pack}-id'49 } for pack in packs]}50 self._stub_bifurcator(51 'describe_conformance_packs', expected_params, response, error_code=error_code)52 def stub_describe_conformance_pack_compliance(self, pack_name, rule_names, error_code=None):53 expected_params = {'ConformancePackName': pack_name}54 response = {55 'ConformancePackName': pack_name,56 'ConformancePackRuleComplianceList': [{57 'ConfigRuleName': rule_name...
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!!