在 AWS 中使用 WaitCondtion 与创建策略
Using WaitCondtion vs Creation policy in AWS
我正在解决一个问题,我在 EC2 实例中将用户数据作为启动配置的一部分,它安装了 aws cli 和 python 包,有时 aws cli 和 python 没有得到安装并且 EC2 实例启动并且 运行。
我的用户数据中的代码
pip install awscli
为了解决这个问题,我查看了 aws documentation.I 发现有两种方法可以解决这个问题,使用带有 cfn 信号的 Waitcondition 和使用创建策略。
我想知道在我的情况下哪条路是前进的方向。
第三种方法(可能也是最简单的方法)是预烘焙自定义 AMI,您可以在其中手动安装 aws cli
和提到的 python 包,并调试可能出现的任何问题。
然后,不用 运行 使用 user-data
脚本创建新的 EC2 实例,只需 运行 您的自定义 AMI 和上述配置已经到位。这样,您的实例将启动得更快,并且您不必担心在该脚本执行期间可能发生的任何错误,因为该脚本已经被执行和测试。
AWS 文档说:
For Amazon EC2 and Auto Scaling resources, we recommend that you use a
CreationPolicy attribute instead of wait conditions.
Add a CreationPolicy attribute to those resources, and use the
cfn-signal helper script to signal when an instance creation process
has completed successfully.
You can use a wait condition for situations like the following:
To coordinate stack resource creation with configuration actions that
are external to the stack creation.
因为您的 EC2 实例是 cf 堆栈的一部分,所以您应该使用 CreationPolicy 属性。
查看 here 了解更多信息。
我正在解决一个问题,我在 EC2 实例中将用户数据作为启动配置的一部分,它安装了 aws cli 和 python 包,有时 aws cli 和 python 没有得到安装并且 EC2 实例启动并且 运行。
我的用户数据中的代码
pip install awscli
为了解决这个问题,我查看了 aws documentation.I 发现有两种方法可以解决这个问题,使用带有 cfn 信号的 Waitcondition 和使用创建策略。
我想知道在我的情况下哪条路是前进的方向。
第三种方法(可能也是最简单的方法)是预烘焙自定义 AMI,您可以在其中手动安装 aws cli
和提到的 python 包,并调试可能出现的任何问题。
然后,不用 运行 使用 user-data
脚本创建新的 EC2 实例,只需 运行 您的自定义 AMI 和上述配置已经到位。这样,您的实例将启动得更快,并且您不必担心在该脚本执行期间可能发生的任何错误,因为该脚本已经被执行和测试。
AWS 文档说:
For Amazon EC2 and Auto Scaling resources, we recommend that you use a CreationPolicy attribute instead of wait conditions.
Add a CreationPolicy attribute to those resources, and use the cfn-signal helper script to signal when an instance creation process has completed successfully.
You can use a wait condition for situations like the following:
To coordinate stack resource creation with configuration actions that are external to the stack creation.
因为您的 EC2 实例是 cf 堆栈的一部分,所以您应该使用 CreationPolicy 属性。 查看 here 了解更多信息。