Closed generalpax closed 1 year ago
Greetings,
This can simply be achieved by adding depends_on
to the module call:
module "otc_keycloak_sso" {
source = "registry.terraform.io/iits-consulting/project-factory/opentelekomcloud//modules/keycloak_sso"
...
depends_on = [ opentelekomcloud_compute_instance_v2.keycloak ]
...
The code you provided is a workaround from the past before the module dependency syntax was added (version 0.13). It achieves this by using explicit dependency syntax depends on
to extend an implicit dependency.
In more detail,
depends_on = [ var.otc_tf_dependencies ]
this will create an explicit dependency between the resource and the variable, not what is inside the variable.
The second part;
module "otc_keycloak_sso" {
source = "registry.terraform.io/iits-consulting/project-factory/opentelekomcloud//modules/keycloak_sso"
...
otc_tf_dependencies = [ opentelekomcloud_compute_instance_v2.keycloak ]
...
creates an implicit dependency between the values passed to the module variable otc_tf_dependencies
, namely, resource opentelekomcloud_compute_instance_v2.keycloak
and the variable itself. The complete dependency chain becomes:
opentelekomcloud_identity_protocol_v3.saml = explicit => var.otc_tf_dependencies = implicit => opentelekomcloud_compute_instance_v2.keycloak
this does accomplish the goal of granular dependency control between modules but is essentially a hack designed to overcome the limitations of old terraform versions.
Since there is the much simpler and readble option to create module level dependencies, I am unsure if this is really needed.
Best, Can
i would like to add dependencies to create keycloak server first or something else:
changed and tested:
keycloak_idp.tf
variables.tf
idp.tf