Expected Behavior
New member will add in the group after creating a user … the group membership addition will run only after user creation and the user 1 & user 2 will be created then will be added in the group. as depend_on function is there in main.tf under config/main.tf
module “user”{
source = “./gcp_user”
}
module “group”{
depends_on = [module.user]
source = “./gcp_group”
}
Actual Behavior
The group creation module is reruning, deleting and recreating the existing group while adding new member which causes the users to loose access
@anurag1990mar
I am currently struggling with something similar to this, where I am using depends_on.
I find the depends_on influences the order in which the blocks are run, they do not determine whether or not the the run occurs.
In your case, the group module will always run, it is just called after the user module.
You may want to explore conditionals where you incorporate count, which you set based on a condition… if the count is zero, it will not run.
For example:
module “” {
source = “”
Deploy conditionally based on local variable
count = local.deploy_flag == true ? 1 : 0
The formatting did not display properly, let’s try again:
module "<module-name>" {
source = "<source-name>"
# Deploy conditionally based on Feature Flag variable
count = local.deploy_flag == true ? 1 : 0
# module attributes here
}