由于错误而导致部署失败属性值变量必须是具有String(或简单类型)属性的对象

时间:2019-06-10 06:27:46

标签: node.js amazon-web-services aws-lambda serverless-framework

我收到无服务器错误,如下所示: 发生错误:CandidateSubmissionLambdaFunction-属性值变量必须是具有String(或简单类型)属性的对象。

我尝试将值从yml文件更改为字符串,然后我也遇到相同的错误。

我的Yml文件代码如下:


frameworkVersion: ">=1.1.0 <2.0.0"

provider:
  name: aws
  runtime: nodejs8.10
  stage: dev
  region: us-east-1
  environment:
    CANDIDATE_TABLE: ${self:service}-${opt:stage, self:provider.stage}
    CANDIDATE_EMAIL_TABLE: "candidate-email-${opt:stage, self:provider.stage}"
    iamRoleStatements:
      - Effect: Allow
        Action:
          - dynamodb:Query
          - dynamodb:Scan
          - dynamodb:GetItem
          - dynamodb:PutItem
        Resource: "*"

resources:
  Resources:
    CandidatesDynamoDbTable:
      Type: 'AWS::DynamoDB::Table'
      DeletionPolicy: Retain
      Properties:
        AttributeDefinitions:
          -
            AttributeName: "id"
            AttributeType: "S"
        KeySchema:
          -
            AttributeName: "id"
            KeyType: "HASH"
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1
        StreamSpecification:
          StreamViewType: "NEW_AND_OLD_IMAGES"
        TableName: ${self:provider.environment.CANDIDATE_TABLE}

functions:
  candidateSubmission:
    handler: api/candidate.submit
    memorySize: 128
    description: Submit candidate information and starts interview process.
    events:
      - http:
          path: candidates
          method: post 

环境信息

     OS:   linux
     Node Version:  8.10.0
     Serverless Version: 1.27.3

我想将其部署在aws上并想要执行凝乳操作。

1 个答案:

答案 0 :(得分:0)

YAML配置中用于值的变量之一可能是错误的类型。

${self:service}在YAML中未定义,但在

中被引用

provider:
  environment:
    CANDIDATE_TABLE: ${self:service}-${opt:stage, self:provider.stage}