What CLI command will directly pull Transit Gateway route tables so I can get the destinations and attachments?

0

I was looking through the AWS CLI commands for Transit Gateway and I have settled on 'search-transit-gateway-routes' but I can't tell if that would actually get me the destination and attachments or just the ID of the transit gateway route table.

Do I need to use a filter with it like 'attachment.transit-gateway-attachment-id' or would 'attachment.resource-id' be more useful?

Maybe - aws ec2 search-transit-gateway-routes --transit-gateway-route-table-id tgw-rtb-valuegoeshere --filters "Name=state,Values=active"

I want to be able to create a query that I could use to pull the routes for several Transit Gateway so I could script it instead of manually reviewing things in the console. But I want to be able to actually see the entire route table for the transit gateway via the output.

質問済み 1ヶ月前118ビュー
2回答
2
承認された回答

Good answer from Riku_Kobayashi - I'd like to point out one other thing:

When you create a Transit Gateway there is a single route table. But Transit Gateways can have more than one route tables to enabled for attachment traffic separation (think, VRF-Lite in traditional routers).

So the way to see "entire route table for the transit gateway" is to look at all of them, understanding that a route table is associated with an attachment (which you could consider to be a router interface in the traditional sense - VPCs, Direct Connect, VPNs and SD-WAN appliances can all be attachments).

For more information: https://youtu.be/X_4ekgRc4C8?t=710

profile pictureAWS
エキスパート
回答済み 1ヶ月前
profile picture
エキスパート
レビュー済み 23日前
  • So I need to specifically query the list of attachments (route table IDs?) and then for each of the associated route tables in order to see all of the routes?

  • If you you're trying to map which VPCs (and other attachments) can reach specific routes then you will need both the routes that are in each route table; and the mapping of which route tables are assigned to each attachment. So listing the attachments and the route tables associated with them is a good start.

1

Hello.

I was looking through the AWS CLI commands for Transit Gateway and I have settled on 'search-transit-gateway-routes' but I can't tell if that would actually get me the destination and attachments or just the ID of the transit gateway route table.

An example output is provided in the document below, and the attachment ID, destination CIDR, etc. are output.
https://awscli.amazonaws.com/v2/documentation/api/latest/reference/ec2/search-transit-gateway-routes.html

In fact, if you run it using the "--filters "Name=state,Values=active"" you're expecting, you'll see output like the one below.
You can use "--filters "Name=state,Values=active"" to get routes with status "active".

{
    "Routes": [
        {
            "DestinationCidrBlock": "172.31.0.0/16",
            "TransitGatewayRouteTableAnnouncementId": "",
            "TransitGatewayAttachments": [
                {
                    "ResourceId": "vpc-d05042b7",
                    "TransitGatewayAttachmentId": "tgw-attach-1111111111",
                    "ResourceType": "vpc"
                }
            ],
            "Type": "propagated",
            "State": "active"
        }
    ],
    "AdditionalRoutesAvailable": false
}

Also, if you want to get a list of TransitGateway route table IDs, you can use "describe-transit-gateway-route-tables" as shown below.

aws ec2 describe-transit-gateway-route-tables --query "TransitGatewayRouteTables"[]."TransitGatewayRouteTableId" | jq -r .[]
profile picture
エキスパート
回答済み 1ヶ月前
profile pictureAWS
エキスパート
レビュー済み 1ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ