Tags Helper

The tags helper adds several conveniences.

Convenience Form

Provide tags with a simple hash:

tags(Name: "test")

And it conveniently generates the typical CloudFormation Tags property structure.

Tags:
- Key: Name
  Value: test

If you prefer to be explicitly you can provide the standard form also. Example:

tags([{Key: "Name", Value: "test"}])

PropagateAtLaunch Special Key

For most resources, the CloudFormation Tags structure is an Array of Hashes with Key and Value elements. For the AWS::AutoScaling::AutoScalingGroup TagProperty, there is an additional required key: PropagateAtLaunch.

The tags helper method can automatically add PropagateAtLaunch key to all the Hash elements. Example:

tags(Name: "test", Env: "dev", PropagateAtLaunch: true)

Results in:

Tags:
- Key: Name
  PropagateAtLaunch: true
  Value: test
- Key: Env
  PropagateAtLaunch: true
  Value: dev

Tags Variables Inference

The tags helper method can also infer it’s value from variables configs. Example:

config/blueprints/demo/vars/dev.rb:

@tags = {Name: "test", Env: "dev"}

Then in the template, call tags without any arguments to tell it to infer the value from variables.

tags

This generates

Tags:
- Key: Name
  Value: test
- Key: Env
  Value: dev