Reputation: 65
I have a situation where I want to load a custom-based file to memory and pass it as array to AWS resource.
Here is my file (this is not JSON)
abc.tmpl
{
name="Mark"
age="20"
},
{
name="Steve"
age="25"
}
apply the above values to one of the resources in the array below
module "elb" {
custome_elb_settings = [
{
name="Mark"
age="20"
},
{
name="Steve"
age="25"
}
]
}
When I tried with template_file it loaded in plain text and loaded as 1 string with \n and escape chars in it.
Is there any way to load as objects from file or else convert string to array in Terraform
Thank you in advance
Upvotes: 0
Views: 996
Reputation: 10703
Declare it as a variable:
variable "custome_elb_settings" {
type = list(object({name=string,age=number}))
}
module "elb" {
custome_elb_settings = var.custome_elb_settings
}
Then pass the value in the command line:
terraform apply -var custome_elb_settings="[ $(cat abc.tmpl) ]"
Upvotes: 1