bridgecrewio / yor

Extensible auto-tagger for your IaC files. The ultimate way to link entities in the cloud back to the codified resource which created it.
https://www.yor.io
Apache License 2.0
826 stars 123 forks source link

Fix adding tags to terraform merge expression #317

Closed rotemavni closed 1 year ago

rotemavni commented 1 year ago

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Handling the case where a resource has a merge clause with tomap expression, leading to misidentification of the existing tags.

Issue:

tags = merge(var.tags, tomap({ "Name" = format("%s-sample", var.this) }), {
    Name      = "format(\"%s-sample\""
    git_org   = "this"
    git_repo  = "this-repo"
    yor_trace = "111111111111111111111111111111111111"
  })

Expected fix:

tags = merge(var.tags, tomap({ "Name" = format("%s-sample", var.this) }), {
    git_org   = "this"
    git_repo  = "this-repo"
    yor_trace = "111111111111111111111111111111111111"
  })

Fixes https://github.com/bridgecrewio/yor/issues/315