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

gefragt vor 3 Jahren674 Aufrufe
1 Antwort
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  
            }  
        ]  
    },
beantwortet vor 3 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen