pactflow / terraform-provider-pact

Terraform provider for Pact Broker (and Pactflow)
https://pactflow.io
MIT License
24 stars 4 forks source link

pact_webhook resource is replaced on apply when webhook_consumer is omitted #7

Closed ghost closed 4 years ago

ghost commented 4 years ago

Terraform Version

Terraform v0.12.28

Affected Resource(s)

Terraform Configuration Files

provider "pact" {
  host = "http://localhost:9292"
}

resource "pact_pacticipant" "service" {
  name = "example-service"
}

resource "pact_webhook" "service_webhook" {
  webhook_provider = {
    name = "example-service"
  }

  request {
    url = "http://jenkins.example.com/example-service/build"
    method = "POST"
    username = "username"
    password = "password"
    headers = {
      "content-type" = "application/x-www-form-encoded"
    }
    body = "json={\"parameter\": [{\"name\":\"TAG_AND_PUSH\", \"value\":\"false\"}]}"
  }
  events = ["contract_content_changed"]
  depends_on = [pact_pacticipant.service]
}

Expected Behavior

Running terraform apply should not replace or modify a webhook resource that does not have any changes.

Actual Behavior

Running terraform apply causes webhooks to be replaced, even when no changes have been made to the configuration.

The following line appears in the plan:

+ webhook_consumer = (known after apply) # forces replacement

Steps to Reproduce

  1. terraform apply
  2. terraform apply

Observe that despite the fact that no changes have been made, terraform still plans and executes the replacement of the webhook resource.

mefellows commented 4 years ago

Thanks again for the report - I've just made a small change to handle the situation. It was a quirk in the way terraform set nil that I wasn't aware of - TIL.

I checked the other resources and as they don't have complex input structures like webhooks they look like they won't suffer the same fate.

Build is green and I've just released another version (v0.0.7)

Thanks again for your patience whilst we work to get a 1.0.0 release out later this year.