无服务器步骤功能状态机未在 sls 部署时创建。

问题描述 投票:0回答:1

我试图在我的无服务器应用程序中设置一个步骤函数,但当我将应用程序部署到aws时,状态机没有为步骤函数创建。这是我的lambda文件。我不知道我做错了什么,但我的设置中一定有什么东西导致状态机创建失败。

service: help-please

provider:
  name: aws
  versionFunctions: false
  runtime: nodejs12.x
  vpc:
    securityGroupIds:
      - sg
    subnetIds:
      - subnet
      - subnet
  stage: dev
  region: us-west-2
  iamRoleStatements:
    - Effect: 'Allow'
      Action:
        - 'xray:PutTraceSegments'
        - 'xray:PutTelemetryRecords'
        - 'sns:*'
        - 'states:*'
      Resource: '*'

functions:
upsertNewCustomerRecord:
    handler: .build/handler.upsertNewCustomerRecord
    iamRoleStatements:
      - Effect: 'Allow'
        Action:
          - logs:CreateLogGroup
          - logs:CreateLogStream
          - logs:PutLogEvents
          - logs:DescribeLogGroups
          - ec2:CreateNetworkInterface
          - ec2:DescribeNetworkInterfaces
          - ec2:DeleteNetworkInterface
          - cognito-idp:AdminInitiateAuth
          - ccognito-idp:DescribeUserPool
          - cognito-idp:DescribeUserPoolClient
          - cognito-idp:ListUserPoolClients
          - cognito-idp:ListUserPools
          - 'xray:PutTraceSegments'
          - 'xray:PutTelemetryRecords'
        Resource: '*'
  sendNewCustomerEmail:
    handler: .build/handler.sendNewCustomerEmail
    iamRoleStatements:
      - Effect: 'Allow'
        Action:
          - logs:DescribeLogGroups
          - logs:CreateLogGroup
          - logs:CreateLogStream
          - logs:PutLogEvents
          - ec2:CreateNetworkInterface
          - ec2:DescribeNetworkInterfaces
          - ec2:DeleteNetworkInterface
          - cognito-idp:AdminInitiateAuth
          - ccognito-idp:DescribeUserPool
          - cognito-idp:DescribeUserPoolClient
          - cognito-idp:ListUserPoolClients
          - cognito-idp:ListUserPools
          - 'xray:PutTraceSegments'
          - 'xray:PutTelemetryRecords'
        Resource: '*'
  upsertCognitoUser:
    handler: .build/handler.upsertCognitoUser
    iamRoleStatements:
      - Effect: 'Allow'
        Action:
          - logs:CreateLogGroup
          - logs:CreateLogStream
          - logs:PutLogEvents
          - logs:DescribeLogGroups
          - ec2:CreateNetworkInterface
          - ec2:DescribeNetworkInterfaces
          - ec2:DeleteNetworkInterface
          - cognito-idp:AdminInitiateAuth
          - ccognito-idp:DescribeUserPool
          - cognito-idp:DescribeUserPoolClient
          - cognito-idp:ListUserPoolClients
          - cognito-idp:ListUserPools
          - 'xray:PutTraceSegments'
          - 'xray:PutTelemetryRecords'
        Resource: '*'

stepFunctions:
  stateMachines:
    signupstepfunc:
      definition:
        Comment: 'Sign up step function'
        StartAt: UpsertNewCustomerRecord
        States:
          UpsertNewCustomerRecord:
            Type: Task
            Resource: 'arn'
            Next: SendNewCustomerEmail
          SendNewCustomerEmail:
            Type: Task
            Resource: 'arn'
            Next: UpsertCognitoUser
          UpsertCognitoUser:
            Type: Task
            Resource: 'arn'
            End: true

plugins:
  - serverless-plugin-typescript
  - serverless-offline
  - serverless-iam-roles-per-function
  - serverless-plugin-tracing
  - serverless-step-functions
  - serverless-pseudo-parameters
  - serverless-prune-plugin
node.js yaml serverless state-machine aws-step-functions
1个回答
0
投票

通过提供的 yaml 文件,我认为问题可能出在你的函数定义的缩进处。

functions:
upsertNewCustomerRecord:
    handler: .build/handler.upsertNewCustomerRecord
    iamRoleStatements:

必须用这个代替

functions:
  upsertNewCustomerRecord:
    handler: .build/handler.upsertNewCustomerRecord
    iamRoleStatements:

你能不能改一下,然后再试一次?


0
投票

不幸的是,我发现我在我的buildpec文件中抠了一个斜杠,这就是导致这种情况发生的原因,要小心这样做,因为当使用serverless部署时,你的build不会失败,你将不得不挖掘每一个文件,只是为了找出发生了什么。只是一些需要记住的东西。

© www.soinside.com 2019 - 2024. All rights reserved.