Skip to content

Commit 91a5fd8

Browse files
authored
Remove current user from CF org users/admins (#296)
* Remove current user from CF org users/admins * fix format
1 parent b0e0211 commit 91a5fd8

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

released/discovery_center/mission_4327/step1/main.tf

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ resource "btp_subaccount" "project" {
1717
subdomain = local.subaccount_domain
1818
region = lower(var.region)
1919
}
20+
2021
data "btp_whoami" "me" {}
2122

2223
data "btp_subaccount_environments" "all" {
@@ -56,7 +57,7 @@ resource "btp_subaccount_environment_instance" "cloudfoundry" {
5657
# Assignment of users as sub account administrators
5758
###############################################################################################
5859
resource "btp_subaccount_role_collection_assignment" "subaccount-admins" {
59-
for_each = toset("${var.subaccount_admins}")
60+
for_each = toset(var.subaccount_admins)
6061
subaccount_id = btp_subaccount.project.id
6162
role_collection_name = "Subaccount Administrator"
6263
user_name = each.value
@@ -136,14 +137,19 @@ resource "btp_subaccount_entitlement" "hana-hdi-shared" {
136137
plan_name = "hdi-shared"
137138
}
138139

140+
locals {
141+
cf_org_users = setsubtract(toset(var.cf_org_users), [data.btp_whoami.me.email])
142+
cf_org_admins = setsubtract(toset(var.cf_org_admins), [data.btp_whoami.me.email])
143+
}
144+
139145
resource "local_file" "output_vars_step1" {
140146
count = var.create_tfvars_file_for_next_stage ? 1 : 0
141147
content = <<-EOT
142148
cf_api_url = "${jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels)["API Endpoint"]}"
143149
cf_org_id = "${btp_subaccount_environment_instance.cloudfoundry.platform_id}"
144150
145-
cf_org_users = ${jsonencode(var.cf_org_users)}
146-
cf_org_admins = ${jsonencode(var.cf_org_admins)}
151+
cf_org_users = ${jsonencode(local.cf_org_users)}
152+
cf_org_admins = ${jsonencode(local.cf_org_admins)}
147153
cf_space_developers = ${jsonencode(var.cf_space_developers)}
148154
cf_space_managers = ${jsonencode(var.cf_space_managers)}
149155

released/discovery_center/mission_4327/step1/outputs.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,11 @@ output "cf_org_id" {
1313
output "cf_api_url" {
1414
value = lookup(jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels), "API Endpoint", "not found")
1515
}
16+
17+
output "cf_org_users" {
18+
value = local.cf_org_users
19+
}
20+
21+
output "cf_org_admins" {
22+
value = local.cf_org_admins
23+
}

0 commit comments

Comments
 (0)