@nona-creative/aws-cdk-api-gateway

AWS API Gateway package with CDK

Usage no npm install needed!

<script type="module">
  import nonaCreativeAwsCdkApiGateway from 'https://cdn.skypack.dev/@nona-creative/aws-cdk-api-gateway';
</script>

README

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)