aws-s3-lambda - AWS Solutions Constructs

aws-s3-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_s3_lambda
Typescript
@aws-solutions-constructs/aws-s3-lambda
Java
software.amazon.awsconstructs.services.s3lambda

This AWS Solutions Constructs pattern implements an Amazon S3 bucket connected to an AWS Lambda function.

Here is a minimal deployable pattern definition:

const { S3ToLambdaProps, S3ToLambda } = require('@aws-solutions-constructs/aws-s3-lambda'); const stack = new Stack(app, 'test-s3-lambda-stack'); const props: S3ToLambdaProps = { lambdaFunctionProps: { code: lambda.Code.asset(`${__dirname}/lambda`), runtime: lambda.Runtime.NODEJS_12_X, handler: 'index.handler' } }; new S3ToLambda(stack, 'test-s3-lambda', props);

Initializer

new S3ToLambda(scope: Construct, id: string, props: S3ToLambdaProps);

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.
existingBucketObj? s3.Bucket An optional, existing bucket to be used instead of the default bucket. If an existing bucket is provided, the bucketProps property will be ignored.
bucketProps? s3.BucketProps Optional user-provided properties to override the default properties for the bucket. Ignored if an existingBucketObj is provided.
s3EventSourceProps? S3EventSourceProps Optional user provided props to override the default props for S3EventSourceProps

Pattern Properties

Name Type Description
lambdaFunction lambda.Function Returns an instance of the Lambda function created by the pattern.
s3Bucket s3.Bucket Returns an instance of the S3 bucket created by the pattern.
s3LoggingBucket? s3.Bucket Returns an instance of the logging bucket created by the pattern for the S3 bucket.

Default settings

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

Amazon S3 Bucket

  • Configure Access logging for S3 Bucket

  • Enable server-side encryption for S3 Bucket using AWS managed KMS Key

  • Turn on the versioning for S3 Bucket

  • Don't allow public access for S3 Bucket

  • Retain the S3 Bucket when deleting the CloudFormation stack

  • Enforce encryption of data in transit

AWS Lambda Function

  • Configure least privilege access IAM role for Lambda function

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

Architecture