@nona-creative/aws-cdk-api-gateway
v1.0.2
Published
AWS API Gateway package with CDK
Downloads
1
Readme
AWS API Gateway (CDK)
Installation
npm i -S @nona-creative/aws-cdk-api-gateway
Usage
Create the API Gateway stack
import { ApiGatewayStack } from '@nona-creative/aws-cdk-api-gateway' this.apiGatewayStack = new ApiGatewayStack(this.scope, `${this.id}-lambda-${this.stage}`, { stage: 'test', })
Create a Security Group for Lambda on the relevant VPC (if you are using VPC eg. using
@nona-creative/aws-cdk-vpc
)this.vpcStack.createSecurityGroup({ name: LAMBDA_VPC_SECURITY_GROUP_NAME, description: 'Lambda Security Group for app VPC', })
You can then attach API Gateway to Lambdas by adding the Lambdas as Resources and Methods on the API Gateway Stack instance, eg.
const books = this.apiGatewayStack.addResource('books', 'GET', getBooksLambda, this.apiGatewayStack.api.root) this.apiGatewayStack.addMethod('POST', createBooksLambda, books)