当使用AWS cloudformatoin启动EC2实例时,如何知道实例已经准备好

2024-05-07 14:38:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我现在使用我的脚本(Python)在使用awscloudformation创建堆栈后发送检查实例状态的请求。 但这似乎不是一个好的解决办法。然后我尝试使用cfn signal检查实例的状态,结果发现当接收到信号时cloudformation堆栈被成功创建,但EC2实例仍在检查中。在

当使用AWS cloudformatoin启动EC2实例时,如何知道实例已经准备好


Tags: 实例脚本awssignal信号堆栈状态ec2
1条回答
网友
1楼 · 发布于 2024-05-07 14:38:45

你可以考虑AWS的等待条件。基本上,WaitCondition与CloudFormation模板一起使用,以确保所需的资源正在运行。在

有关详细信息click here

以下片段摘自上述文章

What is WaitCondition and who needs it?

WaitCondition can be considered as a timed semaphore which pauses the execution of yourCloudFormation template and waits for a number of success signals before it continues a stack creation operation. There are scenarios where you need to pause the execution of your CloudFormation stack, such as resource dependencies or user experience. Some scenarios also include:

- As a part of user experience, you want to pause completion of CloudFormation template and display of the output section until all resources are properly provisioned and in working state.

- There are resource dependencies where some additional scripts and packages on your instance must be properly configured before other AWS resources can contact them. For example, for successful backend configuration, a front end application should be in running state.

- An environment in which Active Directory should be in a running state before other instances perform authentication.

- A NAT instance should be in working state before private subnet instances try to fetch packages from the outside world.

相关问题 更多 >