gpt4 book ai didi

amazon-dynamodb - DynamoDB 表未在 serverless.yml 文件中创建

转载 作者:行者123 更新时间:2023-12-02 00:32:36 26 4
gpt4 key购买 nike

在运行 sls offline start 并尝试访问用户端点后出现错误 cannot do operation on a non-existent table。 serverless.yml文件如下:

service: 
name: digital-secret

plugins:
- serverless-dynamodb-local
- serverless-offline # must be last in the list

custom:
userTableName: 'users-table-${self:provider.stage}'
dynamoDb:
start:
migrate: true

provider:
name: aws
runtime: nodejs8.10
stage: dev
region: us-east-2
iamRoleStatements:
- Effect: Allow
Action:
- 'dynamodb:Query'
- 'dynamodb:Scan'
- 'dynamodb:GetItem'
- 'dynamodb:PutItem'
- 'dynamodb:UpdateItem'
- 'dynamodb:DeleteItem'
Resource:
- { "Fn::GetAtt": ["usersTable", "Arn"] }
environment:
USERS_TABLE: ${self:custom.userTableName}

functions:
app:
handler: index.handler
events:
- http: ANY /
- http: 'ANY {proxy+}'
user:
handler: index.handler
events:
- http: 'GET /users/{proxy+}'
- http: 'POST /users'

resources:
Resources:
usersTable:
Type: 'AWS::DynamoDB::Table'
Properties:
TableName: ${self:custom.userTableName}
AttributeDefinitions:
- AttributeName: userId
AttributeType: S
KeySchema:
- AttributeName: userId
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1

谁能帮忙指出这里有什么问题?我查看了文档和在线提供的许多不同示例,但我看到的与上面的没有什么不同。

最佳答案

serverless-dynamodb-local文档说 custom block 的结构应该是这样的:

custom:
dynamodb:
start:
migrate: true

你有 dynamoDb 而不是 dynamodb

关于amazon-dynamodb - DynamoDB 表未在 serverless.yml 文件中创建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51262660/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com