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 Amazon Machine Image (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
However, what if we don’t use Amazon Linux, but Ubuntu? We’d have to manually specify the AMI...