Kong / terraform-provider-konnect

Terraform Provider for Kong Konnect
https://registry.terraform.io/providers/kong/konnect/latest
29 stars 7 forks source link

Terraform plan doesn't detect multiple plugins associated to the same route #84

Open ag91 opened 1 month ago

ag91 commented 1 month ago

Thanks for maintaining this module. It is cool to manage kong via text editing. I got surprised a couple of times by errors not picked up by terraform plan but picked up by terraform apply for this module. Yesterday I could record the following one.

I suspect the root cause seems to be that on terraform plan this module validates syntax but doesn't do dry-run API calls to test that the new resources respect Kong's rules. (Maybe that could explain also this one?)

Steps to reproduce:

  1. define a route
  2. add a plugin
  3. set plugin's route id to initial route
  4. create a new plugin
  5. associate to the same route

Actual behavior: terraform plan succeeds and terraform apply fails with with an error similar to:

"type":"ERROR_TYPE_REFERENCE","messages":["unique-plugin-per-entity
(type: unique) constraint failed for value'acl....'

Expected behavior: terraform plan fails with the same error

Bonus points:

terraform plan fails with a human friendly explanation, on the lines

Multiple plugins [names&ids] are not allowed for the same route [name&id].

Thanks!

mheap commented 3 weeks ago

Thanks @ag91. We only provide limited up front validation via terraform plan right now, and I understand that's a pain point.

I don't know when we'll get to implement this feature, but I agree that it would be useful for everyone.