I Have a local file (named as x.json)contain some json content. like
{
"client": {
"apiKey": "xyzabcpqr!23",
"permissions": {},
"firebaseSubdomain": "my-project-1"
}
}
I am doing data sources on this file like,
data "local_file" "myfile" {
filename = "x.json" #localfile
}
Now I want to extract the apiKey as terraform out and pass the output to some other resource.
output "apiKey" {
value = data.local_file.myfile.content
}
But I don't find any option to get that.
I tried this one also, but it is throwing the error as
Can't access attributes on a primitive-typed value (string).
output "apiKey" {
value = data.local_file.myfile.content.client.apiKey
}
I hope it can help.
Instead of using local file then output, you can also pass your configuration as variable.
For each
Terraformmodule, set the client configuration as variable, before to plan and apply :or
Then in the
Terraformcode :variables.tffilemain.tffile