更新失败后无法编辑 CloudFormation 堆栈?

Rom*_*der 4 amazon-ec2 amazon-web-services aws-cloudformation

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

Invalid value 'm4.large' for instanceType. LaunchPlan instance type does not match attribute value m4.xlarge
Run Code Online (Sandbox Code Playgroud)

回滚也失败,错误:

The following resource(s) failed to update: [TC2, TC1, TC3].
Run Code Online (Sandbox Code Playgroud)

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

This instance 'i-e5e8b063' is not in a state from which it can be stopped.
Run Code Online (Sandbox Code Playgroud)

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

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

除了吹掉堆栈并从我的备份中设计一个新的堆栈之外,我还有什么追索权吗?我完全不知所措。

Sam*_*ing 6

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

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

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

这些最佳实践以及其他最佳实践在https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/best-practices.html 中有详细说明