terraform tempfile and adding tags to YAML files

ismail yenigül
Dec 17, 2020

I am working on creating a CloudFormation stack with terraform resource.

I need to define tags in CloudFormation YAML file in addition to terraform resource.

I added the following lines to YAML template file to make it work.

%{~ if length(mytags) >0 ~}
Tags:
%{~ endif ~}
%{~ for tag_key, tag_value in mytags ~}
- Key: "${tag_key}"
Value: "${tag_value}"
%{~ endfor ~}
You can see all details in my following gist and check https://www.terraform.io/docs/configuration/expressions/strings.html for strings and templatefile handling.

Ismail YENIGUL

Devops Engineer

--

--