【发布时间】:2022-01-03 05:06:56
【问题描述】:
我在 serverless.yml 文件中定义了一个这样定义的 AWS 步进函数。
functions:
create:
handler: create.main
events:
- http:
path: notes
method: post
cors: true
#authorizer: aws_iam
findMatchingAlerts:
handler: findMatchingAlerts.main
events:
- http:
path: findMatchingAlerts
method: post
cors: true
#authorizer: aws_iam
stepFunctions:
stateMachines:
hellostepfunc1:
name: CreateNewListingAndSendNotificationStateMachine
events:
- http:
path: CreateNewListing
method: post
- http:
path: FindMatchingAlerts
method: post
definition:
Comment: "Step function for inserting a new listing, looking up user alert filter, and sending out email notifications"
StartAt: CreateNewListing
States:
CreateNewListing:
Type: Task
Resource: "arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:${self:service}-${opt:stage}-create"
Next: FindMatchingAlerts
FindMatchingAlerts:
Type: Task
Resource: "arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:${self:service}-${opt:stage}-findMatchingAlerts"
End: true
CreateNewListing 和 FindMatchingAlerts 都是 2 个 lambda 函数。
这是我想要做的:我有一个前端 UI,带有一个按钮,按下时调用 step 函数,并将适当的输入传递给 step 函数进行处理,我目前有这样的事情:
return API.post("notes", "/CreateNewListing", {
body: input
});
但是,我可以从 AWS 控制台执行 step 功能。但是,当尝试将我的前端按钮与步进函数挂钩时,每当按下按钮时,我得到的是Error: network error,所以我猜测对步进函数的调用是不正确的。
有人可以帮助我吗?谢谢。
【问题讨论】:
标签: amazon-web-services aws-lambda aws-step-functions