terraform-provider-terracurl icon indicating copy to clipboard operation
terraform-provider-terracurl copied to clipboard

Feature request: It would be great to have pre-post condition that can run a command or a resource

Open oferchen opened this issue 1 year ago • 2 comments

It would be great to have pre-post condition that can run a command or a resource for those isolated vault environments.. it'll save me from having to use a null resource local-provisioner for kubectl port-forward.

Thanks!

oferchen avatar Mar 16 '23 13:03 oferchen

I discovered that a similar feature is actually generally implemented in Terragrunt https://terragrunt.gruntwork.io/docs/features/hooks/ Maybe it's possible to do it indirectly like including the pre-hook object in depends_on

oferchen avatar Mar 22 '23 12:03 oferchen

Depending on the version of Terraform you are using, I believe if you add a lifecycle block to the resource, you'll get what you are after:

  lifecycle {
    postcondition {
      condition     = contains([201, 204], self.status_code)
      error_message = "Status code invalid"
    }
  }

Ahh, but that wouldn't necessarily allow you to run a command - apologies.

wchrisjohnson avatar Aug 04 '23 22:08 wchrisjohnson