最近,我们在一个DynamoDB表中添加了3个GSI,当运行CI/CD管道时,它说:
Cannot perform more than one GSI creation or deletion in a single update.建议解决方案
一种解决方法是将您的更改分解为一次只执行一个GSI更新。
例如,如果需要添加GSI并删除表中的GSI,请尝试以下操作:
Activestatus
。
然而,它应该如何通过CI/CD管道发生呢?这就是我们在SLS框架中的表定义的样子:
tableUsers:
Type: AWS::DynamoDB::Table
Properties:
TableName: users-${self:provider.stage}
AttributeDefinitions: BLA BLA BLA
BillingMode: PAY_PER_REQUEST
GlobalSecondaryIndexes:
- IndexName: ${self:custom.tableUsers.gsi1.name}假设我们用了几个月的代码库添加了3种不同的GSI。当是发布的时候,正如建议一次做一个索引时,是不是在第1步中,我们应该将定义更改为
GlobalSecondaryIndexes:
- IndexName: ${self:custom.tableUsers.gsi1.name}
- IndexName: ${self:custom.tableUsers.gsi2.name}而不是
GlobalSecondaryIndexes:
- IndexName: ${self:custom.tableUsers.gsi1.name}
- IndexName: ${self:custom.tableUsers.gsi2.name}
- IndexName: ${self:custom.tableUsers.gsi3.name}
- IndexName: ${self:custom.tableUsers.gsi4.name}查询仍将在代码库中引用gs3这一事实又如何呢?我不认为在部署代码库中删除它们会是一个很好的方法?另外,我们在每个版本上增加版本这一事实又如何?有更好的方法来代替吗?
发布于 2021-05-25 17:58:00
通常,持续交付的最佳实践是限制部署的规模和复杂性(而不是频繁、小规模的部署)。
当应用于Serverless时,这意味着您应该考虑将新的基础结构与应用程序代码分开部署。这种行为将防止这个问题,以及其他限制,这些限制并不总是明显的,但还是会突然出现。
考虑将架构更改部署到与应用程序代码不同的部署中的表中。然后,一旦验证了索引是否已经成功创建,就可以轻松地为这些索引添加新的查询。
https://stackoverflow.com/questions/67642109
复制相似问题