How to use get_transit_gateway_route_table_associations method in localstack

Best Python code snippet using localstack_python

test_transit_gateway.py

Source:test_transit_gateway.py Github

copy

Full Screen

...548 )["TransitGatewayVpcAttachment"]549 table = ec2.create_transit_gateway_route_table(TransitGatewayId=gateway_id)[550 "TransitGatewayRouteTable"551 ]552 initial = ec2.get_transit_gateway_route_table_associations(553 TransitGatewayRouteTableId=table["TransitGatewayRouteTableId"]554 )555 initial["Associations"].should.equal(556 [557 {558 "TransitGatewayAttachmentId": "",559 "ResourceId": "",560 "ResourceType": "",561 "State": "",562 }563 ]564 )565 ec2.associate_transit_gateway_route_table(566 TransitGatewayAttachmentId=attchmnt["TransitGatewayAttachmentId"],567 TransitGatewayRouteTableId=table["TransitGatewayRouteTableId"],568 )569 updated = ec2.get_transit_gateway_route_table_associations(570 TransitGatewayRouteTableId=table["TransitGatewayRouteTableId"]571 )572 updated["Associations"].should.equal(573 [574 {575 "TransitGatewayAttachmentId": attchmnt["TransitGatewayAttachmentId"],576 "ResourceId": "vpc-id",577 "ResourceType": "vpc",578 "State": "associated",579 }580 ]581 )582@mock_ec2583def test_disassociate_transit_gateway_route_table():584 ec2 = boto3.client("ec2", region_name="us-west-1")585 gateway_id = ec2.create_transit_gateway(Description="g")["TransitGateway"][586 "TransitGatewayId"587 ]588 attchmnt = ec2.create_transit_gateway_vpc_attachment(589 TransitGatewayId=gateway_id, VpcId="vpc-id", SubnetIds=["sub1"]590 )["TransitGatewayVpcAttachment"]591 table = ec2.create_transit_gateway_route_table(TransitGatewayId=gateway_id)[592 "TransitGatewayRouteTable"593 ]594 initial = ec2.get_transit_gateway_route_table_associations(595 TransitGatewayRouteTableId=table["TransitGatewayRouteTableId"]596 )["Associations"][0]597 initial["TransitGatewayAttachmentId"].should.equal("")598 ec2.associate_transit_gateway_route_table(599 TransitGatewayAttachmentId=attchmnt["TransitGatewayAttachmentId"],600 TransitGatewayRouteTableId=table["TransitGatewayRouteTableId"],601 )602 updated = ec2.get_transit_gateway_route_table_associations(603 TransitGatewayRouteTableId=table["TransitGatewayRouteTableId"]604 )["Associations"][0]605 updated["TransitGatewayAttachmentId"].should.equal(606 attchmnt["TransitGatewayAttachmentId"]607 )608 updated["State"].should.equal("associated")609 dis = ec2.disassociate_transit_gateway_route_table(610 TransitGatewayAttachmentId=attchmnt["TransitGatewayAttachmentId"],611 TransitGatewayRouteTableId=table["TransitGatewayRouteTableId"],612 )["Association"]613 dis["State"].should.equal("disassociated")614 updated = ec2.get_transit_gateway_route_table_associations(615 TransitGatewayRouteTableId=table["TransitGatewayRouteTableId"]616 )["Associations"][0]617 updated["TransitGatewayAttachmentId"].should.equal("")618 updated["State"].should.equal("")619@mock_ec2620def test_enable_transit_gateway_route_table_propagation():621 ec2 = boto3.client("ec2", region_name="us-west-1")622 gateway_id = ec2.create_transit_gateway(Description="g")["TransitGateway"][623 "TransitGatewayId"624 ]625 attchmnt = ec2.create_transit_gateway_vpc_attachment(626 TransitGatewayId=gateway_id, VpcId="vpc-id", SubnetIds=["sub1"]627 )["TransitGatewayVpcAttachment"]628 table = ec2.create_transit_gateway_route_table(TransitGatewayId=gateway_id)[...

Full Screen

Full Screen

ec2.py

Source:ec2.py Github

copy

Full Screen

...532 f"tgw attachment id {transit_gateway_attachment_id}"533 )534 self.logger.exception(error)535 raise536 def get_transit_gateway_route_table_associations(537 self,538 transit_gateway_route_table_id,539 transit_gateway_attachment_id,540 resource_id,541 resource_type="vpc",542 ):543 """544 This method retrieves transit gateway route table associations545 :param transit_gateway_route_table_id: ID for transit gateway route table546 :param transit_gateway_attachment_id:ID for transit gateway attachment547 :param resource_id: VPC ID548 :return list of route table associations549 """550 try:551 response = (552 self.ec2_client.get_transit_gateway_route_table_associations(553 TransitGatewayRouteTableId=transit_gateway_route_table_id,554 Filters=[555 {556 "Name": "transit-gateway-attachment-id",557 "Values": [transit_gateway_attachment_id],558 },559 {"Name": "resource-type", "Values": [resource_type]},560 {"Name": "resource-id", "Values": [resource_id]},561 ],562 )563 )564 associations_list = response.get("Associations", [])565 next_token = response.get("NextToken", None)566 while next_token is not None:567 response = self.ec2_client.get_transit_gateway_route_table_associations(568 TransitGatewayRouteTableId=transit_gateway_route_table_id,569 NextToken=next_token,570 )571 associations_list.extend(response.get("Associations", []))572 next_token = response.get("NextToken", None)573 return associations_list574 except Exception as error:575 self.logger.exception(576 f"Error while getting tgw route table associations for route table "577 f"{transit_gateway_route_table_id}, attachment id {transit_gateway_attachment_id} "578 f"and resource id {resource_id} "579 )580 self.logger.exception(error)581 raise...

Full Screen

Full Screen

transit.py

Source:transit.py Github

copy

Full Screen

...152 except Exception as e:153 print(e)154 def routetable_association_status(self,tgrtid,tgatid):155 try:156 res = self.client.get_transit_gateway_route_table_associations(157 TransitGatewayRouteTableId=tgrtid,158 Filters=[159 {160 'Name': 'transit-gateway-attachment-id',161 'Values': [tgatid]162 },163 ]164 )165 return res166 except Exception as e:167 print(e)168 169 def update_vpc_route_table(self,routetableid,tgwid):170 try:...

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