Search code examples
amazon-web-servicesaws-api-gatewayjqboto

boto script to list all api gateway deployments


I have several API's deployed using gateway. How do I list all of them along with details like type of integration (like lambda) and method response (like 200) in tabular format?


Update: As suggested in the answer, I can use "get-rest-apis" method to get the list of all API ID's. The json data can be converted to pandas dataframe like this...

# aws apigateway get-rest-apis --region=us-east-1 > /tmp/to_file.json

import pandas as pd
import json
from pandas.io.json import json_normalize

with open("to_file.json") as f:
    data = json.load(f)

df = json_normalize(data, "items")

df["createdDate"] = pd.to_datetime(df["createdDate"], unit="s").dt.date
df = df.sort_values(["createdDate"])

df["endpointConfiguration.types"] = df["endpointConfiguration.types"].str[0]

But how do I query to get details of each ID?


In order to get the complete picture of a given API, I need to query several methods like get-integration, get-method-response, get-resource. Each one of these has different number of required parameters that makes the automation process very difficult.


Solution

  • Although it might not satisfy all of your requirements (or it might be just what you need), easiest and most standardized way of achieving what you want is to export your REST API to an OpenAPI format (former "Swagger" format). Support for version 3.0 was recently added to API Gateway. You may augment/extend the output JSON with additional information that you need.

    Official documentation: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-export-api.html