A CloudFormation macro is a transformation that allows you to create your own shorthand, in order to inject snippets into your templates. You probably already know a little bit about macros—AWS::Include and AWS::Serverless are both macros that are hosted by CloudFormation. Now, you have the ability to write your own macros, and with some creativity, you will find that this can be a very powerful tool to add to your arsenal as an AWS administration guru.
In this recipe, you will create a simple macro that allows you to configure an AWS CloudTrail auditing trail, and a bucket to hold the audit logs, all in just a few short lines of YAML. Similar to the last recipe on custom resources, you will create a lambda function in order to implement the macro transformation.