hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io
Other
42.79k stars 9.57k forks source link

Allow mocking/skipping provisioners when running `terraform test` #35459

Open JakeNeyer opened 4 months ago

JakeNeyer commented 4 months ago

Terraform Version

Terraform v1.9.2

Use Cases

In some scenarios, running provisioner blocks when testing is unfeasible. When running terraform test I would like the ability to mock output or skip provisioner blocks on certain resources entirely.

Attempted Solutions

N/A

Proposal

Following conventions from the override_resource, override_data, and override_module blocks, a separate override_provisioner block would be one suggestion. The override could have attributes to indicate the provisioner should be skipped altogether or replaced with some other provisioner specifically for testing purposes.

For example, a null_resource with a local-exec provisioner might look like:

override_resource_provisioner {
  target = null_resource.hello_world
  provisioner = null
}

References

No response

crw commented 4 months ago

Thanks for this feature request! If you are viewing this issue and would like to indicate your interest, please use the 👍 reaction on the issue description to upvote this issue. We also welcome additional use case descriptions. Thanks again!