1.0.2 • Published 3 years ago

@nona-creative/aws-cdk-api-gateway v1.0.2

Weekly downloads
155
License
MIT
Repository
-
Last release
3 years ago

AWS API Gateway (CDK)

Installation

npm i -S @nona-creative/aws-cdk-api-gateway

Usage

  1. 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',
    })
  2. 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',
    })
  3. 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)