Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added BTP_NEW_SUBACCOUNT_ADMINS #45

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions examples/kyma-on-btp-new-sa/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module "kyma" {
BTP_BOT_PASSWORD = var.BTP_BOT_PASSWORD
BTP_NEW_SUBACCOUNT_REGION = var.BTP_NEW_SUBACCOUNT_REGION
BTP_KYMA_MODULES = var.BTP_KYMA_MODULES
BTP_NEW_SUBACCOUNT_ADMINS = var.BTP_NEW_SUBACCOUNT_ADMINS
}

output "subaccount_id" {
Expand Down
5 changes: 5 additions & 0 deletions examples/kyma-on-btp-new-sa/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,8 @@ variable "BTP_KYMA_MODULES" {
]
description = "The list of kyma modules to install"
}

variable "BTP_NEW_SUBACCOUNT_ADMINS" {
type = list(string)
default = [ ]
}
17 changes: 17 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,20 @@ resource "btp_subaccount" "subaccount" {
subdomain = var.BTP_NEW_SUBACCOUNT_NAME
}

locals {
subaccount_admins = var.BTP_NEW_SUBACCOUNT_NAME != null && var.BTP_USE_SUBACCOUNT_ID == null ? var.BTP_NEW_SUBACCOUNT_ADMINS : []
}

resource "btp_subaccount_role_collection_assignment" "subaccount_admins" {
for_each = toset(local.subaccount_admins)
subaccount_id = btp_subaccount.subaccount.0.id
role_collection_name = "Subaccount Administrator"
user_name = each.value
}

resource "btp_subaccount_role_collection_assignment" "subaccount_viewers" {
for_each = toset(local.subaccount_admins)
subaccount_id = btp_subaccount.subaccount.0.id
role_collection_name = "Subaccount Viewer"
user_name = each.key
}
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ variable "BTP_NEW_SUBACCOUNT_REGION" {
default = "eu20"
}

variable "BTP_NEW_SUBACCOUNT_ADMINS" {
type = list(string)
description = "Usernames of the new subaccount admins"
default = [ ]
}

variable "BTP_CUSTOM_IAS_TENANT" {
type = string
description = "Custom IAS tenant"
Expand Down