Skip to content
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

Passing plans to Terraform plan is deprecated? #22873

Closed
elliot-resdiary opened this issue Sep 23, 2019 · 5 comments
Closed

Passing plans to Terraform plan is deprecated? #22873

elliot-resdiary opened this issue Sep 23, 2019 · 5 comments

Comments

@elliot-resdiary
Copy link

Terraform Version

0.12.8

Terraform Configuration Files

provider "null" {
    version = "=2.1.2"
}

Debug Output

Crash Output

Expected Behavior

According to the documentation here

If the command is given an existing saved plan as an argument, the command will output the contents of the saved plan. In this scenario, the plan command will not modify the given plan. This can be used to inspect a planfile.

the following command should render changeset contained within a saved plan terraform plan -out plan.bin && terraform plan plan.bin. It's worth noting that before we upgraded to 0.12.x (previously on 0.11.x) this was working as expected.

Actual Behavior

Error: Invalid configuration directory

Cannot pass a saved plan file to the 'terraform plan' command. To apply a
saved plan, use: terraform apply plan.bin

Steps to Reproduce

Using the minimal provided HCL.

  1. terraform init
  2. terraform plan -out ./plan.bin
  3. terraform plan ./plan.bin

Additional Context

As mentioned previously, this was working as expected until our upgrade to 0.12.8, previously we were using 0.11.14.

References

The discussion in this issue is relevant, but the discussion doesn't line up with the referenced documentation which claims that passing a plan file to the terraform plan command
is valid #19235.

@teamterraform
Copy link
Contributor

Hi @elliot-resdiary,

Thanks for letting us know about the outdated docs. The main way to view a saved plan file, which still works in Terraform 0.12, is to pass it to terraform show.

We'll update the documentation to reflect that, but in the meantime you should be able to replace terraform plan ./plan.bin with terraform show ./plan.bin in your workflow to get the equivalent result. (That will work on Terraform 0.11 too, in case you still have some systems still using that.)

@elliot-resdiary
Copy link
Author

elliot-resdiary commented Sep 24, 2019

The output of terraform show seems to be lower resolution than the output from terraform plan, which makes it less suitable for reviewing changes before applies.

Here's an example. When I create the following HCL

provider "null" {
    version = "=2.1.2"
}

resource "null_resource" "test" {
    triggers = {
        test = true
    }
}

Now here is the output from a plan terraform plan -out plan.bin, which is what we were able to review in the past before running terraform apply plan.bin

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # null_resource.test will be created
  + resource "null_resource" "test" {
      + id       = (known after apply)
      + triggers = {
          + "test" = "true"
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.

However when we run terraform show plan.bin this is all we get

+ null_resource.test

Which I'm sure you can agree is not an equivalent result.

@seh
Copy link

seh commented Sep 26, 2019

Related: #21596.

@hashibot
Copy link
Contributor

hashibot commented Oct 2, 2019

Hello! 🤖

This issue seems to be covering the same problem or request as #21596, so we're going to close it just to consolidate the discussion over there. Thanks!

@hashibot hashibot closed this as completed Oct 2, 2019
@ghost
Copy link

ghost commented Nov 1, 2019

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.

@ghost ghost locked and limited conversation to collaborators Nov 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants