3

I need to export my route table detail to CSV. The goal is to load the CSV to a graphDB. What I need is the RoutetableID, CIDR block, Gateway and associated Subnet list as a CSV table. Would like to automate this as much as I can since I have several VPCs that I need to consolidate data for.

1- I can not find a BOTO3 query that provides this depth of detail. 2- AWS-config as well do not go to this depth. 3- AWS-CLI will get me the detail as a nested JSON. But here I loose the easy of automation.

Am I missing a detail here or does AWS not expose this detail for automation?

sirocco
  • 31
  • 4
  • I have gotten this code to get me the detail I need; ### Route Table list all details import boto3 from botocore.exceptions import ClientError ec2 = boto3.client('ec2') try: response = ec2.describe_route_tables() print(response) except ClientError as e: print(e) – sirocco May 19 '20 at 07:58

1 Answers1

2

In AWS EC2 CLI, using describe-route-tables (link) you can fetch routetableID, CIDR block, gateway and associated subnet list. If you use this CLI, the automation will be fetching your four key value from JSON, converting into an array and writing it in a CSV.

The boto3 equivalent for this will be using RouteTable and RouteTableAssociation. This is a good example in python.

bot
  • 1,293
  • 3
  • 17
  • 34