【发布时间】:2018-05-14 00:48:28
【问题描述】:
我有以下错误。
无服务器:操作失败!
Serverless Error ---------------------------------------
An error occurred: phoneNumberTable - CloudFormation cannot update a stack when a custom-named resource requires replacing. Rename mysite-api-phonenumber-dev and update the stack again…
我尝试删除数据库以查看是否可以重新创建它,但它仍然给出相同的错误并且没有重新创建数据库? 我在这里做什么?
我最近在我的 serverless.yml 文件中为资源更改了以下内容。
phoneNumberTable: #This table is used to track phone numbers used in the system
Type: AWS::DynamoDB::Table
Properties:
TableName: ${self:custom.phoneNumberTable}
AttributeDefinitions: #UserID in this case will be created once and constantly updated as it changes with status regarding the user.
- AttributeName: phoneNumber
AttributeType: S
KeySchema:
- AttributeName: phoneNumber
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: ${self:custom.dynamoDbCapacityUnits.${self:custom.pstage}}
WriteCapacityUnits: ${self:custom.dynamoDbCapacityUnits.${self:custom.pstage}}
我在复制和粘贴时不小心使用 userId 创建了它,因此我将其更改为 phoneNumber 作为哈希键,但现在不会反映更改!
编辑::
我找到了解决方案,但很糟糕。如果我执行 sls remove --stage dev 它将删除我的阶段的所有内容,但实际上所有内容......然后我必须执行 sls deploy --stage dev 重新开始部署,同时我的数据库被清除所有数据...必须有更好的方法。
【问题讨论】:
-
您的解决方案对我有好处...阶段是“开发”,在我的情况下丢失的数据不是问题。谢谢!
标签: amazon-web-services amazon-dynamodb amazon-cloudformation serverless-framework serverless