AWS Step functions Api Gateway integration RequestBody.$ bug
I have a state machine splitted in some different lambdas to complete a process. One of the steps is a call to apigateway lambda function. Previous call is a call to lambda function and in ASL language I tell to pass the object overrided by this function to the next step.
When it comes to Apigateway step, PathParameters are filled ok with the jsonpath accessors but when I try to use in RequestBody the received value are always empty.
I'm using golang language
State Machine
"UploadFile": {
"Type": "Task",
"Resource": "${UploadFileFunctionArn}",
"Retry": [
{
"ErrorEquals": [
"States.TaskFailed"
],
"IntervalSeconds": 2,
"MaxAttempts": 3,
"BackoffRate": 2.0
}
],
"Catch": [
{
"ErrorEquals": [
"States.ALL"
],
"ResultPath": null,
"Next": "Fail"
}
],
"ResultPath": "$",
"Next": "UpdateTerminal"
},
"UpdateTerminal": {
"Type": "Task",
"Next": "HasBeenUpdated",
"Resource": "${UpdateTerminalFunctionArn}",
"Parameters": {
"ApiEndpoint": "${APIDomainName}/${APIBasePath}",
"Method": "POST",
"Stage": "${ApiStageName}",
"Path": "",
"PathParameters": {
"terminalId.$": "$.terminalId"
},
"RequestBody.$": "$",
"AuthType": "NO_AUTH"
},
"Retry": [
{
"ErrorEquals": [
"States.TaskFailed"
],
"IntervalSeconds": 2,
"MaxAttempts": 3,
"BackoffRate": 2.0
}
]
},
Update terminal lambda logs :
fmt.Println("request.Body", request.Body)
fmt.Println("request.PathParameters['terminalId']", request.PathParameters["terminalId"])
2020-12-07T13:55:23.889+01:00 request.Body
2020-12-07T13:55:23.889+01:00 request.PathParameters\['terminalId'] dc725a3a-0b96-4b14-8036-5c36514466556
Edited by: eguzkilorebeltza on Dec 7, 2020 5:08 AM
I could solve this isuse after so many different tries. In golang I found that you have to specify in Parameters object Body field not as documentation says RequestBody
"Body.$": "States.JsonToString($)",
"UpdateTerminal": {
"Type": "Task",
"Next": "HasBeenUpdated",
"Resource": "${UpdateTerminalApiFunctionArn}",
"Parameters": {
"ApiEndpoint": "${APIDomainName}/${APIBasePath}",
"Method": "POST",
"Stage": "${ApiStageName}",
"Path": "",
"PathParameters": {
"terminalId.$": "$.terminalId"
},
**"Body.$": "States.JsonToString($)",**
"AuthType": "NO_AUTH"
},
"Retry": \[
{
"ErrorEquals": \[
"States.TaskFailed"
],
"IntervalSeconds": 2,
"MaxAttempts": 3,
"BackoffRate": 2.0
}
]
},
Relevant questions
AWS Step functions Api Gateway integration RequestBody.$ bug
asked a year agoWhy aren't the HTTP headers passed from API Gateway to Step Functions?
asked 5 months agoWhen to invoke a lambda directly or via API Gateway
asked 5 months agoCan I specify GET URL path parameter in step function?
asked 2 months agoApiGateway REST not respecting Lambda alias
Accepted Answerasked 5 months agoHTTP API Integration with lamda function and stage variable not working
asked 9 months agoThrottlingException from Step Function triggered through API Endpoint
asked 2 years agoS3 object and lambda function in step machine with the asynchronous express workflows
Accepted Answerasked 4 months agohow to trigger a step function from a s3 object notification?
asked a month agoLambda function won't run in parallel via State Machines
asked 4 months ago