AWS API Gateway
Table of Contents
About
A simple AWS API Gateway Node.js application that creates rest resources from OpenAPI specification that doesn't overrides REST application.
Getting Started
Prerequisites
You need to set up your AWS security credentials before the code is able to connect to AWS. You can do this by creating a file named "credentials" at ~/.aws/ (C:\Users\USER_NAME.aws\ for Windows users) and saving the following lines in the file:
[default]
aws_access_key_id = <your access key id>
aws_secret_access_key = <your secret key>
See the Security Credentials page. It's also possible to configure your credentials via a configuration file or directly in source. See the AWS SDK for Node.js Developer Guide for more information.
Installing
Install all dependencies
npm install
Usage
This application connects to AWS API Gateway, creates rest resource. The script will automatically create the resource to API Gateway.
Arguments:
- --rest-api-id
The REST resource identifier. The REST resources will be looking for API Gateway - --parent-id
The parent root resource identifier. This is where the REST resources will be created under. - --swagger-file
The OpenAPI specs file. It is required to be yaml file.
To run:
node index.js --rest-api-id=k21xbs0us3 --parent-id=2wn64i --swagger-file="rest.yml"
node index.js --rest-api-id=k21xbs0us3 --parent-id=2wn64i --swagger-file="/home/users/Documents/rest.yml"
REST API Resources Architecture
/** this is your root resource '/' **/
/
| /pets
| /resource1
| /resource2
Get the rest-api-id and parent-id. Click one of your resources
/ /** parent-id: wsx234 **/
| /pets /** parent-id: y5xcy8 **/
| /resource1 /** parent-id: cv5vf2 **/
https://us-east-2.console.aws.amazon.com/apigateway/home?region={region}#/apis/{rest-api-id}/resources/{parent-id}