gpt4 book ai didi

amazon-web-services - 更新失败后无法编辑 CloudFormation 堆栈?

转载 作者:行者123 更新时间:2023-12-03 21:30:11 28 4
gpt4 key购买 nike

我的 CloudFormation 堆栈似乎已经爆炸。我尝试快速更改以调整 EC2 实例的大小,但更新失败并出现错误:

Invalid value 'm4.large' for instanceType. LaunchPlan instance type does not match attribute value m4.xlarge

回滚也失败并出现错误:

The following resource(s) failed to update: [TC2, TC1, TC3].

右键单击堆栈时我唯一的选择是删除,并尝试通过操作菜单强制继续更新会产生:

This instance 'i-e5e8b063' is not in a state from which it can be stopped.

查看 EC2 实例控制台,我可以看到此消息至少是正确的:所有实例都列为已终止。

这里关于如何处理更新失败的所有建议似乎都基于我实际上能够修改堆栈以首先修复错误,但我无法做到这一点:http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/troubleshooting.html#troubleshooting-errors-update-rollback-failed

除了清除堆栈并从备份中设计一个新堆栈之外,我还有其他办法吗?我完全不知所措。

最佳答案

CloudFormation 尝试采用声明式方式,并尝试能够从您开始的位置移动到模板中的状态。有时,它会进入不一致的状态(当给出错误的模板或在 CloudFormation 外部进行手动更改时)。当这种情况发生在我身上时,CloudFormation 通常会正确回滚,但如果没有,我只能成功删除堆栈并从头开始。

因此,CloudFormation 中有两件事很重要:

  1. 使用多层。例如,FooDev 和 FooProd CloudFormation 堆栈,以便您可以在 Dev 中进行测试(尤其是升级等),而不是破坏 Prod。
  2. 使用多个堆栈。例如,您的数据库堆栈应该是长期存在且有状态的,因此它可能会拥有自己的堆栈,您应该小心对待它们,而您的 EC2 实例应该是短暂且无状态的,因此如果您搞砸了一个堆栈,那也没关系。部署其中之一。

这些最佳实践以及其他最佳实践详见 https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/best-practices.html

关于amazon-web-services - 更新失败后无法编辑 CloudFormation 堆栈?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38464908/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com