cli icon indicating copy to clipboard operation
cli copied to clipboard

Additional state file detection for terraform state pull cases

Open eerkunt opened this issue 4 years ago • 5 comments

Feature Request

Feature description : While running against state files instead of plan files, terraform-compliance runs if the state file is created via ;

terraform show -json > state.out.json or terraform state pull > state.out && terraform show -json state.out > state.out.json

Since the latter could be a functionality within the tool, it would be nice if we just implement it.

The issue is also described in #223

eerkunt avatar Mar 09 '20 11:03 eerkunt

I'm getting an error running against both of these right now.

Macos Catalina terraform-compliance v1.2.7

$ terraform-compliance -p state.out
# ERROR: state.out is not a valid terraform plan json output.
$ terraform-compliance -p state.out.json
# ERROR: state.out.json is not a valid terraform plan json output.

kjr247 avatar Jun 24 '20 16:06 kjr247

Can I have your state file if possible @kjr247 ?

eerkunt avatar Jun 25 '20 10:06 eerkunt

I believe this and #305 are describing the same issue.

For my use case at least, it would be really helpful if TC could run directly on state files instead of needing to pass them through terraform show.

jantman avatar Aug 10 '20 17:08 jantman

Terraform 0.13.5 terrafrom-compliance 1.3.8

For some reason helped to use:

terraform plan -out plan.out
terraform show -json plan.out > plan.out.json
terraform-compliance -f tests -p plan.out.json

instead of terraform state pull > state.out && terraform show -json state.out > state.out.json

andr9184 avatar Dec 11 '20 14:12 andr9184

in the meantime i think it would help to update the docs here to indicate to use terraform show -json > state.out.json instead of terraform state pull https://terraform-compliance.com/pages/usage/#-p--planfile

related here too https://github.com/terraform-compliance/cli/issues/305

nwsparks avatar Feb 28 '22 14:02 nwsparks