I have an AWS Step Functions state machine defined in a json file, in step1
(a lambda task), I saved three parameters in the ResultPath
:
"NeededParameters": {
"year": "2021",
"month": "04",
"day": "27"
},
In step2
(also a lambda task), I understand that if I do something like:
"Step 2" : {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"Parameters": {
"FunctionName":"${lambda_name}",
"Payload":{
"year.$": "$.NeededParameters.year"
}
},
"ResultPath": "$.Step2",
"year.$": "$.NeededParameters.year"
will pass 2021
to payload Year
.
But what I want to achieved is to define an Amazon S3 path which includes the three parameters, something like:
"Step 2" : {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"Parameters": {
"FunctionName":"${lambda_name}",
"Payload":{
"s3path.$":"${s3_bucket_name}/$.NeededParameters.year/$.NeededParameters.month/$.NeededParameters.day"
}
},
"ResultPath": "$.Step2",
s3_bucket_name
is defined in Terraform resource "aws_sfn_state_machine" "sfn_state_machine"
and pass to the statemachine definition json file above, but when I apply terraform it complains:
InvalidDefinition: Invalid State Machine Definition: 'SCHEMA_VALIDATION_FAILED: The value for the field 's3path.$' must be a valid JSONPath at /States/Process Scores/Parameters'
if I change s3path.$
to s3path
it still not working, does anyone know how to resolve this? Thanks.
As the error message implies, the string you pass to s3path.$
is not valid JSONPath. If you want to pass some static value, you need to name it without .$
at the end (simply s3path
), otherwise, like in your case, it will be treated and validated as a JSONPath.
Static params don't support any kind of string expansion to my knowledge, especially involving JSONPath. I would suggest passing param called s3BucketName
in addition to year, month and day, and then simply construct S3 URL inside lambda function itself.