How to use modify_transit_gateway_vpc_attachment method in localstack

Best Python code snippet using localstack_python

index.py

Source:index.py Github

copy

Full Screen

...26 try:27 if event['RequestType'] == 'Delete':28 phyresId = event['PhysicalResourceId']29 client_ec2 = boto3.client('ec2', region_name=region)30 action = client_ec2.modify_transit_gateway_vpc_attachment(31 TransitGatewayAttachmentId=tgwattach,32 Options={33 'ApplianceModeSupport': 'disable'34 }35 )36 response["Status"] = "SUCCESS"37 response["Reason"] = ("Appliance Mode disable!")38 response["PhysicalResourceId"] = phyresId39 response["Data"] = { "TransitGatewayVpcAttachmentId" : tgwattach, "Appliancemode" : 'disable' }40 elif event['RequestType'] == 'Create':41 client_ec2 = boto3.client('ec2', region_name=region)42 action = client_ec2.modify_transit_gateway_vpc_attachment(43 TransitGatewayAttachmentId=tgwattach,44 Options={45 'ApplianceModeSupport': 'enable'46 }47 )48 response["Status"] = "SUCCESS"49 response["PhysicalResourceId"] = tgwattach50 response["Reason"] = ("Appliance Mode enable!")51 response["Data"] = { "TransitGatewayVpcAttachmentId" : tgwattach, "Appliancemode" : 'enable' }52 else:53 phyresId = event['PhysicalResourceId']54 client_ec2 = boto3.client('ec2', region_name=region)55 action = client_ec2.modify_transit_gateway_vpc_attachment(56 TransitGatewayAttachmentId=tgwattach,57 Options={58 'ApplianceModeSupport': 'enable'59 }60 )61 response["Status"] = "SUCCESS"62 response["Reason"] = ("Appliance Mode enable!")63 response["PhysicalResourceId"] = phyresId64 response["Data"] = { "TransitGatewayVpcAttachmentId" : tgwattach, "Appliancemode" : 'enable' }65 logger.info('Action: Nothing to do here! - {}'.format(event['RequestType']))66 except Exception as e:67 response = {}68 logger.error('ERROR: {}'.format(e))69 traceback.print_exc()...

Full Screen

Full Screen

lambda-enable-tgw-attachment-appliance-mode.py

Source:lambda-enable-tgw-attachment-appliance-mode.py Github

copy

Full Screen

...8 if (event['RequestType'] == 'Create' or event['RequestType'] == 'Update'):9 tgw_attachment_id_list=tgw_attachment_ids.split(",")10 for attachment_id in tgw_attachment_id_list:11 try:12 appliance_mode=ec2_client.modify_transit_gateway_vpc_attachment(13 TransitGatewayAttachmentId=attachment_id,14 Options={15 'ApplianceModeSupport': 'enable'16 }17 )['TransitGatewayVpcAttachment']['Options']['ApplianceModeSupport']18 print(f"Appliance Mode for the Inspection VPC Transit Gateway Attachment is set to {appliance_mode}.")19 cfnresponse.send(event, context, cfnresponse.SUCCESS, {})20 except ClientError as e: 21 print(f"Unable to Modify Transit Gateway Attacment ID: {attachment_id}. Error: {e}.") 22 cfnresponse.send(event, context, cfnresponse.FAILED, e.response)23 elif event['RequestType'] == 'Delete':24 tgw_attachment_id_list=tgw_attachment_ids.split(",")25 for attachment_id in tgw_attachment_id_list:26 try:27 appliance_mode=ec2_client.modify_transit_gateway_vpc_attachment(28 TransitGatewayAttachmentId=attachment_id,29 Options={30 'ApplianceModeSupport': 'disable'31 }32 )['TransitGatewayVpcAttachment']['Options']['ApplianceModeSupport']33 print(f"Appliance Mode for the Inspection VPC Transit Gateway Attachment is set to {appliance_mode}.")34 cfnresponse.send(event, context, cfnresponse.SUCCESS, {})35 except ClientError as e: 36 print(f"Unable to Modify Transit Gateway Attacment ID: {attachment_id}. Error: {e}.") ...

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