Terraform show -json some.plan: jsons are not identical for same state

Hi,
I’m using terraform version 0.15.3.

I’m creating a plan with terraform plan -out some_1.plan and then again with terraform plan -out some_2.plan.
No changes happen on the account between the calls. So I’d expect the two plans would do the same.

Then I do a terraform show -json some_1.plan > some_1.json and a terraform show -json some_2.plan > some_2.json.

import json

with open('some_1.json', 'r') as f:
    plan1 = json.load(f)

with open('some_2.json', 'r') as f:
    plan2 = json.load(f)

print(plan1 == plan2)

This prints False :frowning:
So it seems the plans don’t actually do the same.

After some research I found that they are not equal, because some depends_on lists have a different ordering of their elements than the corresponding one.

I need to compare the two plans to find out if they would do the same changes.

Questions:

  1. Is it save to order the depends_on lists e.g. alphabetically before the comparison?
  2. Are there more lists with potentially different orderings that I haven’t encountered?
  3. Is there maybe a different way to automatically find out if the two plans would do the same on the same “reality”?

Thank you!
Marc-Philip

Hi @mpw96,

The ordering of the dependencies set in the state was fixed in a later release of terraform, in v1.1 I believe.

The Terraform version you are using is quite far behind. I would suggest updating to at least the latest patch release for that branch which is v1.0.11 to get many bug fixes and features which are required for newer providers, but the latest v1.1 would be required to determine equality in the manner you tried above.

1 Like