删除 AWS CloudFormation 堆栈但保留 Route53 记录集
Delete AWS CloudFormation stack but preserve Route53 record set
上下文: 我一直在使用 CloudFormation 来配置应用程序资源,效果很好。但是,我最近将我的应用程序移到了不同的基础设施 (Kubernetes) 上,为了适应这一变化,我修改了 Route53 DNS 记录以指向新资源,并保留了 CloudFormation 创建的所有 AWS 资源。为清楚起见,我修改的 DNS 记录是作为 CloudFormation 堆栈的一部分创建的。
问题:我想删除现在未使用的资源,包括 CloudFormation 堆栈本身。但是,这样做要么会删除我很在意的一条DNS记录,要么会因为DNS记录被修改而删除失败,回滚整个操作。
问题:有没有人知道我可以删除 CloudFormation 堆栈的巧妙方法,同时仍然保留由它创建的 Route53 条目且停机时间为零?
注意:我不想手动删除 CloudFormation 创建的资源(DNS 记录除外),并让堆栈闲置。
拒绝 Route53 的删除权限并分 2 个阶段删除堆栈。
When stacks are in the DELETE_FAILED state because AWS CloudFormation
couldn't delete a resource, rerun the deletion with the
RetainResources parameter and specify the resource that AWS
CloudFormation can't delete. AWS CloudFormation deletes the stack
without deleting the retained resource. Retaining resources is
useful when you can't delete a resource, such as an S3 bucket that
contains objects that you want to keep, but you still want to delete
the stack. After you delete the stack, you can manually delete
retained resources by using their associated AWS service.
我最近需要保留使用 CloudFormation 创建的 Route53 记录。我根据@jarmod 的响应进行了以下练习,并且效果很好。这里的关键是:"DeletionPolicy" : "Retain"
更多信息就DeletionPolicy attribute。我还会注意到,当我应用更改集来更改我的删除策略时,CloudFormation 没有检测到 Route53 条目中的任何漂移。成功!
- 创建一个基本的 CloudFormation 堆栈;负载均衡器、ASG 和指向负载均衡器的 Route53 记录
- 使用 Route53 控制台更改 Route53 条目以指向另一个位置
- 通过更改集将
"DeletionPolicy" : "Retain"
应用到我的 Route53 资源块
- 从 AWS 控制台删除 CloudFormation 堆栈
- 确认删除堆栈后 Route53 仍然有您的条目
Image of CloudFormation Skipping Delete
上下文: 我一直在使用 CloudFormation 来配置应用程序资源,效果很好。但是,我最近将我的应用程序移到了不同的基础设施 (Kubernetes) 上,为了适应这一变化,我修改了 Route53 DNS 记录以指向新资源,并保留了 CloudFormation 创建的所有 AWS 资源。为清楚起见,我修改的 DNS 记录是作为 CloudFormation 堆栈的一部分创建的。
问题:我想删除现在未使用的资源,包括 CloudFormation 堆栈本身。但是,这样做要么会删除我很在意的一条DNS记录,要么会因为DNS记录被修改而删除失败,回滚整个操作。
问题:有没有人知道我可以删除 CloudFormation 堆栈的巧妙方法,同时仍然保留由它创建的 Route53 条目且停机时间为零?
注意:我不想手动删除 CloudFormation 创建的资源(DNS 记录除外),并让堆栈闲置。
拒绝 Route53 的删除权限并分 2 个阶段删除堆栈。
When stacks are in the DELETE_FAILED state because AWS CloudFormation couldn't delete a resource, rerun the deletion with the RetainResources parameter and specify the resource that AWS CloudFormation can't delete. AWS CloudFormation deletes the stack without deleting the retained resource. Retaining resources is useful when you can't delete a resource, such as an S3 bucket that contains objects that you want to keep, but you still want to delete the stack. After you delete the stack, you can manually delete retained resources by using their associated AWS service.
我最近需要保留使用 CloudFormation 创建的 Route53 记录。我根据@jarmod 的响应进行了以下练习,并且效果很好。这里的关键是:"DeletionPolicy" : "Retain"
更多信息就DeletionPolicy attribute。我还会注意到,当我应用更改集来更改我的删除策略时,CloudFormation 没有检测到 Route53 条目中的任何漂移。成功!
- 创建一个基本的 CloudFormation 堆栈;负载均衡器、ASG 和指向负载均衡器的 Route53 记录
- 使用 Route53 控制台更改 Route53 条目以指向另一个位置
- 通过更改集将
"DeletionPolicy" : "Retain"
应用到我的 Route53 资源块 - 从 AWS 控制台删除 CloudFormation 堆栈
- 确认删除堆栈后 Route53 仍然有您的条目
Image of CloudFormation Skipping Delete