如何通过无服务器创建 AWS StateMachine Activity

How to create AWS StateMachine Activity via serverless

我正在尝试部署 Step Function,但我看不到在无服务器配置中定义 activity 的方法。 AWS 文档 https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-stepfunctions-activity.html 说 activity 应该这样定义,但每次我这样做 sls deploy 我都无法在步骤函数控制台中看到新的 activity。是否可以通过无服务器创建 activity,或者我必须手动 运行 script/create?

Resources:
MyActivity:
    Type: "AWS::StepFunctions::Activity"
    Properties:
      Name: myActivity


stepFunctions:
  stateMachines:
    stepfunctest:
      events:
        - http:
            path: step
            method: get
      definition:
        Comment: "A sample application"
        StartAt: extract
        States:
          extract:
            Type: Task
            Resource: "arn:aws:state:#{AWS::Region}:#{AWS::AccountId}:activity:MyActivity"
            End: true

假设您使用的是无服务器插件 https://github.com/serverless-operations/serverless-step-functions。您可以通过将 activity 添加到 stepFunction

来创建 activity
stepFuntions:
      activities:
        - myActivity
      stateMachines:
        stepfunctest:
          events:
            - http:
                path: step
                method: get
          definition:
            Comment: "A sample application"
            StartAt: extract
            States:
              extract:
                Type: Task
                Resource: "arn:aws:state:#{AWS::Region}:#{AWS::AccountId}:activity:MyActivity"
                End: true