Is it possible to get the status of a CloudFormation stack? If so, how?
I'm creating a stack with:
client = boto3.client('cloudformation',)
response = client.create_stack(
StackName=stackname,
...
)
I can see in the CloudFormation web UI that the stack successfully creates.
I've tried to get the status with:
print(client.describe_stacks(stack_name_or_id=hostname))
But that throws exception:
botocore.exceptions.ParamValidationError: Parameter validation failed:
Unknown parameter in input: "stack_name_or_id", must be one of: StackName, NextToken
So I tried to wait while the stack deploys and catch the exception with:
while True:
time.sleep(5)
try:
print(client.describe_stacks(stack_name_or_id=stackname))
except botocore.exceptions.ParamValidationError:
pass
But I get no response at all; the print statement never gets called.
The error message:
Unknown parameter in input: "stack_name_or_id", must be one of: StackName, NextToken
clearly says you are passing invalid parameter name; stack_name_or_id.
In Boto3 describe_stacks, the expected parameter is: StackName
response = client.describe_stacks(
StackName='string',
NextToken='string'
)
For a running stack, you can pass stack name or stack ID. But for deleted stacks, you have to pass stack ID.
client.describe_stacks(StackName='mystack')
{u'Stacks': [{u'StackId': 'arn:aws:cloudformation:us-east-1:.......
'content-type': 'text/xml',
'date': 'Thu, 22 Jun 2017 14:54:46 GMT'}}}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With