Terraform: Garbage output with `terraform plan -out`

Created on 4 Aug 2016  ยท  4Comments  ยท  Source: hashicorp/terraform

terraform plan -out=out.tfstate produces garbage output in the out file. This makes future use of the file (with terraform plan -out or terraform apply -state) unusable.

Terraform Version

0.7

Affected Resource(s)

core

Terraform Configuration Files

This is reproducible with any configuration, e.g. resource "null_resource" "dummy" {}

Debug Output

plan succeeds and produces normal output to the console.

Example of resulting out file with the above config:
https://gist.github.com/ajcrites/f0aa95114dac6aaa67c47c33b789710f

Expected Behavior

out files should be usable by future terraform plan and terraform apply.

Actual Behavior

Garbage in the out file prevents using it for other terraform commands.

Steps to Reproduce

Run terraform plan with the config above

documentation question

All 4 comments

Hi @ajcrites - the -out parameter generates a binary execution plan. This plan file can then be provided as an argument to apply to establish a contract between the reviewed plan and what actually happens during terraform apply.

Here's an example of usage. Given config:

resource "null_resource" "foo" {}

If you run:

terraform plan -out example.tfplan

You'll see as part of the output message:

Your plan was also saved to the path below. Call the "apply" subcommand
with this plan file and Terraform will exactly execute this execution
plan.

Path: example.tfplan

You can then run:

terraform apply example.tfplan

This executes the plan and will bail if anything in the environment changed since the planfile was generated that might invalidate the plan.

I hope this helps to clarify! Let me know if you have any further questions on this.

@ssubraman224 - I am not sure what your comment has to do with this particular issue, which was closed two years ago. Is it possible you meant to comment somewhere else, or create a new issue?

@mildwonkey right, wrong window... typed here by mistake. thanks for notifying.

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.

Was this page helpful?
0 / 5 - 0 ratings