Terraform v0.13.0
Backend config like official doc
https://www.terraform.io/docs/backends/types/remote.html#using-cli-input
workspaces { name = "workspace" }
hostname = "app.terraform.io"
organization = "company"
N/A
N/A
init backend without error
Initializing the backend...
Error: Invalid backend configuration file
The backend configuration file "backend.hcl" given on the command
line must contain key-value pairs only, and not configuration blocks.
terraform init -backend-config=backend.hcl
N/A
second. not sure if I am missing updated docs ref, but I started hitting this today as well.
Same, works fine in 0.12.28 as documented but not in 0.13.0
I'm able to reproduce this and I think it is indeed a bug. It looks like in #25411 we were overzealous in validating the backend configuration file as purely attributes, when it actually should contain the configuration body for the specified backend. As in the remote backend example, this configuration may include blocks.
We need to remove the attributes-only constraint, but I'm not sure what we can replace it with to help out with the original issue (#24845). Maybe a check that there is no terraform block at the top level?
@alisdair Thanks. At lease me, I don't put terraform block at the top level in config file. If it would be difficult to check it at runtime, I think refining docs & outputs are enough.
Is there a workaround that still lets you use a backend.hcl file, but in a different format?
Is there a workaround that still lets you use a backend.hcl file, but in a different format?
Yes. You can combine the attributes as blocks alternate syntax with HCL as JSON. Instead of this HCL:
workspaces { name = "workspace" }
hostname = "app.terraform.io"
organization = "company"
Write this JSON as backend.hcl.json:
{
"workspaces": [
{
"name": "workspace"
}
],
"hostname": "app.terraform.io",
"organization": "company"
}
And run terraform init -backend-config=backend.hcl.json.
I can config that JSON syntax is working as fine with terraform 0.13. Is there a plan to add support for previous HCL syntax or is this the final solution going forward?
I consider it to be a bug and think it should be fixed. I only suggest the JSON workaround as a temporary way to unblock use of 0.13.0.
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
second. not sure if I am missing updated docs ref, but I started hitting this today as well.