Perform custom processing on CloudFormation templates with template macros - Amazon CloudFormation
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Perform custom processing on CloudFormation templates with template macros

With macros, you can perform custom processing on templates, from simple actions like find-and-replace operations to extensive transformations of entire templates.

To get an idea of the breadth of possibilities, consider the AWS::Include and AWS::Serverless transforms, which are macros hosted by CloudFormation:

Billing

When a macro runs, the owner of the Lambda function is billed for any charges related to the execution of that function.

The AWS::Serverless transform and AWS::Include transform transforms are macros hosted by CloudFormation. There is no charge for using them.

Macro examples

In addition to the examples in this section, you can find example macros, including source code and templates, in our GitHub repository. These examples are provided 'as-is' for instructional purposes.