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

[WIP] Add a diff option to a plan command #17437

Closed
wants to merge 1 commit into from

Conversation

bells17
Copy link

@bells17 bells17 commented Feb 26, 2018

Hi, Could I append diff option to plan command?
I want to use this file to analyze the diff.

generated example is below:

{
  "Modules": [
    {
      "Path": [
        "root"
      ],
      "Resources": {
        "aws_security_group.sample": {
          "Attributes": {
            "revoke_rules_on_delete": {
              "Old": "",
              "New": "true",
              "NewComputed": false,
              "NewRemoved": false,
              "NewExtra": null,
              "RequiresNew": false,
              "Sensitive": false,
              "Type": 0
            },
            "tags.%": {
              "Old": "0",
              "New": "1",
              "NewComputed": false,
              "NewRemoved": false,
              "NewExtra": null,
              "RequiresNew": false,
              "Sensitive": false,
              "Type": 0
            },
            "tags.Name": {
              "Old": "",
              "New": "sample",
              "NewComputed": false,
              "NewRemoved": false,
              "NewExtra": null,
              "RequiresNew": false,
              "Sensitive": false,
              "Type": 0
            }
          },
          "Destroy": false,
          "DestroyDeposed": false,
          "DestroyTainted": false,
          "Meta": null
        }
      },
      "Destroy": false
    }
  ]
}

test result

$ go test -v -run='TestLocal_plan*' -timeout=60s -parallel=4 github.com/hashicorp/terraform/backend/local
=== RUN   TestLocal_planBasic
--- PASS: TestLocal_planBasic (0.00s)
=== RUN   TestLocal_planInAutomation
--- PASS: TestLocal_planInAutomation (0.00s)
=== RUN   TestLocal_planNoConfig
--- PASS: TestLocal_planNoConfig (0.00s)
=== RUN   TestLocal_planRefreshFalse
--- PASS: TestLocal_planRefreshFalse (0.00s)
=== RUN   TestLocal_planDestroy
--- PASS: TestLocal_planDestroy (0.00s)
=== RUN   TestLocal_planOutPathNoChange
--- PASS: TestLocal_planOutPathNoChange (0.00s)
=== RUN   TestLocal_planDiff
--- PASS: TestLocal_planDiff (0.00s)
=== RUN   TestLocal_planScaleOutNoDupeCount
--- PASS: TestLocal_planScaleOutNoDupeCount (0.01s)
PASS
ok    github.com/hashicorp/terraform/backend/local  0.047s

@apparentlymart
Copy link
Contributor

Hi @bells17,

As previously discussed in #10665 (which I contributed before I was a HashiCorp employee), we're intentionally not supporting machine-readable plans at this time because we expect to need to change the representation of plans to support forthcoming features and so we're not yet ready to commit to compatibility on a specific JSON format.

In the mean time, you may be able to do what you want by using Terraform as a library from your own Go program and calling terraform.ReadPlan. We cannot promise that this interface will not change in future versions -- in fact, it definitely will change at least once during our current work to change the internal representation of values -- but if you are willing to accept a small amount of gradual maintenance here then this could get you what you want in the short term.

We do plan to have a machine-readable plan description in the long run, once we've completed all of the expected work that will require changes to the format. However, we're not ready to move forward with that for the moment.

I'm sorry to have to say no to this for now, and I'm grateful for the time you spent on this work. Possibly we can build on this in future when the time is right to implement machine-readable plans.

@bells17
Copy link
Author

bells17 commented Feb 28, 2018

Hi, @apparentlymart,

Thank you for reviewing, and teaching me about the previously discussed.
I think create a diff output tool with the Terraform Go API for analyze a diff.

but if you'll ready supporting machine-readable plans, I use this.
Thanks!

@bells17 bells17 closed this Feb 28, 2018
@ghost
Copy link

ghost commented Apr 4, 2020

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 Apr 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants