TLDR - if Terraform is not creating the
port_integration
resources, then it should not delete them either
-------
As per https://docs.getport.io/guides/all/import-and-manage-integration/, when setting up a new integration via Terraform, it is necessary to first manually create the integration via the "Builder" UI, and then import this to Terraform.
This creates a problem for projects which are subsequently rolled back - e.g. some change has broken a feature in the IDP, potentially unrelated to the new integration.
Consider the following sequence:
  1. Integration created manually
  2. Integration imported into Terraform
  3. Changes are applied to the live Port instance (terraform apply)
  4. Something in that release is identified as breaking - so we need to roll back to an earlier version
  5. Earlier release is deployed - terraform plan & apply is run again, from an earlier version of the code
  6. Terraform sees that the integration wasn't present in the earlier version, so it deletes it from both the live portal and the terraform state!
Now we're back to square-one, and having to re-create the integration, with a new installation id, all over.
Terraform has a convention for resources which aren't directly managed via IaC - Data Sources.
I suggest the Port provider should:
  • Offer a "Data Source" to lookup an existing integration, by id / name
  • Update the "port_integration" resource to only manage the config of the integration - not the integration itself