Terraform Internal components

We were previously using

This was used in our golang testing Terraform modules to read the planfile and ensure the module was setting up correct values

Example

Since then, looks like they were all moved to an internal folder which no longer allows our testing to work as internal does not let us access the functionality to read planfiles

it says “use of internal package github.com/hashicorp/terraform/internal/plans/planfile not allowed”

We’ve looked up other means and it appears all of the tools to access the planfile use the same way which no longer works

What other options do we have to read planfiles as the functionality is no longer available to us

Hi @lhull,

The saved plan format has always been an implementation detail of Terraform and subject to change at any time, even in patch releases. There is no supported way to directly consume plan files from external software.

However, if you save a plan file using terraform plan -out=tfplan and then use terraform show -json tfplan you can get a JSON representation of the plan data which is a documented integration point which is subject to the Terraform v1.0 compatibility promises, and should thus remain compatible at least through the v1.x series, which currently has no explicitly-planned end date.

Terraform is an application that happens to be written in Go, rather than a Go library, so the move of all of these packages to internal was to make explicit that integrating in that way is explicitly not supported, and specifically that the version tags in the Terraform repository represent Terraform CLI release versions and not Go Module versions.

Thanks, I’ll go with that approach, didn’t know there was a way to view the plan via JSON