A Minimum Viable CloudFormation Template

Watching the clouds form

Sometimes when testing CloudFormation features I need a minimum viable template to try that feature with.

(Like my Ansible Minimum Viable Playbook).

Here’s the basic template I use:

AWSTemplateFormatVersion: 2010-09-09

Resources:
  Topic:
    Type: AWS::SNS::Topic

It has two things:

I can then change it according to what I want to test, for example adding parameters, outputs, or referencing resources. This is easier and faster than testing as part of a larger CloudFormation template.

Testing a Bug

As an example, I used this template to test for an old bug.

Previously, if you changed a template to only add a DeletionPolicy to a resource, CloudFormation would succeed but not actually add the policy. Then if you deleted the stack, CloudFormation would delete the resource, even though you thought it wouldn’t.

I tested this in a minute with my MVP template. I created a stack from the above basic template, then updated it with this template:

AWSTemplateFormatVersion: 2010-09-09

Resources:
  Topic:
    DeletionPolicy: Retain  # Added
    Type: AWS::SNS::Topic

The I deleted the stack and SNS retained the topic.

Nice to know AWS have fixed the bug, although I don’t recall it ever being publicly acknowledged, or mentioned on the release history.

Fin

Hope this helps you with testing CloudFormation!

—Adam


Newly updated: my book Boost Your Django DX now covers Django 5.0 and Python 3.12.


Subscribe via RSS, Twitter, Mastodon, or email:

One summary email a week, no spam, I pinky promise.

Related posts:

Tags: ,