Skip to main content

CloudFormation

Geoffrey Hunter
mbedded.ninja Author

Overview

Command-Line

To delete a stack:

$ 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',
# ...
# }
# ]
# }