Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ resource "btp_subaccount_entitlement" "cloudfoundry" {
}

resource "btp_subaccount_environment_instance" "cloudfoundry" {
depends_on = [btp_subaccount_entitlement.build_code]
subaccount_id = btp_subaccount.dc_mission.id
name = "cf-${random_uuid.uuid.result}"
environment_type = "cloudfoundry"
Expand Down Expand Up @@ -204,7 +205,7 @@ resource "local_file" "output_vars_step1" {
cf_org_id = "${jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels)["Org ID"]}"
cf_org_name = "${jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels)["Org Name"]}"

origin = "${var.origin}"
origin_key = "${var.origin}"

cf_space_name = "${var.cf_space_name}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,25 @@ resource "cloudfoundry_space" "dev" {
# ------------------------------------------------------------------------------------------------------
# Assign CF Org roles to the admin users
# ------------------------------------------------------------------------------------------------------
# Remove current user from org roles
data "btp_whoami" "me" {}

locals {
cf_org_admins = setsubtract(toset(var.cf_org_admins), [data.btp_whoami.me.email])
}

# Define Org User role
resource "cloudfoundry_org_role" "organization_user" {
for_each = toset("${var.cf_org_admins}")
for_each = toset("${local.cf_org_admins}")
username = each.value
type = "organization_user"
org = var.cf_org_id
origin = var.origin_key
}

# Define Org Manager role
resource "cloudfoundry_org_role" "organization_manager" {
for_each = toset("${var.cf_org_admins}")
for_each = toset("${local.cf_org_admins}")
username = each.value
type = "organization_manager"
org = var.cf_org_id
Expand Down