Best Python code snippet using localstack_python
transit_gateways.py
Source:transit_gateways.py
...37 filters, transit_gateway_ids38 )39 template = self.response_template(DESCRIBE_TRANSIT_GATEWAY_RESPONSE)40 return template.render(transit_gateways=transit_gateways)41 def modify_transit_gateway(self):42 transit_gateway_id = self._get_param("TransitGatewayId")43 description = self._get_param("Description") or None44 options = self._get_multi_param_dict("Options")45 transit_gateway = self.ec2_backend.modify_transit_gateway(46 transit_gateway_id=transit_gateway_id,47 description=description,48 options=options,49 )50 template = self.response_template(MODIFY_TRANSIT_GATEWAY_RESPONSE)51 return template.render(transit_gateway=transit_gateway)52CREATE_TRANSIT_GATEWAY_RESPONSE = """<CreateTransitGatewayResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">53 <requestId>151283df-f7dc-4317-89b4-01c9888b1d45</requestId>54 <transitGateway>55 <transitGatewayId>{{ transit_gateway.id }}</transitGatewayId>56 <ownerId>{{ transit_gateway.owner_id }}</ownerId>57 <description>{{ transit_gateway.description or '' }}</description>58 <createTime>{{ transit_gateway.create_time }}</createTime>59 <state>{{ transit_gateway.state }}</state>...
lambda-modify-tgw-configuration.py
Source:lambda-modify-tgw-configuration.py
...8tgw_rtb_spoke_id=os.environ['TGW_RTB_SPOKE_ID']9def lambda_handler(event, context):10 if (event['RequestType'] == 'Create' or event['RequestType'] == 'Update'):11 try:12 response=ec2_client.modify_transit_gateway(13 TransitGatewayId=tgw_id,14 Options={15 'DefaultRouteTableAssociation': 'enable',16 'AssociationDefaultRouteTableId': tgw_rtb_spoke_id,17 'DefaultRouteTablePropagation': 'enable',18 'PropagationDefaultRouteTableId': tgw_rtb_firewall_id19 }20 )21 print(response)22 cfnresponse.send(event, context, cfnresponse.SUCCESS, {})23 except ClientError as e: 24 print(f"Unable to Modify Transit Gateway: {tgw_id}. Error: {e}.") 25 cfnresponse.send(event, context, cfnresponse.FAILED, e.response)26 elif event['RequestType'] == 'Delete':27 try:28 response=ec2_client.modify_transit_gateway(29 TransitGatewayId=tgw_id,30 Options={31 'DefaultRouteTableAssociation': 'disable',32 'DefaultRouteTablePropagation': 'disable'33 }34 )35 print(response)36 cfnresponse.send(event, context, cfnresponse.SUCCESS, {})37 except ClientError as e: 38 print(f"Unable to Modify Transit Gateway: {tgw_id}. Error: {e}.") ...
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!!