GorillaStack / auto-tag

Automatically tag AWS resources on creation, for cost assignment
GNU General Public License v3.0
463 stars 159 forks source link

do not tag already tagged resources #82

Closed balihb closed 2 years ago

balihb commented 4 years ago

I'm using Terraform in tandem with user created resources in AWS. The problem is, that I can't tell AutoTag to not tag resources that I already tagged, so Terraform will detect changes on the resources it created and it is bloating the code seriously if I have to exclude AutoTag tags on every resource I created. Maybe it would also be possible to include a tag, that tells AutoTag not to tag a certain resource.

I've started looking at the code but haven't found a single point where I could check the already existing tags on every resource and skip tagging if needed.

rayjanoka commented 3 years ago

The only solution I'm aware of is to add this code to those terraform resources that are being tagged.

lifecycle {
    ignore_changes = [
      "tags.AutoTag_CreateTime",
      "tags.AutoTag_Creator",
      "tags.AutoTag_InvokedBy",
      "tags.%"
    ]
  }

We don't check to see if the tag exists before we add it so there is no simple way to do this.

balihb commented 3 years ago

back when I reported this terraform was unable to ignore changes on individual tags, but it is still fairly annoying to exclude tags on all the resources that have tags. oh well...