Select Language:
If you’re trying to use CloudFormation parameters with Step Functions and run into errors, here’s a simple way to fix it. The problem typically happens because the JSON in the step function definition isn’t properly formatted or the parameter substitution isn’t working as expected.
First, look at the error message. It says that there’s an unrecognized token like ‘TestBucket’ in the JSON, which suggests that the parameter isn’t being inserted correctly into your definition string. To fix this, you need to make sure your parameter is properly referenced within the JSON.
Here’s a helpful approach:
- Define your parameters at the top, like ‘DestinationBucket’ and ‘StepFunctionName’.
- When building your state machine, use ‘DefinitionString’ with the correct JSON format.
- Substitute your parameters properly inside the JSON, making sure to format strings correctly. Use
${ParameterName}inside the JSON string.
For example:
DefinitionString: |-
{
“StartAt”: “Init”,
“TimeoutSeconds”: 4800,
“States”: {
“Init”: {
“Type”: “Pass”,
“Parameters”: {
“bucket.$”: “$.DestinationBucket”,
“LogGroups”: [],
“NextToken”: null,
“YesterdayStartTime”: “{% $toMillis($substring($fromMillis($toMillis($now()) – 86400000), 0, 10) & ‘T00:00:00.000Z’) %}”,
“YesterdayEndTime”: “{% $toMillis($substring($fromMillis($toMillis($now()) – 86400000), 0, 10) & ‘T23:59:59.999Z’) %}”,
“date_prefix”: “{% $fromMillis($toMillis($now()) – 86400000, \”[Y0001]/[M01]/[D01]\”, \”Z\”) %}”
},
“End”: true
}
},
“QueryLanguage”: “JSONata”
}
Notice the use of .Parameters with "$": "$.DestinationBucket" for string parameters, which ensures proper substitution. Also, avoid missing commas between JSON entries—it’s a common mistake.
Double-check your JSON syntax, and ensure that the parameter reference matches the way your template handles substitutions. This should fix the ‘Invalid JSON description’ error and let your state machine accept the parameterized bucket name successfully.




