You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
馃憢 Thanks for your work on terratest! I'd love to see terraform.parsePlanJson be publicly exported (perhaps as a terraform.ParsePlanJSON function).
Context and use case
terratest v0.30.15 introduced the ability to write terratest tests against Terraform plan output, which is great! However, terratest assumes the terraform.PlanStruct has been generated from terratest-orchestrated terraform CLI commands, such as terraform.InitAndPlanAndShowWithStruct. terratest provides no mechanism or API for producing a terraform.PlanStruct from raw Terraform plan JSON, as might be beneficial when using terratest to programmatically analyze and validate a Terraform plan produced by a separate, upstream process (such as a preceding CI/CD job step) that is not orchestrated via terratest.
For example, consider the following contrived GitHub Actions workflow, which could use terratest's terraform.ParsePlanJSON in its Terratest test plan.json step to programmatically analyze plan output produced by the preceding Terraform plan step and gate the Terraform apply step accordingly, without requiring that terratest orchestrate the invocation of the terraform CLI:
jobs:
terraform:
name: Terraformruns-on: ubuntu-lateststeps:
...
- name: Terraform planrun: terraform plan -out=plan.out
- name: Generate Terraform plan.jsonrun: terraform show -json plan.out > plan.json
- name: Terratest test plan.jsonrun: go test
- name: Terratest applyrun: terraform apply plan.out
Via a terraform.ParsePlanJSON function, terratest's testing of the plan.json is decoupled from the actual invocation of the terraform CLI that produced the plan.json. I think this is especially useful in contexts where teams have non-terratest-orchestrated CI/CD logic surrounding the invocation of the terraform CLI, but where those teams would also like to leverage terratest to evaluate the plan results.
Additionally, this also enables the use of terratest Terraform plan testing in contexts where the terraform executable is not installed, as may be the case when separate, distinct OCI container images are responsible for invoking terraform and terratest tests.
The text was updated successfully, but these errors were encountered:
mdb
added a commit
to mdb/terratest
that referenced
this issue
Jun 15, 2023
This seeks to fixgruntwork-io#1308 by publicly exposing the
`terraform.ParsePlanJSON` function, in effect better enabling the use of
`terratest` for programmatically analyzing and validating a Terraform
plan produced by an upstream, non-`terratest` process.
Signed-off-by: Mike Ball <mikedball@gmail.com>
馃憢 Thanks for your work on terratest! I'd love to see terraform.parsePlanJson be publicly exported (perhaps as a
terraform.ParsePlanJSON
function).Context and use case
terratest
v0.30.15 introduced the ability to writeterratest
tests against Terraform plan output, which is great! However,terratest
assumes the terraform.PlanStruct has been generated fromterratest
-orchestratedterraform
CLI commands, such as terraform.InitAndPlanAndShowWithStruct.terratest
provides no mechanism or API for producing aterraform.PlanStruct
from raw Terraform plan JSON, as might be beneficial when usingterratest
to programmatically analyze and validate a Terraform plan produced by a separate, upstream process (such as a preceding CI/CD job step) that is not orchestrated viaterratest
.For example, consider the following contrived GitHub Actions workflow, which could use
terratest
'sterraform.ParsePlanJSON
in itsTerratest test plan.json
step to programmatically analyze plan output produced by the precedingTerraform plan
step and gate theTerraform apply
step accordingly, without requiring thatterratest
orchestrate the invocation of theterraform
CLI:Via a
terraform.ParsePlanJSON
function,terratest
's testing of theplan.json
is decoupled from the actual invocation of theterraform
CLI that produced theplan.json
. I think this is especially useful in contexts where teams have non-terratest
-orchestrated CI/CD logic surrounding the invocation of theterraform
CLI, but where those teams would also like to leverageterratest
to evaluate theplan
results.Additionally, this also enables the use of
terratest
Terraform plan testing in contexts where theterraform
executable is not installed, as may be the case when separate, distinct OCI container images are responsible for invokingterraform
andterratest
tests.The text was updated successfully, but these errors were encountered: