How to use create_event_subscription method in localstack

Best Python code snippet using localstack_python

wecutil.py

Source:wecutil.py Github

copy

Full Screen

...61 def act(self, good_conn_infos, args, config):62 for conn_info in good_conn_infos:63 hostname = conn_info.hostname64 for subscr_info in config.subscr_infos:65 subscription = create_event_subscription(conn_info)66 self._subscriptions_dct[(hostname, subscr_info)] = subscription67 yield subscription.subscribe(68 subscr_info.path, subscr_info.select)69 self._do_pull(0, args.num_pulls, hostname, subscr_info)70 yield self._d71class WecUtility(app.ConfigDrivenUtility):72 def add_args(self, parser):73 parser.add_argument("--path", "-p", default='Application')74 parser.add_argument("--select", "-s", default='*')75 parser.add_argument("--num-pulls", "-n", type=int, default=2)76 def check_args(self, args):77 return True78 def add_config(self, parser, config):79 subscr_info_builders_dct = {}...

Full Screen

Full Screen

handler.py

Source:handler.py Github

copy

Full Screen

...38 39 if response:40 return True41 return False42def create_event_subscription(dbname,stage):43 session = boto3.session.Session()44 client = session.client(service_name='rds',region_name='ap-southeast-2')45 sts_client = session.client("sts", region_name="ap-southeast-2")46 account_id = sts_client.get_caller_identity()["Account"]47 date = datetime.now().strftime("%Y-%m-%d")48 target_db = f"{dbname}-rcvred-{date}"49 50 sns_arn = f"arn:aws:sns:{session.region_name}:{account_id}:rds-events-dispatcher"51 response = client.create_event_subscription(52 SubscriptionName='restore-snapshot-subs',53 SnsTopicArn=sns_arn,54 SourceType='db-instance',55 EventCategories=[56 'backup',57 ],58 SourceIds=[59 target_db60 ],61 Enabled=True,62 Tags=[63 {64 'Key': 'environment',65 'Value': stage66 },67 ]68 )69 return response70def delete_event_subscription():71 session = boto3.session.Session()72 client = session.client(service_name='rds',region_name='ap-southeast-2')73 response = client.delete_event_subscription(SubscriptionName='restore-snapshot-subs')74 return response 75def restore(event, context):76 dbname = os.environ["DB_NAME"]77 db_sg = os.environ["DB_SECURITY_GROUP_ID"]78 lambda_sg = os.environ["LAMBDA_SECURITY_GROUP_ID"]79 subnet_group = os.environ["DB_SUBNET_GROUP_NAME"]80 stage = os.environ["STAGE"]81 restore_snapshot(dbname, db_sg, lambda_sg, subnet_group)82 83 if subscription_exists():84 delete_event_subscription()85 print("subscription (restore-snapshot-subs) deleted") 86 response_create_subs = create_event_subscription(dbname,stage)87 subscription_id = response_create_subs["EventSubscription"]["CustSubscriptionId"]88 status = response_create_subs["EventSubscription"]["Status"]89 result = f"the subscription {subscription_id} is {status}" 90 print(result)91 return {"result": result}92if __name__ == "__main__":...

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