diff --git a/released/discovery_center/mission_4327/step1/main.tf b/released/discovery_center/mission_4327/step1/main.tf index 4a57c2b0..f5e02711 100644 --- a/released/discovery_center/mission_4327/step1/main.tf +++ b/released/discovery_center/mission_4327/step1/main.tf @@ -63,35 +63,7 @@ resource "btp_subaccount_role_collection_assignment" "subaccount-admins" { user_name = each.value } ###################################################################### -# Add entitlement for BAS, Subscribe BAS and add roles -###################################################################### -resource "btp_subaccount_entitlement" "bas" { - subaccount_id = btp_subaccount.project.id - service_name = "sapappstudio" - plan_name = var.service_plan__bas -} -resource "btp_subaccount_subscription" "bas-subscribe" { - subaccount_id = btp_subaccount.project.id - app_name = "sapappstudio" - plan_name = var.service_plan__bas - depends_on = [btp_subaccount_entitlement.bas] -} -resource "btp_subaccount_role_collection_assignment" "Business_Application_Studio_Administrator" { - subaccount_id = btp_subaccount.project.id - role_collection_name = "Business_Application_Studio_Administrator" - user_name = data.btp_whoami.me.email - depends_on = [btp_subaccount_subscription.bas-subscribe] -} - - -resource "btp_subaccount_role_collection_assignment" "Business_Application_Studio_Developer" { - subaccount_id = btp_subaccount.project.id - role_collection_name = "Business_Application_Studio_Developer" - user_name = data.btp_whoami.me.email - depends_on = [btp_subaccount_subscription.bas-subscribe] -} -###################################################################### -# Add Build Workzone entitlement subscription and role Assignment +# Add Build Workzone entitlement ###################################################################### resource "btp_subaccount_entitlement" "build_workzone" { subaccount_id = btp_subaccount.project.id @@ -99,18 +71,6 @@ resource "btp_subaccount_entitlement" "build_workzone" { plan_name = var.service_plan__build_workzone amount = var.service_plan__build_workzone == "free" ? 1 : null } -resource "btp_subaccount_subscription" "build_workzone_subscribe" { - subaccount_id = btp_subaccount.project.id - app_name = "SAPLaunchpad" - plan_name = var.service_plan__build_workzone - depends_on = [btp_subaccount_entitlement.build_workzone] -} -resource "btp_subaccount_role_collection_assignment" "launchpad_admin" { - subaccount_id = btp_subaccount.project.id - role_collection_name = "Launchpad_Admin" - user_name = data.btp_whoami.me.email - depends_on = [btp_subaccount_subscription.build_workzone_subscribe] -} ###################################################################### # Create HANA entitlement subscription ###################################################################### @@ -131,12 +91,30 @@ resource "btp_subaccount_subscription" "hana-cloud-tools" { plan_name = "tools" depends_on = [btp_subaccount_entitlement.hana-cloud-tools] } +# Assign users to Role Collection: SAP HANA Cloud Administrator +resource "btp_subaccount_role_collection_assignment" "hana-cloud-admin" { + for_each = toset(var.hana_cloud_admins) + subaccount_id = btp_subaccount.project.id + role_collection_name = "SAP HANA Cloud Administrator" + user_name = each.value + depends_on = [btp_subaccount_subscription.hana-cloud-tools] +} resource "btp_subaccount_entitlement" "hana-hdi-shared" { subaccount_id = btp_subaccount.project.id service_name = "hana" plan_name = "hdi-shared" } +############################################################################################### +# Prepare and setup app: Continuous Integration & Delivery +############################################################################################### +# Entitle subaccount for usage of app Continuous Integration & Delivery +resource "btp_subaccount_entitlement" "cicd_app" { + subaccount_id = btp_subaccount.project.id + service_name = "cicd-app" + plan_name = var.cicd_service_plan +} + locals { cf_org_users = setsubtract(toset(var.cf_org_users), [data.btp_whoami.me.email]) cf_org_admins = setsubtract(toset(var.cf_org_admins), [data.btp_whoami.me.email]) @@ -147,7 +125,7 @@ resource "local_file" "output_vars_step1" { content = <<-EOT cf_api_url = "${jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels)["API Endpoint"]}" cf_org_id = "${btp_subaccount_environment_instance.cloudfoundry.platform_id}" - + cf_org_users = ${jsonencode(local.cf_org_users)} cf_org_admins = ${jsonencode(local.cf_org_admins)} cf_space_developers = ${jsonencode(var.cf_space_developers)} @@ -155,4 +133,4 @@ resource "local_file" "output_vars_step1" { EOT filename = "../step2_cf/terraform.tfvars" -} +} \ No newline at end of file diff --git a/released/discovery_center/mission_4327/step1/outputs.tf b/released/discovery_center/mission_4327/step1/outputs.tf index 0d4bc694..8afdb918 100644 --- a/released/discovery_center/mission_4327/step1/outputs.tf +++ b/released/discovery_center/mission_4327/step1/outputs.tf @@ -22,14 +22,6 @@ output "cf_org_admins" { value = local.cf_org_admins } -output "bas_subscription_url" { - value = btp_subaccount_subscription.bas-subscribe.subscription_url -} - -output "build_workzone_subscription_url" { - value = btp_subaccount_subscription.build_workzone_subscribe.subscription_url -} - output "hana_cloud_tools_subscription_url" { value = btp_subaccount_subscription.hana-cloud-tools.subscription_url -} +} \ No newline at end of file diff --git a/released/discovery_center/mission_4327/step1/samples.tfvars b/released/discovery_center/mission_4327/step1/samples.tfvars index 23fe67be..eea45fa9 100644 --- a/released/discovery_center/mission_4327/step1/samples.tfvars +++ b/released/discovery_center/mission_4327/step1/samples.tfvars @@ -15,18 +15,22 @@ subaccount_admins = ["joe.do@sap.com", "jane.do@sap.com"] # Entitlements plan update #------------------------------------------------------------------------------------------------------ # For production use of Business Application Studio, upgrade the plan from the `free-tier` to the appropriate plan e.g standard-edition -service_plan__bas = "standard-edition" +# service_plan__bas = "standard-edition" #------------------------------------------------------------------------------------------------------- # For production use of Build Workzone, upgrade the plan from the `free-tier` to the appropriate plan e.g standard service_plan__build_workzone = "standard" #-------------------------------------------------------------------------------------------------------- # For production use of HANA, upgrade the plan from the `free-tier` to the appropriate plan e.g hana service_plan__hana_cloud = "hana" +# cicd service plan +cicd_service_plan = "default" #------------------------------------------------------------------------------------------------------ # Cloud Foundry #------------------------------------------------------------------------------------------------------ # Choose a unique organization name e.g., based on the global account subdomain and subaccount name -cf_org_name = "" +cf_org_name = "" +# hana cloud admin users +hana_cloud_admins = ["john.doe@sap.com"] # Additional Cloud Foundry users cf_space_developers = ["john.doe@sap.com"] cf_space_managers = ["john.doe@sap.com"] diff --git a/released/discovery_center/mission_4327/step1/variables.tf b/released/discovery_center/mission_4327/step1/variables.tf index e7cb8ee3..ff7acfad 100644 --- a/released/discovery_center/mission_4327/step1/variables.tf +++ b/released/discovery_center/mission_4327/step1/variables.tf @@ -43,11 +43,6 @@ variable "subaccount_admins" { ### # Plan_name update -variable "service_plan__bas" { - description = "BAS plan" - type = string - default = "free" -} variable "service_plan__build_workzone" { description = "Build Workzone plan" @@ -61,6 +56,20 @@ variable "service_plan__hana_cloud" { default = "hana-free" } +variable "hana_cloud_admins" { + type = list(string) + description = "Defines the colleagues who are added as admins to access the instance of SAP HANA Cloud." +} +# CICD service plan +variable "cicd_service_plan" { + type = string + description = "The plan for Continous Integration & Delivery subscription" + default = "free" + validation { + condition = contains(["free", "default"], var.cicd_service_plan) + error_message = "Invalid value for Continous Integraion & Delivery. Only 'free' and 'default' are allowed." + } +} ### # Cloud Foundry ### @@ -105,4 +114,4 @@ variable "create_tfvars_file_for_next_stage" { description = "Switch to enable the creation of the tfvars file for the next stage." type = bool default = false -} +} \ No newline at end of file