AWS Step functions Api Gateway integration RequestBody.$ bug

0

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

asked 3 years ago643 views
1 Answer
0

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  
            }  
        ]  
    },
answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions