Best Python code snippet using localstack_python
create_tgw_connect_peer.py
Source:create_tgw_connect_peer.py
...31 try:32 ec2 = boto3.client('ec2')33 properties = event['ResourceProperties']34 if event['RequestType'] == 'Create':35 tgw_connect_peer = ec2.create_transit_gateway_connect_peer(36 TransitGatewayAttachmentId=properties['TransitGatewayAttachmentId'],37 TransitGatewayAddress=properties['TransitGatewayAddress'],38 PeerAddress=properties['PeerAddress'],39 BgpOptions={40 'PeerAsn': int(properties['PeerAsn'])41 },42 InsideCidrBlocks=[43 properties['InsideCidrBlocks'],44 ]45 )['TransitGatewayConnectPeer']46 peer_id = tgw_connect_peer['TransitGatewayConnectPeerId']47 __wait_for_status(peer_id, 'available', ec2)48 cfnresponse.send(event, context, cfnresponse.SUCCESS, response_data, peer_id)49 return50 if event['RequestType'] == 'Delete':51 if re.match("tgw-connect-peer-[a-zA-Z0-9]+", event['PhysicalResourceId']):52 ec2.delete_transit_gateway_connect_peer(53 TransitGatewayConnectPeerId=event['PhysicalResourceId']54 )55 __wait_for_status(event['PhysicalResourceId'], 'deleted', ec2)56 cfnresponse.send(event, context, cfnresponse.SUCCESS, response_data, event['PhysicalResourceId'])57 return58 else:59 cfnresponse.send(event, context, cfnresponse.SUCCESS, response_data, event['PhysicalResourceId'])60 return61 if event['RequestType'] == 'Read':62 cfnresponse.send(event, context, cfnresponse.SUCCESS, response_data, event['PhysicalResourceId'])63 return64 if event['RequestType'] == 'Update':65 if re.match("tgw-connect-peer-[a-zA-Z0-9]+", event['PhysicalResourceId']):66 ec2.delete_transit_gateway_connect_peer(67 TransitGatewayConnectPeerId=event['PhysicalResourceId']68 )69 __wait_for_status(event['PhysicalResourceId'], 'deleted', ec2)70 tgw_connect_peer = ec2.create_transit_gateway_connect_peer(71 TransitGatewayAttachmentId=properties['TransitGatewayAttachmentId'],72 TransitGatewayAddress=properties['TransitGatewayAddress'],73 PeerAddress=properties['PeerAddress'],74 BgpOptions={75 'PeerAsn': int(properties['PeerAsn'])76 },77 InsideCidrBlocks=[78 properties['InsideCidrBlocks'],79 ]80 )['TransitGatewayConnectPeer']81 peer_id = tgw_connect_peer['TransitGatewayConnectPeerId']82 __wait_for_status(peer_id, 'available', ec2)83 cfnresponse.send(event, context, cfnresponse.SUCCESS, response_data, peer_id)84 return...
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!!