5

I have resources defined in my Cloudformation template file with tags defined like so:

  "Properties": {
    "Tags": [
      { "Key": "Environment", "Value": {"Ref": "Environment"}},
      { "Key": "Hello", "Value": "World"}
    ]
  }

My IAM username is my.name. I would like to add a key named Creator to the Tags property with value my username (my.name). Moreover, I need this value to reflect the username of whoever runs this Cloudformation template. How can I do it?

Saqib Ali
  • 11,931
  • 41
  • 133
  • 272

2 Answers2

6

I am not aware of any way of referencing the IAM username directly from the template JSON.

However, you can use get-user to get the username (either using the CLI or one of the SDKs), and then pass it on to CloudFormation as a parameter, or, if you are creating the template JSON programmatically, just insert it directly.

bsvingen
  • 2,699
  • 14
  • 18
0

You should pass the user ID as a parameter on the create-template API call and add it to the tags using Fn::Join. Cloudformation won't do this for you.

Max
  • 8,671
  • 4
  • 33
  • 46