I’m using the terraform plugin framework.
When an acceptance test fails, is it possible to prevent resources from being destroyed ? If yes how ?
The reason is I’d like to look at logs to figure out why the test failed.
I’m using the terraform plugin framework.
When an acceptance test fails, is it possible to prevent resources from being destroyed ? If yes how ?
The reason is I’d like to look at logs to figure out why the test failed.
Yes, you can prevent resource destruction during acceptance test failures by setting prevent_destroy = true
in your resource’s lifecycle configuration. This ensures that even if the test fails, Terraform won’t destroy the resources, allowing you to inspect logs:
resource "example_resource" "test" {
# resource configuration
lifecycle {
prevent_destroy = true
}
}
This way, you can investigate the logs without worrying about the resources being removed.