Hadil Ben Abdallah describes creating a managed cluster and a test realm in I Provisioned My Keycloak Infrastructure With Terraform. Here’s What I’d Automate. The walkthrough is a useful starting point for deciding which Terraform configuration should own an identity resource and where to check the result.
Decide who owns the realm
The Skycloak provider can create the managed cluster and supports realm resources. The Keycloak provider manages settings inside an existing Keycloak instance, including protocol mappers. If you need a mapper for an application, one possible division is for the platform configuration to own the cluster and realm and for a second configuration to manage the application's mapper. Keep one owner for each resource so the two configurations do not try to reconcile the same settings.
The second configuration needs a reachable cluster and working credentials. Ben Abdallah proposes running cluster provisioning and the deeper configuration in stages. That gives a staging pipeline a point at which to confirm that the cluster accepts an authenticated Admin API request before attempting to configure the application.
Verify the result at the application boundary
In the walkthrough, the author checked the cluster and enabled realm in the dashboard and used Terraform state commands to confirm the two resources were tracked. An application rollout can add its own check. For example, after adding a mapper to a staging client, sign in using a test account and check that the resulting token contains the expected claim. This exercises the path that depends on the change. Inspect the state backend permissions as well. HashiCorp documents that marking values sensitive can redact output while those values are still stored in state. Terraform variable documentation
For a staging rehearsal, record the realm, client and test identity used for the token check. If it fails, the recorded details give the platform and application teams a starting point for checking whether they deployed and tested against the same realm.
Where would you put the handoff check between cluster provisioning and application configuration?