簡體   English   中英

從上傳到 S3 的文件觸發的無服務器框架和 AWS Step Functions(AWS 狀態機)

[英]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

插件部分正在使用“無服務器步驟功能”插件

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 網關功能和計划以及雲監視事件來啟動狀態機。

有人能指出我正確的方向嗎?

謝謝

我認為這與亞馬遜州語言的區分大小寫有關。

嘗試更新StartAtimageWasUploadedEvent

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM