- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在使用无服务器框架时遇到了一些问题,因为我不小心在另一个服务上使用了相同的服务名称。
发生错误:tableX - TableX 已存在。
假设我有两个“serverless.yml”文件,它们都具有相同的服务名称。其中一个(我们称之为“test1”)拥有资源(DynamoDB 表),另一个则没有(“test2”)。就像下面的片段一样:
测试1
service: sandbox-core
provider:
name: aws
stage: core
runtime: nodejs6.10
region: sa-east-1
memorySize: 128
timeout: 300
resources:
Resources:
table3:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
TableName: SandboxTable3
AttributeDefinitions:
-
AttributeName: provider
AttributeType: S
-
AttributeName: appId
AttributeType: S
KeySchema:
-
AttributeName: provider
KeyType: HASH
-
AttributeName: appId
KeyType: RANGE
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
table4:
Type: 'AWS::DynamoDB::Table'
DeletionPolicy: Retain
Properties:
TableName: SandboxTable4
AttributeDefinitions:
-
AttributeName: session
AttributeType: S
KeySchema:
-
AttributeName: session
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 5
WriteCapacityUnits: 1
functions:
auth:
handler: handler.auth
events:
- http:
path: auth/{session}/{provider}/{appId}
method: get
cors: true
测试2
service: sandbox-core
provider:
name: aws
stage: core
runtime: nodejs6.10
region: sa-east-1
memorySize: 128
timeout: 300
functions:
createCustomData:
handler: handler.createCustomData
events:
- http:
path: teste2
method: post
cors: true
当我sls部署
“test1”时,他根据我的需要使用DeletionPolicy: Retain
创建表,对于具有非常明智的数据。然后我sls部署
“test2”具有其他功能但没有任何资源(DynamoDB表),他执行了预期的操作:跳过表的删除。
但是,当我再次部署“test1”时,他无法识别这些表,他开始“创建”现有表而不是更新它们,并且部署失败。
我需要未删除的表,并且需要服务上的功能。看起来 Cloud Formation 失去了对第一次部署时创建的表的跟踪。
我不想像 github thread 中所说的那样分离服务(仅用于资源) 。我需要正在运行的表,它有大量数据,备份和恢复到另一个表的成本太高,很多用户可能会受到影响。
那么,我如何告诉 Cloud Formation Stack 我正在更新该表,而不是尝试创建它?如何跟踪 Cloud Formation Stack 上的服务?而且,我如何防止在没有资源的情况下部署服务?
对于这种情况,最好的解决方案是什么?希望我的问题足够清楚,能够理解。
最佳答案
不存在与test2
相关的问题。
对于test1
,您可以多次sls部署
。
但是,如果您运行 sls remove
,当 dynamodb 在 serverless.yml
中设置为 Retain
时,dynamodb 表不会被删除。所以你不能用slsdeploy
再次创建它,因为同名资源已经存在。这是aws cloudformation中的设计。
您发现跳过资源的新功能已开放。我们必须等待该功能的开发和合并。我也在等待同样的解决方案。去那里投票吧!
就目前的情况,你必须备份dynamodb,销毁它,然后运行sls部署
,如果确实有问题,再恢复它。
我通常使用变量进行管理,例如
DeletionPolicy: ${self:custom.${self:custom.stage}.deletion_policy}
针对不同环境定制:
custom
dev:
deletion_policy: Delete
prod:
deletion_policy: Retain
关于amazon-web-services - 无服务器服务更新使用 DeletionPolicy 保留创建的 Dynamodb 表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47536542/
我目前正在将现有资源导入 CloudFormation 堆栈。为了导入资源 Foo,我在模板中描述其当前状态,将 DeletionPolicy 设置为 Retain,然后导入现有资源。到目前为止,一切
我正在尝试在 CloudFormation 模板中调整我的 DeletionPolicy: "DeletionPolicy":{ "Fn::If":[
我浏览了很多 CloudFormation 文档,但找不到任何将 DeletionPolicy 从 Retain 更新为 Delete 的引用已部署堆栈中的资源。 堆栈中部署的现有资源的 Dele
我创建了一个 CloudFormation 堆栈,然后使用变更集更新它以将 DeletionPolicy 更改为 Retain。 是否有任何方法可以查看实时堆栈中资源的 DeletionPolicy
我的一个 AWS CloudFormation 模板根据堆栈名称在变量中导出“stage”值(例如“dev”或“prod”),如下所示: Export: … Name: !Sub "$
作为一名 DevOps 人员,我想使用相同的模板来配置开发和生产堆栈...其中开发堆栈不应具有任何 DeletionPolicy,但生产堆栈应使用 DeletionPolicy 所以,乍一看,CFT
我创建了一个没有 DeletionPolicy 的存储桶,并且想要添加它。更新了我们的配置(在 serverless.yml 中),现在我们在云形成模板中看到 DeletionPolicy:retai
我在使用无服务器框架时遇到了一些问题,因为我不小心在另一个服务上使用了相同的服务名称。 发生错误:tableX - TableX 已存在。 假设我有两个“serverless.yml”文件,它们都具有
我正在尝试创建一个堆栈(请参阅下面的代码) 但我收到以下错误: There was an error creating this change set. The following resources
我正在尝试使用下面的 cloudoformation 模板创建 RDS 集群和 aurora 实例: { "AWSTemplateFormatVersion" : "2010-09-09"
您好,我正在尝试使用“IF”函数,就像 RDS DeletionPolicy 的云形成文档中提到的那样,但由于某种原因,它说我的函数不返回字符串。 AWS Documentation on condi
我正在使用下面的代码片段使用Cloudformation配置S3 Bucket 我想保留 S3 存储桶,从而使用DeletionPolicy。 Resources: S3Bucket: T
AWS docs for DeletionPolicy提及数据库集群的默认策略: For AWS::RDS::DBCluster resources, the default policy is Sn
我有一个具有以下内容的云形成模板,如果我删除堆栈,即使存储桶 DeletionPolicy 为 Retain,存储桶仍会删除。 Resources: mybucket123: Type:
我正在使用 CloudFormation 构建 AWS::DynamoDB::Table 资源,并将 DeletionPolicy 设置为 Retain。假设我对此逻辑资源的 AttributeDef
我是一名优秀的程序员,十分优秀!