Empty CloudFormation Stacks using WaitConditionHandle

Using the WaitConditionalHandle to construct CloudFormation stacks without AWS resources

Table Of Contents

Today I Explained

CloudFormation Templates have a requirement that at least one resource exists within the CloudFormation, which prevents stacks from being created that contain only outputs. An alternative to creating a dummy resource like AWS::IAM::Role is to make use of WaitConditionHandle.

Using a WaitConditionHandle does introduce complexity because it doesn’t support an update action, which is why when prototyping with WaitConditionHandle, it will be necessary to generates a random logical ID for this WaitConditionHandle to force updates. Using a resource like AWS::IAM::Role has the potential to avoid that, but ultimately means introducing another Amazon Web Service (AWS) service like IAM into the mix.

You can create these empty stacks like so:

---
# A CloudFormation Template that contains no resources, allowing for an "empty" CloudFormation stack to be created.

# CloudFormation Stacks require at minimum one resource to be defined, and using the `WaitConditionHandle` allows this
# condition to be satisified, without requiring the CloudFormation Stack to provision any "unnecessary" resources. This makes
# it easier when experimenting with function oriented transformations (FindInMap/Mappings/etc).
AWSTemplateFormatVersion: '2010-09-09'

# The empty resource configuration that allows for testing against just mappings, parameters, and
# outputs. To force a new update, the `LogicalID` of this must be re-generated as this resource
# does not support updates.
Resources:
  WaitHandle:
    Type: AWS::CloudFormation::WaitConditionHandle

# -------------------------------------------------
Description: An empty CloudFormation Template