Skip to content

Does Trivy correctly handle variables in terraform configuration files? #7731

Answered by nikpivkin
ledmonster asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @ledmonster !

Trivy performs a static scan of the Terraform configuration, so it knows nothing about the state of the resources. In the example, you are referring to the name attribute of the google_project_iam_custom_role resource, about which nothing is known at the time of the scan, so it is null. Beforehand, we fill in the id of the resources and some other attributes. If I refer to the id attribute, which is equivalent to name, I don't get any errors:

resource "google_project_iam_member" "example" {
  for_each = toset([
    google_project_iam_custom_role.example.id,
  ])
  project = "example"
  member  = "group:foo@example.com"
  role    = each.value
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ledmonster
Comment options

Answer selected by ledmonster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
triage/support Indicates an issue that is a support question.
2 participants