I have the following code to deploy a Step Functions State Machine using CloudFormation:
...
DefinitionString:
!Sub
- |
{
"StartAt": "Save Artifact to S3",
"States": {
"Save Artifact to S3": {
"Type": "Task",
"Resource": ${lambdaArn},
"Next": "Format Notification"
},
"Format Notification": {
"Type": "Task",
"Resource": ${lambda2Arn},
"Next": "Publish to SNS"
},
"Publish to SNS": {
"Type": "Task",
"Resource": "arn:aws:states:::sns:publish",
"Parameters": {
"TopicArn": ${snsArn},
"Message.$": "$.message",
"Subject.$": "$.subject"
},
"End": true
}
}
}
- lambdaArn: !GetAtt SavetoS3Function.Arn
lambda2Arn: !GetAtt NotifyUserFunction.Arn
snsArn: !Ref NotifyUserTopic
...
Using SAM to deploy on AWS, I get the following error:
Invalid State Machine Definition: 'INVALID_JSON_DESCRIPTION: Unrecognized token 'arn': was expecting ('true', 'false' or 'null') at [Source: (String)...
Everything else looks correct, so what is going on here? All the Arns are being referred correctly inside the Definition String, so that's probably not the issue.
This should be a json, so lambdaArn
, lambda2Arn
and snsArn
should be in quotations:
{
"StartAt": "Save Artifact to S3",
"States": {
"Save Artifact to S3": {
"Type": "Task",
"Resource": "${lambdaArn}",
"Next": "Format Notification"
},
"Format Notification": {
"Type": "Task",
"Resource": "${lambda2Arn}",
"Next": "Publish to SNS"
},
"Publish to SNS": {
"Type": "Task",
"Resource": "arn:aws:states:::sns:publish",
"Parameters": {
"TopicArn": "${snsArn}",
"Message.$": "$.message",
"Subject.$": "$.subject"
},
"End": true
}
}