Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloudformation template parameter to pass tags to resource

I've been racking my brain but cant see how it can be done which seems limited, but I would like to be able to have a template parameter that can be used to pass arbitrary tags to a supported resource in my template, for example:

EC2Tags:
  Description: Tags to add to the EC2 Instance
  Type: CommaDelimitedList
  Default: "CreatedBy=JohnDoe,Name=NewEC2,OtherTag=OtherValue"

 ....

but later on the resource requires something like:

Type: "AWS::EC2::Instance"
Properties:
  Tags: 
    - 
     Key: "keyname1"
     Value: "value1"
    - 
     Key: "keyname2"
     Value: "value2" 

  ....

Is there anyway to achieve this goal?

like image 756
user2237076 Avatar asked Mar 08 '23 00:03

user2237076


1 Answers

I wanted a generic solution that didn't assume number of tags, order of tags or tag names, and after much trial and error I have managed to solve this using the custom resource solution proposed by @laurent-jalbert-simard.

Here is the gist if anyone else might find useful:

https://gist.github.com/ispyinternet/97b434a2a58aea5d496ecd87b29e64e9

like image 149
user2237076 Avatar answered May 05 '23 12:05

user2237076