How to use put_destination_policy method in localstack

Best Python code snippet using localstack_python

avm-cwpolicy-update.py

Source:avm-cwpolicy-update.py Github

copy

Full Screen

...43 ]44 }}45 """46 print(access_policy)47 response = client.put_destination_policy(destinationName=d["destinationName"],accessPolicy=access_policy)48 #print(json.dumps(response))49 else:50 access_policy = json.loads(d["accessPolicy"])51 52 stmt = access_policy["Statement"][0]53 accounts = stmt["Principal"]["AWS"]54 if str(account_id) not in accounts:55 accounts.append(str(account_id))56 access_policy["Statement"][0]["Principal"]["AWS"] = accounts57 access_policy["Statement"][0]["Resource"] = d["arn"]58 print(json.dumps(access_policy))59 response = client.put_destination_policy(destinationName=d["destinationName"],accessPolicy=json.dumps(access_policy))60 #print(json.dumps(response))61def lambda_handler(event, context):62 try:63 account_id = event["AccountId"]64 sns_topic = avm_common.get_param("sns_topic_arn")65 print(sns_topic)66 print(account_id)67 sub = "ERROR: accountpipeline CW destination policy update"68 func = "accountpipeline-cw-destination-policy-update"69 lambda_handler_inner(event, context)70 except ClientError as e:71 body = f"Unexpected error : {e}"72 print(body)73 #(accountId, snsARN, function_name, subject, body):...

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