无服务器框架和 AWS Step Functions(AWS 状态机)从上传到 S3 的文件触发
Serverless Framework and AWS Step Functions (AWS State Machine) triggered from a file uploaded to S3
我正在尝试在文件上传到 S3 存储桶后启动 AWS 状态机(步进函数)。
存储桶已经存在并且项目是使用无服务器框架创建的。
为此,我在 serverless.yml
中创建了这个函数
functions:
imagewasuploadedevent:
handler: src/stepfunctions/imageWasUploadedEvent.handler
events:
- s3:
bucket: !Ref AttachmentsBucket
existing: true
iamRoleStatements:
- Effect: "Allow"
Action:
- "states:StartExecution"
Resource:
- "*"
当文件上传到已经存在的 S3 存储桶“AttachmentsBucket”时应该触发此函数,我希望它启动状态机处理
Step Function 定义如下
stepFunctions:
stateMachines:
ValidateImageStateMachine:
definition:
Comment: "This state function validates the images after users upload them to S3"
StartAt: imagewasuploadedevent
States:
imageWasUploadedEvent:
Type: Task
Resource:
Fn::GetAtt: [imagewasuploadedevent, Arn]
End: true
插件部分正在使用“serverless-step-functions”插件
plugins:
- serverless-python-requirements
- serverless-iam-roles-per-function
- serverless-step-functions
但是,堆栈的 CloudFormation 失败并出现以下错误
An error occurred:
ValidateImageStateMachineStepFunctionsStateMachine - Invalid State Machine
Definition: 'MISSING_TRANSITION_TARGET: Missing 'Next' target: imagewasuploadedevent at /StartAt, MISSING_TRANSITION_TARGET: State "imageWasUploadedEvent" is not reachable. at /States/imageWasUploadedEvent' (Service: AWSStepFunctions; Status Code: 400; Error Code: InvalidDefinition; Request ID: 39217fe8-9dcd-4386-8549-b995619d2db6; Proxy: null).
我怀疑这与我正在做的事情无关,而是我们只能使用此插件通过 API 网关功能和计划以及云监视事件来启动状态机。
有人能给我指出正确的方向吗?
谢谢
我认为这与亚马逊州语言区分大小写有关。
尝试将 StartAt
更新为 imageWasUploadedEvent
stepFunctions:
stateMachines:
ValidateImageStateMachine:
definition:
Comment: "This state function validates the images after users upload them to S3"
StartAt: imageWasUploadedEvent
States:
imageWasUploadedEvent:
Type: Task
Resource:
Fn::GetAtt: [imagewasuploadedevent, Arn]
End: true
我正在尝试在文件上传到 S3 存储桶后启动 AWS 状态机(步进函数)。 存储桶已经存在并且项目是使用无服务器框架创建的。
为此,我在 serverless.yml
中创建了这个函数 functions:
imagewasuploadedevent:
handler: src/stepfunctions/imageWasUploadedEvent.handler
events:
- s3:
bucket: !Ref AttachmentsBucket
existing: true
iamRoleStatements:
- Effect: "Allow"
Action:
- "states:StartExecution"
Resource:
- "*"
当文件上传到已经存在的 S3 存储桶“AttachmentsBucket”时应该触发此函数,我希望它启动状态机处理
Step Function 定义如下
stepFunctions:
stateMachines:
ValidateImageStateMachine:
definition:
Comment: "This state function validates the images after users upload them to S3"
StartAt: imagewasuploadedevent
States:
imageWasUploadedEvent:
Type: Task
Resource:
Fn::GetAtt: [imagewasuploadedevent, Arn]
End: true
插件部分正在使用“serverless-step-functions”插件
plugins:
- serverless-python-requirements
- serverless-iam-roles-per-function
- serverless-step-functions
但是,堆栈的 CloudFormation 失败并出现以下错误
An error occurred:
ValidateImageStateMachineStepFunctionsStateMachine - Invalid State Machine
Definition: 'MISSING_TRANSITION_TARGET: Missing 'Next' target: imagewasuploadedevent at /StartAt, MISSING_TRANSITION_TARGET: State "imageWasUploadedEvent" is not reachable. at /States/imageWasUploadedEvent' (Service: AWSStepFunctions; Status Code: 400; Error Code: InvalidDefinition; Request ID: 39217fe8-9dcd-4386-8549-b995619d2db6; Proxy: null).
我怀疑这与我正在做的事情无关,而是我们只能使用此插件通过 API 网关功能和计划以及云监视事件来启动状态机。
有人能给我指出正确的方向吗?
谢谢
我认为这与亚马逊州语言区分大小写有关。
尝试将 StartAt
更新为 imageWasUploadedEvent
stepFunctions:
stateMachines:
ValidateImageStateMachine:
definition:
Comment: "This state function validates the images after users upload them to S3"
StartAt: imageWasUploadedEvent
States:
imageWasUploadedEvent:
Type: Task
Resource:
Fn::GetAtt: [imagewasuploadedevent, Arn]
End: true