AWS announced a new feature in September 2018, Macros in CloudFormation, allowing customers to add custom logic to templates and modify the template as necessary. CloudFormation transforms help simplify template authoring by condensing the expression of AWS infrastructure as code and enabling reuse of template components.
There are two steps in the process of modifying templates using macros: A) Creating the Macro, and B) Using the Macro to proces your templates.
You can read more about how they work in the referenced AWS docs.
This repo is a small collection of Macros I've developed to add useful features to CloudFormation templates, for example, fetching Key-Value pairs from a DynamoDB and adding them to Mappings.
Feel free to go through them, and improve upon them as well!