Writing your own macro
In this section, we are going to develop macros to solve the cases introduced in the first section of this chapter, the Understanding the use cases of template macros section. This will help us to get some hands-on experience and practice partial and full template processing.
Let's start with the AMI ID filler!
AMI ID filler
Let's start with a simple task and create a macro that will automatically find the AMI ID for EC2. By the end of this section, we will have a macro that automatically puts a correct AMI in the resource properties.
As you might remember, our main template will look like the following:
Resources: Â Â LaunchTemplate: Â Â Â Â Type: "AWS::EC2::LaunchTemplate" Â Â Â Â Properties: Â Â Â Â Â Â LaunchTemplateData: Â Â Â Â Â Â Â Â # This is a replacement for the field ImageId: Â Â Â Â Â Â Â ...