Skip to content

CloudFormation

Published On:
Nov 21, 2019
Last Updated:
Nov 21, 2019

Command-Line

To delete a stack:

Terminal window
$ aws cloudformation delete-stack --stack-name <stack_name> --region <region>

Python API

The first thing you have to do to interact with CloudFormation from boto3 is to create a CloudFormation client:

import boto3
cf = boto3.client('cloudformation')

describe_stacks() returns an dictionary which contains a Stacks key. This Stacks key contains an array where each element is a dictionary containing information about a particular stack.

import boto3
cf = boto3.client('cloudformation')
stacks = cf.describe_stacks(StackName='my-stack-name')
print(stacks)
# stdout:
# {
# 'Stacks': [
# {
# 'StackId': 'foo',
# ...
# }
# ]
# }