amplify-education / python-hcl2

MIT License
250 stars 56 forks source link

HCL interpolations within dict output contain single quotes #172

Open weaversam8 opened 5 days ago

weaversam8 commented 5 days ago

HCL only supports double quotes, but some interpolations may contain single quotes.

Example hcl:

block {
  type = list(
    object({
      id = string
    })
  )
}

Expected output:

{'block': [{'type': "${list(object({\"id\": \"${string}\"}))}", '__start_line__': 1, '__end_line__': 7}]}

Actual output (note the difference in quotes):

{'block': [{'type': "${list(object({'id': '${string}'}))}", '__start_line__': 1, '__end_line__': 7}]}

I plan to fix this in a future PR, just creating this issue for tracking purposes.

weaversam8 commented 3 days ago

This is actually true for many different Python datatypes - booleans appear in this output as True and False instead of the Terraform true and false.