aws-events-rule-lambda - AWS Solutions Constructs


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

This AWS Solutions Construct implements an AWS Events rule and an AWS Lambda function.

Here is a minimal deployable pattern definition in TypeScript:

const { EventsRuleToLambdaProps, EventsRuleToLambda } from '@aws-solutions-constructs/aws-events-rule-lambda'; const props: EventsRuleToLambdaProps = { lambdaFunctionProps: { code: lambda.Code.fromAsset(`${__dirname}/lambda`), runtime: lambda.Runtime.NODEJS_12_X, handler: 'index.handler' }, eventRuleProps: { schedule: events.Schedule.rate(Duration.minutes(5)) } }; new EventsRuleToLambda(this, 'test-events-rule-lambda', props);


new EventsRuleToLambda(scope: Construct, id: string, props: EventsRuleToLambdaProps);


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.
eventRuleProps events.RuleProps User provided eventRuleProps to override the defaults

Pattern Properties

Name Type Description
eventsRule events.Rule Returns an instance of the Events rule created by the pattern.
lambdaFunction lambda.Function Returns an instance of the Lambda function created by the pattern.

Default settings

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

Amazon CloudWatch Events Rule

  • Grant least privilege permissions to CloudWatch Events to trigger the Lambda Function

AWS Lambda Function

  • Configure limited privilege access IAM role for Lambda function

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

  • Enable X-Ray tracing

  • Set environment variables:

    • AWS_NODEJS_CONNECTION_REUSE_ENABLED (for Node 10.x and higher functions)



To view the code for this pattern, create/view issues and pull requests, and more: