无服务器DynamoDB没有显示在AWS管理控制台中

时间:2019-12-17 17:34:39

标签: amazon-web-services aws-lambda amazon-dynamodb serverless

我正在学习使用无服务器框架来创建和管理AWS服务。我已经逐步完成了在无服务器站点上使用文档部署无服务器项目的步骤,但是由于某种原因,我无法在AWS管理控制台中看到DynamoDB表。

我已经检查过我使用的AWS Profile是否正确,当我从终端使用cURL时,我能够从表中发布并获取数据,并且能够在那些终端上查看数据在浏览器中,但是在serverless.yml文件之外的任何地方都看不到对创建的表的任何引用。这是为什么?请参阅下面的代码(在此链接上有完整的示例存储库:https://github.com/serverless/examples/tree/master/aws-node-rest-api-with-dynamodb)。

感谢您在这里学习细微差别的帮助。谢谢!


org: justinbell714
app: jb-test-from-docs
service: serverless-rest-api-with-dynamodb

frameworkVersion: ">=1.1.0 <2.0.0"

provider:
  name: aws
  runtime: nodejs10.x
  environment:
    DYNAMODB_TABLE: ${self:service}-${opt:stage, self:provider.stage}
  iamRoleStatements:
    - Effect: Allow
      Action:
        - dynamodb:Query
        - dynamodb:Scan
        - dynamodb:GetItem
        - dynamodb:PutItem
        - dynamodb:UpdateItem
        - dynamodb:DeleteItem
      Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"

functions:
  create:
    handler: todos/create.create
    events:
      - http:
          path: todos
          method: post
          cors: true

  list:
    handler: todos/list.list
    events:
      - http:
          path: todos
          method: get
          cors: true

  get:
    handler: todos/get.get
    events:
      - http:
          path: todos/{id}
          method: get
          cors: true

  update:
    handler: todos/update.update
    events:
      - http:
          path: todos/{id}
          method: put
          cors: true

  delete:
    handler: todos/delete.delete
    events:
      - http:
          path: todos/{id}
          method: delete
          cors: true

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

1 个答案:

答案 0 :(得分:3)

确保用于创建表的区域是您在AWS控制台中选择的区域。