微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

从上载到S3的文件触发了无服务器框架和AWS步骤功能AWS状态机

如何解决从上载到S3的文件触发了无服务器框架和AWS步骤功能AWS状态机

文件上传到S3存储桶后,我正在尝试启动AWS State Machine(步进功能)。 存储桶已经存在,并且已使用Serverless Framework创建了项目。

为此,我在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”中并且希望它启动状态机处理时,应该触发该功能

现在“步进功能”定义在下面

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网关功能,日程表和云监视事件来启动状态机。

有人能指出我正确的方向吗?

谢谢

解决方法

我认为这与亚马逊国家语言的区分大小写有关。

尝试使用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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。