DOP-C02 Practice Question 84: CloudFormation Macros Transform
AWS Certified DevOps Engineer – Professional (DOP-C02) · Test 9 · question 4 of 10
A team maintains a large CloudFormation template with dozens of near-identical resource blocks that differ only by a handful of parameters. They want to author a compact, custom shorthand syntax in the template and have CloudFormation expand it into the full set of standard resource definitions immediately before every create or update, using their own Lambda function to perform the expansion logic. Which CloudFormation capability should they use?
Show answer and explanation
Answer:
Macros are exactly the feature for custom template processing: you register a macro backed by a Lambda function, reference it in the Transform section (or with Fn::Transform for part of a template), and CloudFormation passes the template through your function to rewrite the custom shorthand into standard resource definitions before provisioning.
A is wrong because nested stacks reuse whole templates as building blocks, they do not let you invent new syntax that gets expanded at process time. B is wrong because a custom resource runs its Lambda function during stack operations to manage one resource's lifecycle, it does not rewrite the template itself before CloudFormation parses it. C is wrong because StackSets solve multi-account, multi-Region deployment of an existing template, they have nothing to do with transforming the template's content.
Reference: Perform custom processing on CloudFormation templates with template macros