Cloudformation Transform::Include Limitations

It’s been now a few days since I’ve played with Transform::Include.

There’s two limitations I’ve found so far:

If you follow the link for the first one, you will understand what the issue.

For the second one, please follow my lead!

Let’s say, you would like to separate the resources in your template logically into snippets.

For example, you might want to create an S3 bucket and a CloudFront distribution on top of the S3 bucket to be able to use custom SSL, or maybe just for actual caching capabilities.

Doing this in one stack is probably the way to go, as they would be tightly attached, but your template might grow very quickly, as you might have an S3 bucket resource, the SSL certificate resource, the CloudFront resource and possibly the S3 bucket policy as well..

Your first thought might be to separate the S3 bucket + policy into one snippet, and the CloudFront + SSL certificate into another snippet!
Great idea! That’s what I would do.. except, you can’t do it!

Let’s assume you have something similar to:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
AWSTemplateFormatVersion: '2010-09-09'
Description: Transform Include example
Parameters:
ArtifactBucket:
Type: String
Resources:
'Fn::Transform':
Name: 'AWS::Include'
Parameters:
Location: !Sub "s3://${ArtifactBucket}/s3.yaml"
'Fn::Transform':
Name: 'AWS::Include'
Parameters:
Location: !Sub "s3://${ArtifactBucket}/cloudfront.yaml"

What will actually happen, is that Cloudformation would only deploy the second Include!

It would be really awesome if you could use multiple Includes on the same level.. but who knows, that might be coming in the future..
Or even, right now, AWS already has a fix and is pushing it to us-east-1 as you read!

Remember they keep pushing improvements every hour!