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

terraform show, does not work properly for v0.12 #21864

Closed
marcb1 opened this issue Jun 24, 2019 · 6 comments
Closed

terraform show, does not work properly for v0.12 #21864

marcb1 opened this issue Jun 24, 2019 · 6 comments
Labels

Comments

@marcb1
Copy link

marcb1 commented Jun 24, 2019

When I make the following change to HCL:

 resource "google_compute_address" "apt-repo-1" {
-  name         = "apt-repo-1"
+  name         = "apt-repo-2"
   address_type = "INTERNAL"
   project      = "${var.project}"

I then run terraform plan

terraform plan -target=google_compute_address.apt-repo-1 -out=plan_file
# google_compute_address.apt-repo-1 must be replaced                                                                 
-/+ resource "google_compute_address" "apt-repo-1" {
      ~ address            = "10.56.28.116" -> (known after apply)
        address_type       = "INTERNAL"
      ~ name               = "apt-repo-1" -> "apt-repo-2" # forces replacement
      + network_tier       = (known after apply)       

I expect terraform show to show the same diff output as terraform plan. However it only displays the resource name (this behavior has changed between TF 0.11 and TF 0.12)

terraform show plan_file 
-/+ google_compute_address.apt-repo-1 (new resource required)

We have some automation that relies on this behavior. Is there a plan to change terraform show to display the full output from the plan file?

@phinze
Copy link
Contributor

phinze commented Jun 25, 2019

Hi Marc - check out terraform show -json which should have all the information you might need for automation purposes - hopefully in an easier to use format than the former plaintext output!

@phinze phinze closed this as completed Jun 25, 2019
@marcb1
Copy link
Author

marcb1 commented Jun 25, 2019

@phinze terraform show -json shows the entire state file and not just the changed resource, so I'm not sure how to parse it

@phinze
Copy link
Contributor

phinze commented Jun 25, 2019

Aha! My mistake - I thought you could get a plan representation with the changes represented. Let's reopen this then so we can track this need to get the plan changes from terraform show. 👍

@phinze phinze reopened this Jun 25, 2019
@marcb1
Copy link
Author

marcb1 commented Jun 25, 2019

awesome, thanks!

@phinze
Copy link
Contributor

phinze commented Jun 27, 2019

Ok I've gotten a chance to test this now and I can now confirm it definitely works on plans, you just have to specify the plan file as an argument. Check out the example below.

# main.tf
resource "random_pet" "test" {}
❯ terraform -version
Terraform v0.12.3
+ provider.random v2.1.2
❯ terraform plan -out=plan.tfplan
❯ terraform show -json plan.tfplan
{"format_version":"0.1","terraform_version":"0.12.3","planned_values":{"root_module":{"resources":[{"address":"random_pet.test","mode":"managed","type":"random_pet","name":"test","p
rovider_name":"random","schema_version":0,"values":{"keepers":null,"length":2,"prefix":null,"separator":"-"}}]}},"resource_changes":[{"address":"random_pet.test","mode":"managed","t
ype":"random_pet","name":"test","provider_name":"random","change":{"actions":["create"],"before":null,"after":{"keepers":null,"length":2,"prefix":null,"separator":"-"},"after_unknow
n":{"id":true}}}],"configuration":{"root_module":{"resources":[{"address":"random_pet.test","mode":"managed","type":"random_pet","name":"test","provider_config_key":"random","schema
_version":0}]}}}

I think with this you should be good to go!

@phinze phinze closed this as completed Jun 27, 2019
@ghost
Copy link

ghost commented Aug 13, 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 Aug 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants