How to use create_customer_gateway method in localstack

Best Python code snippet using localstack_python

customer_gateways.py

Source:customer_gateways.py Github

copy

Full Screen

1from moto.core.responses import BaseResponse2from moto.ec2.utils import filters_from_querystring3class CustomerGateways(BaseResponse):4 def create_customer_gateway(self):5 # raise NotImplementedError('CustomerGateways(AmazonVPC).create_customer_gateway is not yet implemented')6 gateway_type = self._get_param("Type")7 ip_address = self._get_param("IpAddress")8 bgp_asn = self._get_param("BgpAsn")9 tags = self._get_multi_param("TagSpecification")10 tags = tags[0] if isinstance(tags, list) and len(tags) == 1 else tags11 tags = (tags or {}).get("Tag", [])12 tags = {t["Key"]: t["Value"] for t in tags}13 customer_gateway = self.ec2_backend.create_customer_gateway(14 gateway_type, ip_address=ip_address, bgp_asn=bgp_asn, tags=tags15 )16 template = self.response_template(CREATE_CUSTOMER_GATEWAY_RESPONSE)17 return template.render(customer_gateway=customer_gateway)18 def delete_customer_gateway(self):19 customer_gateway_id = self._get_param("CustomerGatewayId")20 delete_status = self.ec2_backend.delete_customer_gateway(customer_gateway_id)21 template = self.response_template(DELETE_CUSTOMER_GATEWAY_RESPONSE)22 return template.render(delete_status=delete_status)23 def describe_customer_gateways(self):24 self.error_on_dryrun()25 filters = filters_from_querystring(self.querystring)26 customer_gateway_ids = self._get_multi_param("CustomerGatewayId")27 customer_gateways = self.ec2_backend.get_all_customer_gateways(...

Full Screen

Full Screen

test_customer_gateways.py

Source:test_customer_gateways.py Github

copy

Full Screen

...6from moto import mock_ec2_deprecated7@mock_ec2_deprecated8def test_create_customer_gateways():9 conn = boto.connect_vpc("the_key", "the_secret")10 customer_gateway = conn.create_customer_gateway("ipsec.1", "205.251.242.54", 65534)11 customer_gateway.should_not.be.none12 customer_gateway.id.should.match(r"cgw-\w+")13 customer_gateway.type.should.equal("ipsec.1")14 customer_gateway.bgp_asn.should.equal(65534)15 customer_gateway.ip_address.should.equal("205.251.242.54")16@mock_ec2_deprecated17def test_describe_customer_gateways():18 conn = boto.connect_vpc("the_key", "the_secret")19 customer_gateway = conn.create_customer_gateway("ipsec.1", "205.251.242.54", 65534)20 cgws = conn.get_all_customer_gateways()21 cgws.should.have.length_of(1)22 cgws[0].id.should.match(customer_gateway.id)23@mock_ec2_deprecated24def test_delete_customer_gateways():25 conn = boto.connect_vpc("the_key", "the_secret")26 customer_gateway = conn.create_customer_gateway("ipsec.1", "205.251.242.54", 65534)27 customer_gateway.should_not.be.none28 cgws = conn.get_all_customer_gateways()29 cgws[0].id.should.match(customer_gateway.id)30 deleted = conn.delete_customer_gateway(customer_gateway.id)31 cgws = conn.get_all_customer_gateways()32 cgws.should.have.length_of(0)33@mock_ec2_deprecated34def test_delete_customer_gateways_bad_id():35 conn = boto.connect_vpc("the_key", "the_secret")36 with pytest.raises(EC2ResponseError) as cm:...

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