Hello folks,
I’m trying to output the content of a local.files_map
to better understand for/for_each loops by running terraform output
. I’m getting the following error:
The state file either has no outputs defined, or all the defined
outputs are empty. Please define an output in your configuration
with the `output` keyword and run `terraform refresh` for it to
become available. If you are using interpolation, please verify
the interpolated value is not empty. You can use the
`terraform console` command to assist.
Here is the code (Using Terraform v0.12.7):
variable "local_files" {
type = list(object({
content = string
filename = string
}))
default =[
{
content = "a",
filename = "a-name"
},
{
content = "b",
filename = "b-name"
},
{
content = "c",
filename = "c-name"
},
]
}
locals {
files_map = {
for f in var.local_files:
f.filename => f
}
}
resource "local_file" "foo" {
for_each = local.files_map
content = each.value.content
filename = each.value.content
}
The code runs fine but I’m not getting any output. Ideas?
Thanks in advance,