diff --git a/developer/terraform.mdx b/developer/terraform.mdx index c523ce3b..89f2b75f 100644 --- a/developer/terraform.mdx +++ b/developer/terraform.mdx @@ -47,6 +47,8 @@ Traditionally, creating a group in an IdP and then configuring its properties in Now, with the Group ID as a join key, you can perform a single Terraform run that creates a group in C1 and simultaneously merges that group with the corresponding IdP group. This eliminates the need to wait for multiple C1 syncs and dramatically simplifies your group management process. +The same configuration works whether or not C1 has already synced the group. If the group is new, Terraform creates the resource and entitlement in C1, and the next sync merges the IdP group into them. If C1 has already synced the group, Terraform adopts the existing resource and entitlement instead of creating duplicates, and their C1 IDs stay the same. + Here are sample Terraform files demonstrating how to use the `match_baton_id` key to sync a C1 group with Okta: **okta.tf file:** @@ -130,8 +132,33 @@ resource "conductorone_custom_app_entitlement" "test" { This example works because Okta's connector uses the native Okta group ID as the match key. Other connectors may not. For a Databricks group, set `match_baton_id` to `account//group/`, not the bare Databricks group ID. With the bare ID, the sync creates a second resource for the group instead of merging. See [per-connector ID formats](/developer/recipes-id#per-connector-id-formats). +#### Keep the IdP group's name + +After the group syncs, the connector can update the resource's display name to match the IdP. To stop Terraform from planning a change back to the name in your configuration, ignore that attribute: + +```terraform +resource "conductorone_app_resource" "okta_group_resource" { + # ... + lifecycle { + ignore_changes = [display_name] + } +} +``` + +#### What `terraform destroy` does + +The IdP and its connector decide whether a synced group exists in C1, so Terraform does not delete it. In provider version 1.8.2 and later: +| State of the resource or entitlement in C1 | Result of `terraform destroy` | +| --- | --- | +| Created by Terraform and not yet synced from the IdP | Deleted from C1. | +| Synced from the IdP (merged after creation, or adopted) | Removed from Terraform state only. It stays in C1 and the connector keeps managing it. Terraform shows a warning. | +| Already deleted in C1 | Removed from Terraform state. | +If you also delete the group in the IdP, the next sync removes it from C1. If you apply the configuration again later, Terraform adopts the same resource and entitlement. + +Earlier provider versions return an error such as `only resources created in ConductorOne can be deleted` when you destroy a synced resource. To stop managing the resource in those versions, run `terraform state rm `. Nothing in C1 is changed. +