amplify-education / python-hcl2

MIT License
255 stars 56 forks source link

Won't parse validation block #158

Closed Eric-Fontana-Indico closed 7 months ago

Eric-Fontana-Indico commented 7 months ago

Input test.tf

variable "network_type" {
  type    = string
  default = "create"

  validation {
    condition     = var.network_type == "create" || var.network_type == "load"
    error_message = "${var.network_type} not valid. Type must be either create or load"
  }
}

contents of t.py

import hcl2
with open('test.tf', 'r') as file:
    dict = hcl2.load(file)
    print(dict)
 python t.py
{'variable': [{'network_type': {'type': '${string}', 'default': 'create', 'validation': [{'condition': '${var.network_type == "create" || var.network_type == "load"}', 'error_message': '${var.network_type} not valid. Type must be either create or load'}]}}]}