I'd like to use yaml formatted variables for terraform with terragrunt. But variables passed to terraform are all with string type, but source vars are all have different types.
Current working tree
.
โโโ dns
โย ย โโโ terragrunt.hcl
โโโ dns-records.yaml
โโโ terragrunt.hcl
โโโ variables.yaml
dns-records.yaml contents
dns_zones:
- name: "test-com"
dns_name: "test.com."
dns_records:
test-com:
- name: "anothertest"
type: "CNAME"
rrdatas: ["test.com."]
variables.yaml contents
#Test variable
test: "supertest"
Parent terragrunt.hcl
inputs = yamldecode(file("variables.yaml"))
Terragrunt.hcl in dns folder
include {
path = find_in_parent_folders()
}
terraform {
source = "/home/bankinobi/work/terraform-modules/dns"
}
inputs = yamldecode(file("${find_in_parent_folders("dns-records.yaml")}"))
Here is my tfstate after refreshing outputs in source module:
{
"version": 4,
"terraform_version": "0.12.28",
"serial": 9,
"lineage": "4d9e1f5d-aa1f-1d6f-2eba-173f2f91f4ef",
"outputs": {
"records": {
"value": "{\"test-com\":[{\"name\":\"anothertest\",\"rrdatas\":[\"test.com.\"],\"type\":\"CNAME\"}]}",
"type": "string"
},
"test": {
"value": "supertest",
"type": "string"
},
"zones": {
"value": "[{\"dns_name\":\"test.com.\",\"name\":\"test-com\"}]",
"type": "string"
}
},
"resources": []
}
How can i decode yamls with preserving variables types?
This is the same issue as https://github.com/gruntwork-io/terragrunt/issues/1007, https://github.com/gruntwork-io/terragrunt/issues/997, and https://github.com/gruntwork-io/terragrunt/issues/1002. You need to add the type information to the variables in terraform to get it to decode properly.
Thank you so much for your help.