Terraform Data Source for fetching existing integrations
M
Mark Tarry
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:
- Integration created manually
- Integration imported into Terraform
- Changes are applied to the live Port instance (terraform apply)
- Something in that release is identified as breaking - so we need to roll back to an earlier version
- Earlier release is deployed - terraform plan & apply is run again, from an earlier version of the code
- 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
M
Mark Tarry
FYI - I've seen https://roadmap.getport.io/ideas/p/terraform-provider-for-data-sources, and I don't think this went far enough
Matan Grady
Mark Tarry: Thank you for all the context, definitely helps us!