首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无服务器部署失败

无服务器部署失败
EN

Stack Overflow用户
提问于 2019-08-19 16:06:45
回答 1查看 652关注 0票数 0

我试图使用无服务器的方式将lambda函数部署到AWS。执行时

无服务器部署-详细

我每次都会收到以下错误:

无服务器错误 错误发生: mainTable -无效KeySchema:第一个> KeySchemaElement不是散列键类型(服务:AmazonDynamoDBv2 2;状态代码: 400;错误代码: ValidationException;请求ID: ValidationException)

我的serverless.yml看起来如下:

代码语言:javascript
复制
service: backend-1 # NOTE: update this with your service name


provider:
  name: aws
  runtime: nodejs10.x
  stage: dev
  region: eu-central-1


functions:
  graphql:
    handler: src/handler.graphql
    events:
    - http:
        path: graphql
        method: post
        cors: true

plugins:
- serverless-webpack
- serverless-offline

custom:
  webpack:
    webpackCOnfig: 'webpack.config.js'
    includeModules: true
    packager: 'npm'
  stage: ${opt:stage, self:provider.stage}

resources:
  Resources:
    mainTable:
      Type: AWS::DynamoDB::Table
      Properties:
        TableName: main_${self:custom.stage}
        AttributeDefinitions:
          - AttributeName: id
            AttributeType: S
          - AttributeName: sort
            AttributeType: S
        KeySchema:
          - AttributeName: id
            KeyType: HASH
          - AttributeName: sort
            KeyType: RANGE
        BillingMode: PAY_PER_REQUEST
        GlobalSecondaryIndexes:
        - IndexName: spinned-primary
          KeySchema:
          - AttributeName: id
            KeyType: RANGE
          - AttributeName: sort
            KeyType: HASH
          Projection:
            ProjectionType: ALL
    labelTable:
      Type: AWS::DynamoDB::Table
      Properties:
        TableName: labels_${self:custom.stage}
        AttributeDefinitions:
          - AttributeName: sort
            AttributeType: S
          - AttributeName: label
            AttributeType: S
        KeySchema:
          - AttributeName: sort
            KeyType: HASH
          - AttributeName: label
            KeyType: RANGE
        BillingMode: PAY_PER_REQUEST
        GlobalSecondaryIndexes:
        - IndexName: spinned-primary
          KeySchema:
          - AttributeName: sort
            KeyType: RANGE
          - AttributeName: label
            KeyType: HASH
          Projection:
              ProjectionType: ALL
    logTable:
      Type: AWS::DynamoDB::Table
      Properties:
        TableName: logs_${self:custom.stage}
        AttributeDefinitions:
          - AttributeName: id
            AttributeType: S
          - AttributeName: sort
            AttributeType: S
        KeySchema:
          - AttributeName: id
            KeyType: HASH
          - AttributeName: sort
            KeyType: RANGE
        BillingMode: PAY_PER_REQUEST

你们中有人能帮忙吗?

干杯!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-08-19 17:00:05

当使用KeySchemaElements时,散列键类型必须位于范围键类型之前。

在YAML中,对于自旋主键,在GSI上,必须将散列键类型放在范围键类型之前;切换它们,以便散列是该元素中的第一个键类型。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57560369

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档