【发布时间】:2017-11-25 20:59:17
【问题描述】:
是否可以获取 CloudFormation 堆栈的状态?如果有,怎么做?
我正在创建一个堆栈:
client = boto3.client('cloudformation',)
response = client.create_stack(
StackName=stackname,
...
)
我可以在 CloudFormation Web UI 中看到堆栈成功创建。
我尝试通过以下方式获取状态:
print(client.describe_stacks(stack_name_or_id=hostname))
但这会引发异常:
botocore.exceptions.ParamValidationError: Parameter validation failed:
Unknown parameter in input: "stack_name_or_id", must be one of: StackName, NextToken
所以我尝试等待堆栈部署并捕获异常:
while True:
time.sleep(5)
try:
print(client.describe_stacks(stack_name_or_id=stackname))
except botocore.exceptions.ParamValidationError:
pass
但我一点反应都没有; print 语句永远不会被调用。
【问题讨论】:
标签: python amazon-web-services boto3 amazon-cloudformation