mapbox / cloudfriend

Helper functions for assembling CloudFormation templates in JavaScript
ISC License
69 stars 9 forks source link

Add top-level Transform support to cf.merge #115

Closed davidtheclark closed 3 years ago

davidtheclark commented 3 years ago

This PR stops cf.merge from removing Transform sections from templates, enabling cloudfriends to use CloudFormation macros.

The trick with this addition is that the Transform section takes a string or array of strings, rather than an object; and the order of the strings in the array does matter. So the validation here is to throw an error if a macro repeats across multiple template arguments, because that situation means you aren't carefully controlling the order of your macros, and you kind of need to.

@rclark for review, please.

davidtheclark commented 3 years ago

Sorry, @rclark. I thought I had gotten all the tests working here before but saw this morning that I hadn't. It's fixed now. The problem seems to have been that CFN validation rejects an empty array as a Transform section, so we need to only add it with cf.merge if it has content — unlike the other sections.