我遇到了以下错误。
无服务器:操作失败!
无服务器:操作失败!
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”重新开始部署,在此期间,我的数据库将清除所有数据...肯定有更好的方法吧。