aws-cdk-lib.aws_events_targets.SfnStateMachineProps

interface SfnStateMachineProps

LanguageType name
.NETAmazon.CDK.AWS.Events.Targets.SfnStateMachineProps
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awseventstargets#SfnStateMachineProps
Javasoftware.amazon.awscdk.services.events.targets.SfnStateMachineProps
Pythonaws_cdk.aws_events_targets.SfnStateMachineProps
TypeScript (source)aws-cdk-lib » aws_events_targets » SfnStateMachineProps

Customize the Step Functions State Machine target.

Example

import * as iam from 'aws-cdk-lib/aws-iam';
import * as sfn from 'aws-cdk-lib/aws-stepfunctions';

const rule = new events.Rule(this, 'Rule', {
  schedule: events.Schedule.rate(Duration.minutes(1)),
});

const dlq = new sqs.Queue(this, 'DeadLetterQueue');

const role = new iam.Role(this, 'Role', {
  assumedBy: new iam.ServicePrincipal('events.amazonaws.com'),
});
const stateMachine = new sfn.StateMachine(this, 'SM', {
  definition: new sfn.Wait(this, 'Hello', { time: sfn.WaitTime.duration(Duration.seconds(10)) })
});

rule.addTarget(new targets.SfnStateMachine(stateMachine, {
  input: events.RuleTargetInput.fromObject({ SomeParam: 'SomeValue' }),
  deadLetterQueue: dlq,
  role: role
}));

Properties

NameTypeDescription
deadLetterQueue?IQueueThe SQS queue to be used as deadLetterQueue. Check out the considerations for using a dead-letter queue.
input?RuleTargetInputThe input to the state machine execution.
maxEventAge?DurationThe maximum age of a request that Lambda sends to a function for processing.
retryAttempts?numberThe maximum number of times to retry when the function returns an error.
role?IRoleThe IAM role to be assumed to execute the State Machine.

deadLetterQueue?

Type: IQueue (optional, default: no dead-letter queue)

The SQS queue to be used as deadLetterQueue. Check out the considerations for using a dead-letter queue.

The events not successfully delivered are automatically retried for a specified period of time, depending on the retry policy of the target. If an event is not delivered before all retry attempts are exhausted, it will be sent to the dead letter queue.


input?

Type: RuleTargetInput (optional, default: the entire EventBridge event)

The input to the state machine execution.


maxEventAge?

Type: Duration (optional, default: Duration.hours(24))

The maximum age of a request that Lambda sends to a function for processing.

Minimum value of 60. Maximum value of 86400.


retryAttempts?

Type: number (optional, default: 185)

The maximum number of times to retry when the function returns an error.

Minimum value of 0. Maximum value of 185.


role?

Type: IRole (optional, default: a new role will be created)

The IAM role to be assumed to execute the State Machine.