Skip to content

chore: update usecases subaccount setup #193

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

Merged
merged 1 commit into from
Jun 18, 2024
Merged
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
24 changes: 23 additions & 1 deletion released/modules/btp-cf/btp-cf-env-instance/btp_env_cf.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ resource "btp_subaccount_environment_instance" "cf" {
delete = "30m"
}
}

# ------------------------------------------------------------------------------------------------------
# Create the Cloud Foundry org users
# ------------------------------------------------------------------------------------------------------
Expand All @@ -61,4 +62,25 @@ resource "cloudfoundry_org_role" "org_role" {
username = each.value
type = "organization_user"
org = btp_subaccount_environment_instance.cf.platform_id
}
}

resource "cloudfoundry_org_role" "manager_role" {
for_each = var.cf_org_managers
username = each.value
type = "organization_manager"
org = btp_subaccount_environment_instance.cf.platform_id
}

resource "cloudfoundry_org_role" "auditor_role" {
for_each = var.cf_org_auditors
username = each.value
type = "organization_auditor"
org = btp_subaccount_environment_instance.cf.platform_id
}

resource "cloudfoundry_org_role" "billing_role" {
for_each = var.cf_org_billing_managers
username = each.value
type = "organization_auditor"
org = btp_subaccount_environment_instance.cf.platform_id
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,19 @@ variable "cf_org_name" {
variable "cf_org_user" {
type = set(string)
description = "Defines the colleagues who are added to the Cloud Foundry organization as users."
}

variable "cf_org_managers" {
type = set(string)
description = "List of Cloud Foundry org managers."
}

variable "cf_org_billing_managers" {
type = set(string)
description = "List of Cloud Foundry org billing managers."
}

variable "cf_org_auditors" {
type = set(string)
description = "List of Cloud Foundry org auditors."
}
3 changes: 2 additions & 1 deletion released/usecases/subaccount_setup/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ resource "btp_subaccount" "project" {
# Creation of Cloud Foundry environment
###
module "cloudfoundry_environment" {
source = "../../modules/environment/cloudfoundry/envinstance_cf"
source = "../../modules/btp-cf/btp-cf-env-instance"

subaccount_id = btp_subaccount.project.id
instance_name = local.project_subaccount_cf_org
cf_org_name = local.project_subaccount_cf_org
cf_org_user = []
cf_org_managers = []
cf_org_billing_managers = []
cf_org_auditors = []
Expand Down
4 changes: 2 additions & 2 deletions released/usecases/subaccount_setup/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ terraform {
version = "~> 1.4.0"
}
cloudfoundry = {
source = "cloudfoundry-community/cloudfoundry"
version = "0.53.1"
source = "SAP/cloudfoundry"
version = "0.2.1-beta"
}
}

Expand Down
26 changes: 23 additions & 3 deletions released/usecases/subaccount_setup/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ variable "subaccount_name" {
error_message = "Provide a valid project account name."
}
}

###
# CloudFoundry Org Setup
variable "cf_org_name" {
type = string
description = "Defines to which organisation the project account shall belong to."
Expand All @@ -30,6 +31,26 @@ variable "cf_org_name" {
}
}

variable "cf_org_user" {
type = set(string)
description = "Defines the colleagues who are added to the Cloud Foundry organization as users."
}

variable "cf_org_managers" {
type = set(string)
description = "Defines the colleagues who are added to the Cloud Foundry organization as org managers."
}

variable "cf_org_billing_managers" {
type = set(string)
description = "Defines the colleagues who are added to the Cloud Foundry organization as org billing managers."
}

variable "cf_org_auditors" {
type = set(string)
description = "Defines the colleagues who are added to the Cloud Foundry organization as org auditors."
}

variable "stage" {
type = string
description = "The stage/tier the account will be used for."
Expand All @@ -41,12 +62,11 @@ variable "stage" {
}
}


###
# BTP ACCOUNT
###
variable "region" {
type = string
description = "The region where the project account shall be created in."
default = "us10"
}
}