aws-apigateway-lambda - AWS Solutions Constructs

aws-apigateway-lambda

All classes are under active development and subject to non-backward compatible changes or removal in any future version. These are not subject to the Semantic Versioning model. This means that while you may use them, you may need to update your source code when upgrading to a newer version of this package.

Language Package
Python
aws_solutions_constructs.aws_apigateway_lambda
Typescript
@aws-solutions-constructs/aws-apigateway-lambda
Java
software.amazon.awsconstructs.services.apigatewaylambda

Overview

This AWS Solutions Constructs pattern implements an Amazon API Gateway REST API connected to an AWS Lambda function pattern.

Here is a minimal deployable pattern definition:

const { ApiGatewayToLambda } = require('@aws-solutions-constructs/aws-apigateway-lambda'); new ApiGatewayToLambda(stack, 'ApiGatewayToLambdaPattern', { lambdaFunctionProps: { runtime: lambda.Runtime.NODEJS_10_X, handler: 'index.handler', code: lambda.Code.asset(`${__dirname}/lambda`) } });

Initializer

new ApiGatewayToLambda(scope: Construct, id: string, props: ApiGatewayToLambdaProps);

Parameters

Pattern Construct Props

Name Type Description
existingLambdaObj? lambda.Function An optional, existing Lambda function to be used instead of the default function. If an existing function is provided, the lambdaFunctionProps property will be ignored.
lambdaFunctionProps? lambda.FunctionProps Optional user-provided properties to override the default properties for the Lambda function. Ignored if an existingLambdaObj is provided.
apiGatewayProps? api.LambdaRestApiProps Optional user-provided props to override the default props for the API.

Pattern Properties

Name Type Description
apiGatewayCloudWatchRole iam.Role Returns an instance of the IAM role created by the pattern that enables access logging from the API Gateway REST API to CloudWatch.
apiGatewayLogGroup logs.LogGroup Returns an instance of the log group created by the pattern that API Gateway REST API access logs are sent to.
lambdaFunction lambda.Function Returns an instance of the Lambda function created by the pattern.
restApi api.LambdaRestApi Returns an instance of the API Gateway REST API created by the pattern.

Default settings

Out-of-the-box implementation of this pattern without any overrides will set the following defaults:

Amazon API Gateway

  • Deploy an edge-optimized API endpoint

  • Enable CloudWatch logging for API Gateway

  • Configure least privilege access IAM role for API Gateway

  • Set the default authorizationType for all API methods to IAM

AWS Lambda Function

  • Configure least privilege access IAM role for Lambda function

  • Enable reusing connections with Keep-Alive for NodeJs Lambda function

Architecture