aws-lambda-step-function - 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 Lambda function connected to an AWS Step Function.

Here is a minimal deployable pattern definition in TypeScript:

import { LambdaToStepFunction } from '@aws-solutions-constructs/aws-lambda-step-function'; import * as stepfunctions from '@aws-cdk/aws-stepfunctions'; const startState = new stepfunctions.Pass(stack, 'StartState'); new LambdaToStepFunction(this, 'LambdaToStepFunctionPattern', { lambdaFunctionProps: { runtime: lambda.Runtime.NODEJS_12_X, handler: 'index.handler', code: lambda.Code.fromAsset(`${__dirname}/lambda`) }, stateMachineProps: { definition: startState } });


new LambdaToStepFunction(scope: Construct, id: string, props: LambdaToStepFunctionProps);


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.
stateMachineProps sfn.StateMachineProps User provided props for the sfn.StateMachine.
createCloudWatchAlarms boolean Whether to create recommended CloudWatch alarms.
logGroupProps? logs.LogGroupProps Optional user-provided props to override the default props for the CloudWatch Logs log group.

Pattern Properties

Name Type Description
cloudwatchAlarms? cloudwatch.Alarm[] Returns a list of one or more CloudWatch alarms created by the pattern.
lambdaFunction lambda.Function Returns an instance of the Lambda function created by the pattern.
stateMachine sfn.StateMachine Returns an instance of the state machine created by the pattern.
stateMachineLogGroup logs.LogGroup Returns an instance of the log group created by the pattern for the state machine.

Default settings

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

AWS Lambda Function

  • Configure a limited privilege access IAM role for the Lambda function.

  • Enable reusing connections with Keep-Alive for NodeJs Lambda functions.

  • Enable X-Ray tracing.

  • Set environment variables:


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

AWS Step Functions State Machine

  • Deploy best-practice CloudWatch alarms for the AWS Step Functions State Machine.



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