-
Notifications
You must be signed in to change notification settings - Fork 321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error reading tfstate file: 0.12 format error: <nil>; pre-0.12 format error #131
Comments
+1 |
1 similar comment
+1 |
Looks like by default Terraform tries to directly read I was able to make it work by setting a var:
By pointing terraform-inventory to a directory instead of a file, it takes a completely different code path that properly utilizes I am not sure what the best fix would be here. Maybe terraform-inventory should default to |
+1 |
thanks your reply. it works now.
…---Original---
From: "Justinas Stankevičius"<notifications@github.com>
Date: Thu, Nov 7, 2019 01:09 AM
To: "adammck/terraform-inventory"<terraform-inventory@noreply.github.com>;
Cc: "Comment"<comment@noreply.github.com>;"paulmao1"<81876776@qq.com>;
Subject: Re: [adammck/terraform-inventory] Error reading tfstate file: 0.12 format error: <nil>; pre-0.12 format error (#131)
Looks like by default Terraform tries to read terraform.tfstate which matches the output of terraform state pull. However, terraform show -json produces a different JSON, where resources are nested under .values.root_module, like the program expects for a 0.12+ file.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
And can you me a sample for playbook file.
The following is my file and get an error:
BR
Paul
------------------ 原始邮件 ------------------
发件人: "81876776"<81876776@qq.com>;
发送时间: 2019年11月8日(星期五) 中午1:23
收件人: "adammck/terraform-inventory"<reply@reply.github.com>;"adammck/terraform-inventory"<terraform-inventory@noreply.github.com>;
抄送: "Comment"<comment@noreply.github.com>;
主题: Re: [adammck/terraform-inventory] Error reading tfstate file: 0.12 format error: <nil>; pre-0.12 format error (#131)
thanks your reply. it works now.
…---Original---
From: "Justinas Stankevičius"<notifications@github.com>
Date: Thu, Nov 7, 2019 01:09 AM
To: "adammck/terraform-inventory"<terraform-inventory@noreply.github.com>;
Cc: "Comment"<comment@noreply.github.com>;"paulmao1"<81876776@qq.com>;
Subject: Re: [adammck/terraform-inventory] Error reading tfstate file: 0.12 format error: <nil>; pre-0.12 format error (#131)
Looks like by default Terraform tries to read terraform.tfstate which matches the output of terraform state pull. However, terraform show -json produces a different JSON, where resources are nested under .values.root_module, like the program expects for a 0.12+ file.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
The proposed workaround doesn't work for me for some reason: |
Seems to work for me:
terraform.tf
|
Yep, sorry it appeared to be this issue #133 |
I'm getting the same error. The $ terraform-inventory --inventory
$ TF_STATE=. terraform-inventory --inventory
$ terraform-inventory --version
$ terraform --version
$ cat terraform.tfstate {
"version": 4,
"terraform_version": "0.12.21",
"serial": 32,
"lineage": "72c6e67a-e500-430a-341e-dab290bbf342",
"outputs": {},
"resources": []
} |
Hi again everyone. I have summarized the format differences below. Terraform 0.11A:
|
@AndiDog your input would also be appreciated. It is not clear to me whether we should use
So it seems that this is a valid use-case. |
The error is clear enough: the state is empty. And it doesn't make sense to use |
But the state file is not empty, it just contains a format we do not expect (B vs C in this comment). This is an obvious regression where previously pointing to either a directory or an individual state file worked, but now only a directory is processed correctly (and it is not even a default). As I see it, out of the box (read: without pointing it to a directory via the env var) terraform-inventory 100% does not work with 0.12. |
Understood now. Let me put this in a reproducible example:
I suggest we drop 0.11 support and always call |
I am having same issue in AWS. Everything worked great in terraform 11. |
anyone already tested with terraform 0.13? asking before upgrading... [UPDATE] I've upgraded to 0.13 and the issue is still the same and the workaround works even with 0.13. at least it's safe to upgrade. |
I build terraform-inventory from source code Same error: |
terraform-inventory build from source. Try on repo https://github.com/yandex-cloud/examples/tree/master/active-directory
|
After destroying our openstack instance with terraform v0.12.10 then terraform-inventory v0.9 crash with following message and our pipeline cannot continue:
Error reading tfstate file: 0.12 format error: <nil>; pre-0.12 format error: <nil> (nil error means no content/modules found in the respective format)
Of course, we understand terraform.tfstate is empty, but it did not happen with terraform v0.11.14 and terraform-inventory v0.8
Below is terraform.tfstate:
{ "version": 4, "terraform_version": "0.12.10", "serial": 12, "lineage": "24894aa7-228d-1dc3-0120-42a4be3cdc57", "outputs": {}, "resources": [] }
The text was updated successfully, but these errors were encountered: