I am trying to trigger an SFN using SQS + Pipes, and I wanted to know if it's possible to configure the name of the SFN execution based on the payload.
Example: If the event is as follows:
{"orderId": "abc-123", "eventType": "ORDER_CREATED", "timestamp": "2025-06-10T12:00:00Z"}
I want the name of the SFN execution to be the orderId
.
I tried to declare the name as follows:
but it doesn't work and the SFN execution name seems to be the randomly generated one.
this can be possible to have, configuring SFN execution name is based on the SQS message payload
sample sqs message is as follows,
{
"orderId": "abc-123",
"eventType": "ORDER_CREATED",
"timestamp": "2025-06-10T12:00:00Z",
"orderDetails": {
"customerId": "CUST001",
"amount": 100.50,
"items": [
{
"productId": "PROD1",
"quantity": 2
}
]
}
}
and with when using EventBridge Pipes configuration code yaml sample as follows,
# EventBridge Pipe configuration
Resources:
SQSToStepFunctionsPipe:
Type: AWS::Pipes::Pipe
Properties:
Name: sqs-to-sfn-pipe
RoleArn: !GetAtt PipeRole.Arn
Source: !GetAtt SourceQueue.Arn
Target: !Ref StateMachineArn
TargetParameters:
StepFunctionsParameters:
ExecutionNamePrefix: !Sub "${AWS::StackName}-"
Name: <$.orderId> # This will use the orderId from the message
# IAM Role for the Pipe
PipeRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Principal:
Service: pipes.amazonaws.com
Action: sts:AssumeRole
Policies:
- PolicyName: PipeAccess
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- sqs:ReceiveMessage
- sqs:DeleteMessage
- sqs:GetQueueAttributes
Resource: !GetAtt SourceQueue.Arn
- Effect: Allow
Action:
- states:StartExecution
Resource: !Ref StateMachineArn
This will be easier for AWS CDK,
import * as pipes from '@aws-cdk/aws-pipes-alpha';
const pipe = new pipes.CfnPipe(this, 'SQSToStepFunctionsPipe', {
name: 'sqs-to-sfn-pipe',
roleArn: pipeRole.roleArn,
source: sourceQueue.queueArn,
target: stateMachine.stateMachineArn,
targetParameters: {
stepFunctionsParameters: {
executionNamePrefix: `${Stack.of(this).stackName}-`,
name: '<$.orderId>',
input: JSON.stringify({
executionId: '<$.orderId>',
type: '<$.eventType>',
customer: '<$.orderDetails.customerId>',
orderAmount: '<$.orderDetails.amount>',
processedTimestamp: '<$.timestamp>',
itemCount: '<$.orderDetails.items[0].quantity>'
})
}
}
});