Understanding the use cases of the template macro
Before we dive into the internals of macros, we need to know what we can solve with them. Let's look at a few cases and examples.
Auto filling resource property values
Imagine having a launch template where you need to define an AMI ID. For Amazon Linux AMI, you could use AWS's parameter store:
Parameters: Â Â ImageId: Â Â Â Â Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id> Â Â Â Â Default: '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2' Resources: Â Â LaunchTemplate: Â Â Â Â Type: "AWS::EC2::LaunchTemplate" Â Â Â Â Properties: Â Â Â Â Â Â LaunchTemplateData: Â Â Â Â Â Â Â Â ImageId: !Ref ImageId
But what if we don't use Amazon Linux, but Ubuntu? We'd have to manually specify the AMI IDs and use mappings:
Mappings: ...