aws-events-rule-lambda - AWS Solutions Constructs

aws-events-rule-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_events_rule_lambda
Typescript
@aws-solutions-constructs/aws-events-rule-lambda
Java
software.amazon.awsconstructs.services.eventsrulelambda

This AWS Solutions Constructs pattern implements an AWS Events rule and an AWS Lambda function.

Here is a minimal deployable pattern definition:

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

Initializer

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

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.
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 least privilege access IAM role for Lambda function

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

Architecture