How to use delete_vpn_connection method in localstack

Best Python code snippet using localstack_python

delete_aws_vpn.py

Source:delete_aws_vpn.py Github

copy

Full Screen

...53 return54 except Exception as e:55 logger.info('Got error {}'.format(e))56 return 'false'57def delete_vpn_connection(VpnConnectionId, DryRun=False):58 try:59 response = ec2_client.delete_vpn_connection(60 VpnConnectionId=VpnConnectionId,61 DryRun=DryRun62 )63 logger.info('Deleted vpn connection {}'.format(VpnConnectionId))64 return 'success'65 except Exception as e:66 logger.info('Got error {} deleting vpn connection'.format(e))67 return 'error'68def delete_cgw(cgwId, DryRun=False):69 try:70 response = ec2_client.delete_customer_gateway(71 CustomerGatewayId=cgwId,72 DryRun=DryRun73 )74 logger.info('Deleted cgw connection {}'.format(cgwId))75 return True76 except Exception as e:77 logger.info('Got error {} deleting cgw'.format(e))78 return False79def lambda_handler(event, context):80 logger.info('Got event {}'.format(event))81 # Delete vgw connections82 fw1_vpnId = event.get('fw1_vpnId')83 fw2_vpnId = event.get('fw2_vpnId')84 fw1_sec_vpnId = event.get('fw1_sec_vpnId')85 fw2_sec_vpnId = event.get('fw2_sec_vpnId')86 fw1_cgwId = event.get('fw1_cgwId')87 fw2_cgwId = event.get('fw2_cgwId')88 fw1_sec_cgwId = event.get('fw1_sec_cgwId')89 fw2_sec_cgwId = event.get('fw2_sec_cgwId')90 if fw1_vpnId:91 if delete_vpn_connection(fw1_vpnId):92 release_ips(table_name, fw1_vpnId)93 if fw2_vpnId:94 if delete_vpn_connection(fw2_vpnId):95 release_ips(table_name, fw2_vpnId)96 if fw1_cgwId:97 if delete_cgw(fw1_cgwId):98 logger.info('Deleted cgw {}'.format(fw1_cgwId))99 if fw2_cgwId:100 if delete_cgw(fw2_cgwId):101 logger.info('Deleted cgw {}'.format(fw2_cgwId))102 if fw1_sec_vpnId:103 if delete_vpn_connection(fw1_sec_vpnId):104 release_ips(table_name, fw1_sec_vpnId)105 if fw2_sec_vpnId:106 if delete_vpn_connection(fw2_sec_vpnId):107 release_ips(table_name, fw2_sec_vpnId)108 if fw1_sec_cgwId:109 if delete_cgw(fw1_sec_cgwId):110 logger.info('Deleted cgw {}'.format(fw1_sec_cgwId))111 if fw2_sec_cgwId:112 if delete_cgw(fw2_sec_cgwId):113 logger.info('Deleted cgw {}'.format(fw2_sec_cgwId))...

Full Screen

Full Screen

delete_fw_vpn.py

Source:delete_fw_vpn.py Github

copy

Full Screen

...23import botocore24logger = logging.getLogger()25logger.setLevel(logging.INFO)26ec2_client = boto3.client('ec2')27def delete_vpn_connection(VpnConnectionId, DryRun=False):28 try:29 response = ec2_client.delete_vpn_connection(30 VpnConnectionId=VpnConnectionId,31 DryRun=DryRun32 )33 return 'success'34 except Exception as e:35 logger.info('Got error {} deleting vpn connection'.format(e))36 return 'error'37def lambda_handler(event, context):38 logger.info('got event {} context {}'.format(event, context))39 # event = {40 # 'Action': 'config_aws_failed',41 # 'fw1_vpnId' : fw1_vpnId,42 # 'fw1_cgwId' : fw1_cgwId,43 # 'fw2_vpnId' : fw2_vpnId,44 # 'fw2_cgwId' : fw2_cgwId45 # }46 if event.get('fw1_vpnId'):47 if delete_vpn_connection(event.get('fw1_vpnId')):48 logger.info('Deleted vpn connection {}'.format(event.get('fw1_vpnId')))49 if event.get('fw2_vpnId'):50 if delete_vpn_connection(event.get('fw2_vpnId')):51 logger.info('Deleted vpn connection {}'.format(event.get('fw2_vpnId')))...

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