我有一个 AWS step 函数,它调用用 Golang 编写的 lambda 函数。由于某种原因,lambda 函数似乎无法读取 step 函数的输入。
拉姆达函数 -
package main
import (
"fmt"
"github.com/aws/aws-lambda-go/lambda"
)
type InEvent struct {
Name string `json:"name"`
}
type OutEvent struct {
Greeting string `json:"greeting"`
}
func HandleRequest(name InEvent) (OutEvent, error) {
var result OutEvent
result.Greeting = fmt.Sprintf("Hello %s!", name.Name)
return result, nil
}
func main() {
lambda.Start(HandleRequest)
}
阶跃函数 -
{
"Comment": "A Hello World example of the Amazon States Language using Pass states",
"StartAt": "Invoke Lambda function",
"States": {
"Invoke Lambda function": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"Parameters": {
"FunctionName": "arn:aws:lambda:us-west-1:301438421794:function:SF1_1:$LATEST",
"Payload": {
"Input.$": "$"
}
},
"End": true
}
}
}
阶跃函数的输入 -
{
"name": "ABCDE"
}
阶跃函数的输出 -
{
"ExecutedVersion": "$LATEST",
"Payload": {
"greeting": "Hello !"
},
"SdkHttpMetadata": {
"AllHttpHeaders": {
"X-Amz-Executed-Version": [
"$LATEST"
],
"x-amzn-Remapped-Content-Length": [
"0"
],
"Connection": [
"keep-alive"
],
"x-amzn-RequestId": [
"5f297331-8b1a-49a0-9ad9-17a78ec1cfd0"
],
"Content-Length": [
"22"
],
"Date": [
"Fri, 25 Dec 2020 19:58:20 GMT"
],
"X-Amzn-Trace-Id": [
"root=1-5fe6445c-5cb6860d2559230940506a2f;sampled=0"
],
"Content-Type": [
"application/json"
]
},
我希望 Output.Payload.greeting 是“Hello ABCDE!” 而是 Output.Payload.greeting 是“你好!”
这里出了什么问题?为什么 lambda 函数中的 name 变量没有正确存储输入?为什么“ABCDE”在 lambda 函数中会变成一个空字符串?
当我直接在 lambda 控制台上测试 lambda 函数而不使用步进函数时,一切正常。
海绵宝宝撒
慕娘9325324
相关分类