Skip to content

fix(terraform): add keycloak grant dependencies - #337

Draft
kruchkovnik15-dot wants to merge 1 commit into
Greenstand:masterfrom
kruchkovnik15-dot:fix/201-keycloak-grant-dependencies
Draft

kruchkovnik15-dot wants to merge 1 commit into
Greenstand:masterfrom
kruchkovnik15-dot:fix/201-keycloak-grant-dependencies

Conversation

@kruchkovnik15-dot

@kruchkovnik15-dot kruchkovnik15-dot commented Oct 12, 2026 •

Copy link
Copy Markdown

Related to #201.

The Keycloak grants use literal role and schema names, so Terraform cannot infer dependencies on the resources that create them. Grant operations can therefore run before the role or schema exists, consistent with the first-apply failure reported in #201.

This change replaces those literals in all three grant resources with references to postgresql_role.service_user.name and postgresql_schema.keycloak_schema.name, establishing the required creation order. Names and privileges remain unchanged.

Validation performed locally against a fresh PostgreSQL 14 database in Docker, using Terraform 1.4.6, PostgreSQL provider 1.22.0, and random provider 3.6.0:

  • terraform fmt -check main.tf passed.
  • terraform init -backend=false and terraform validate passed.
  • Initial plan: 6 to add, 0 to change, 0 to destroy.
  • First apply succeeded: the schema and role completed before all three grant resources.
  • Subsequent plan reported no changes.

This test used the isolated Keycloak configuration with a local superuser connection and an empty schema. The original failure on the unmodified code has not been reproduced, and the full environment configuration has not been tested. No Greenstand infrastructure or remote state was accessed or changed.

Keeping this PR as a draft pending maintainer review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant