以下是更多详细信息:
工作空间-A(基础堆栈):此工作空间包含将创建 AWS 的代码:VPC、SG、路由表、子网和相关关联等。
工作区-B(Service-1 堆栈):此工作区包含用于创建 AWS 的代码:ALB、一些使用 Fargate 的 ECS 容器以及与此服务相关的一些其他组件。
现在,在上述情况下,任何服务(Service-1、2、3 等)都将使用 Workspace-A 创建的 VPC/基础堆栈,我们如何使用 Workspace A(VPC、SG、子网等)的输出作为变量工作区 B 以便工作区 B 可以使用这些 VPC 和其余组件。
我正在尝试使用 boto3 编写一个脚本来启动一个实例并等待它启动。根据wait_until_running的文档,它应该等到实例完全启动(我假设检查应该没问题)但不幸的是它只适用于wait_until_stopped和incase wait_until_running它只是启动实例而不是等到它完全开始了。不确定我在这里做错了什么,或者这是 boto3 的错误。
这是代码:
import boto3
ec2 = boto3.resource('ec2',region_name="ap-southeast-2")
ec2_id = 'i-xxxxxxxx'
instance = ec2.Instance(id=ec2_id)
print("starting instance " + ec2_id)
instance.start()
instance.wait_until_running()
print("instance started")
Run Code Online (Sandbox Code Playgroud)