open-policy-agent / conftest

Write tests against structured configuration data using the Open Policy Agent Rego query language
https://conftest.dev
Other
2.88k stars 305 forks source link

Support for Terraform 1.8 Provider Functions #1014

Open o-otte opened 3 weeks ago

o-otte commented 3 weeks ago

Support for Terraform 1.8 Provider Functions

Hello!

When using provider functions that were introduced with Terraform 1.8, it is not possible to parse *.tf files containing those function invocations.

How to reproduce

When using a provider functions like in this example:

# test.tf
terraform {
  required_providers {
    local = {
      source = "hashicorp/local"
    }
  }
  required_version = ">= 1.8.0"
}

output "example_output" {
  value = provider::local::direxists("${path.module}/test")
}

Leading to

$ conftest parse test.tf
Error: parse configurations: parser unmarshal: convert to bytes: parse config: [:11,19-20: Missing newline after argument; An argument definition must end with a newline.], path: test.tf

Context

It seems that support for those provider function was added in hcl/v2 >= v2.20.1. As far as I can see, conftest uses v2.17.0.