How to use delete_transit_gateway_route method in localstack

Best Python code snippet using localstack_python

test_transit_gateway_route.py

Source:test_transit_gateway_route.py Github

copy

Full Screen

1# Copyright (c) 2018 Cloudify Platform Ltd. All rights reserved2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14# Standard imports15import unittest16# Third party imports17from mock import patch, MagicMock18# Local imports19from cloudify_aws.common._compat import reload_module20from cloudify_aws.common.tests.test_base import (21 TestBase,22 mock_decorator23)24from cloudify_aws.ec2.resources import transit_gateway_route as mod25from cloudify_aws.ec2.resources.transit_gateway import TG_ATTACHMENT_ID26from cloudify_aws.ec2.resources.transit_gateway_routetable import ROUTETABLE_ID27class TestEC2TransitGatewayRoute(TestBase):28 def setUp(self):29 self.route = mod.EC2TransitGatewayRoute(30 "ctx_node", resource_id=True,31 client=True, logger=None)32 mock1 = patch('cloudify_aws.common.decorators.aws_resource',33 mock_decorator)34 mock1.start()35 reload_module(mod)36 def test_class_create(self):37 value = True38 config = {ROUTETABLE_ID: 'foo'}39 self.route.client = self.make_client_function(40 'create_transit_gateway_route', return_value=value)41 res = self.route.create(config)42 self.assertEqual(True, res)43 def test_class_delete(self):44 params = {}45 self.route.client = self.make_client_function(46 'delete_transit_gateway_route')47 self.route.delete(params)48 self.assertTrue(self.route.client.delete_transit_gateway_route.called)49 params = {ROUTETABLE_ID: 'foo'}50 self.route.delete(params)51 self.assertEqual(params[ROUTETABLE_ID], 'foo')52 def test_create(self):53 ctx = self.get_mock_ctx("RouteTable")54 config = {55 ROUTETABLE_ID: 'foo',56 TG_ATTACHMENT_ID: 'bar',57 'DestinationCidrBlock': '0.0.0.0/0'58 }59 self.route.resource_id = config[ROUTETABLE_ID]60 iface = MagicMock()61 iface.create = self.mock_return(config)62 mod.create(ctx, iface, config)63 self.assertEqual(self.route.resource_id, 'foo')64 def test_delete(self):65 ctx = self.get_mock_ctx("RouteTable")66 iface = MagicMock()67 config = {68 ROUTETABLE_ID: 'route table',69 'DestinationCidrBlock': '0.0.0.0/0'70 }71 mod.delete(ctx, iface, config)72 self.assertTrue(iface.delete.called)73if __name__ == '__main__':...

Full Screen

Full Screen

RemoveTGWRoute.py

Source:RemoveTGWRoute.py Github

copy

Full Screen

...38 tgw_rt_id=os.environ.get('TGW_ROUTE_TABLE')39 route=os.environ.get('ROUTE')40 if static_exists(route, tgw_rt_id):41 try:42 delete_result = client.delete_transit_gateway_route(43 TransitGatewayRouteTableId=tgw_rt_id,44 DestinationCidrBlock=route,45 DryRun=False46 )47 logger.info(f"Route {route} deleted from TGW RT {tgw_rt_id}")48 except Exception as ex:49 logger.info(f"exception occured while deleting a tgw route: {ex}")50 raise...

Full Screen

Full Screen

cleanup.py

Source:cleanup.py Github

copy

Full Screen

...16 }17 ]18)19tgw_rt_id_us_east_1=(query['TransitGatewayAttachments'][0]['Association']['TransitGatewayRouteTableId'])20response = client.delete_transit_gateway_route(21 DestinationCidrBlock='172.16.1.0/24',22 TransitGatewayRouteTableId=(tgw_rt_id_us_east_1)23)24client = boto3.client('ec2', region_name='eu-west-1')25query = client.describe_transit_gateway_attachments(26 Filters=[27 {28 'Name': 'resource-type',29 'Values': [30 'peering',31 ]32 },33 {34 'Name': 'state',35 'Values': [36 'available',37 ]38 }39 ]40)41tgw_rt_id_eu_west_1=(query['TransitGatewayAttachments'][0]['Association']['TransitGatewayRouteTableId'])42tgw_attachment_id=(query['TransitGatewayAttachments'][0]['TransitGatewayAttachmentId'])43response = client.delete_transit_gateway_route(44 DestinationCidrBlock='172.16.0.0/24',45 TransitGatewayRouteTableId=(tgw_rt_id_eu_west_1)46)47response = client.delete_transit_gateway_peering_attachment(48 TransitGatewayAttachmentId=(tgw_attachment_id)...

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