How to use describe_resource_policies method in localstack

Best Python code snippet using localstack_python

cloudwatch_logs.py

Source:cloudwatch_logs.py Github

copy

Full Screen

...28 @property29 def policy_exists(self):30 """Return true if the policy exists already. CloudWatch resource policies are weird so we take31 a different approach"""32 response = self.client.describe_resource_policies()33 result = False34 if response.get("resourcePolicies"):35 for item in response.get("resourcePolicies"):36 if item.get("policyName") == constants.SID_SIGNATURE:37 result = True38 return result39 def _get_rbp(self) -> ResponseGetRbp:40 """Get the resource based policy for this resource and store it"""41 # When there is no policy, let's return an empty policy to avoid breaking things42 empty_policy = constants.get_empty_policy()43 policy_document = PolicyDocument(44 policy=empty_policy, service=self.service,45 override_action=self.override_action,46 include_resource_block=self.include_resource_block,...

Full Screen

Full Screen

deploy-in-home-region.py

Source:deploy-in-home-region.py Github

copy

Full Screen

...45 lg_names.append(lg['logGroupName'])46 if '/aws/events/log-all-unauthorized-activity' in lg_names:47 print('yes')48 logs[region]['logs']['log_group'] = 'log_group_exists'49 describe_resource_policies = logs_client.describe_resource_policies()50 print(describe_resource_policies)51 logs[region]['logs']['log_resource_policy'] = ''52 for resource in describe_resource_policies['resourcePolicies']:53 if resource['policyName'] == 'TrustEventsToStoreLogEvents':54 logs[region]['logs']['log_resource_policy'] = 'log_resource_policy_exists'55 # We seem to be having issues here:56 if hasattr(logs[region]['logs'], 'log_resource_policy') == False:57 put_resource_policy_response = logs_client.put_resource_policy(58 **resource_policy_args)59 logs[region]['http_codes']['put_resource_policy_response'] = put_resource_policy_response['ResponseMetadata']['HTTPStatusCode']60 else:61 create_log_group_response = logs_client.create_log_group(62 logGroupName='/aws/events/log-all-unauthorized-activity'63 )...

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