Using the CloudFormation AWS::Include Macro

Eden Hare
The Startup
6 min readFeb 8, 2021

--

If you have ever used an imperative programming language like Javascript, C, or Python, then you are familiar with the concept of importing or including other files into your code.

This is good as it promotes re-use and prevents “reinventing the wheel”. As a result, you can get your code written faster, deploy it sooner, and provide value to your user community.

CloudFormation cannot natively import another template or template section into the template it is processing. This is where the AWS::Include transformation comes to the rescue.

To see this in action, let’s start with a simple CloudFormation template as the basis for this discussion.

This is a very simple template. I have added the Parameters section and commented it out because we will be adding to it as we move along in this article. The template outputs the DomainName for the bucket. As we know, we don’t supply a name for the bucket, CloudFormation will generate a name for us. When we run this in the AWS Console, we will see:

--

--

The Startup
The Startup

Published in The Startup

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +772K followers.

Eden Hare
Eden Hare

Written by Eden Hare

Eden is the co-author of seven books and author of more than 100 articles and book chapters in technical, management, and information security publications.