diff --git a/released/discovery_center/mission_3774/step1/locals.tf b/released/discovery_center/mission_3774/step1/locals.tf new file mode 100644 index 00000000..ef8abdc6 --- /dev/null +++ b/released/discovery_center/mission_3774/step1/locals.tf @@ -0,0 +1,3 @@ +locals { + service_name__build_workzone = "SAPLaunchpad" +} diff --git a/released/discovery_center/mission_3774/step1/main.tf b/released/discovery_center/mission_3774/step1/main.tf index e4bdb0bf..27df7c91 100644 --- a/released/discovery_center/mission_3774/step1/main.tf +++ b/released/discovery_center/mission_3774/step1/main.tf @@ -61,7 +61,7 @@ data "btp_subaccount_environments" "all" { # (this replaces the previous null_resource) # ------------------------------------------------------------------------------------------------------ resource "terraform_data" "replacement" { - input = length(var.cf_environment_label) > 0 ? var.cf_environment_label : [for env in data.btp_subaccount_environments.all.values : env if env.service_name == "cloudfoundry" && env.environment_type == "cloudfoundry"][0].landscape_label + input = length(var.cf_landscape_label) > 0 ? var.cf_landscape_label : [for env in data.btp_subaccount_environments.all.values : env if env.service_name == "cloudfoundry" && env.environment_type == "cloudfoundry"][0].landscape_label } # ------------------------------------------------------------------------------------------------------ # Creation of Cloud Foundry environment @@ -85,15 +85,15 @@ resource "btp_subaccount_environment_instance" "cloudfoundry" { # Entitle subaccount for usage of app destination SAP Build Workzone, standard edition resource "btp_subaccount_entitlement" "build_workzone" { subaccount_id = btp_subaccount.dc_mission.id - service_name = "SAPLaunchpad" - plan_name = var.qas_service_plan__build_workzone - amount = var.qas_service_plan__build_workzone == "free" ? 1 : null + service_name = local.service_name__build_workzone + plan_name = var.service_plan__build_workzone + amount = var.service_plan__build_workzone == "free" ? 1 : null } # Create app subscription to SAP Build Workzone, standard edition (depends on entitlement) resource "btp_subaccount_subscription" "build_workzone" { subaccount_id = btp_subaccount.dc_mission.id - app_name = "SAPLaunchpad" - plan_name = var.qas_service_plan__build_workzone + app_name = local.service_name__build_workzone + plan_name = var.service_plan__build_workzone depends_on = [btp_subaccount_entitlement.build_workzone] } ############################################################################################### @@ -127,7 +127,7 @@ resource "local_file" "output_vars_step1" { subaccount_id = "${btp_subaccount.dc_mission.id}" - cf_api_endpoint = "${jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels)["API Endpoint"]}" + cf_api_url = "${jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels)["API Endpoint"]}" cf_org_id = "${jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels)["Org ID"]}" cf_org_name = "${jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels)["Org Name"]}" diff --git a/released/discovery_center/mission_3774/step1/outputs.tf b/released/discovery_center/mission_3774/step1/outputs.tf index 28ef29a2..37e98bad 100644 --- a/released/discovery_center/mission_3774/step1/outputs.tf +++ b/released/discovery_center/mission_3774/step1/outputs.tf @@ -3,11 +3,16 @@ output "subaccount_id" { description = "The ID of the subaccount." } -output "cf_api_endpoint" { +output "cf_api_url" { value = jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels)["API Endpoint"] description = "The Cloudfoundry API endpoint." } +output "cf_landscape_label" { + value = terraform_data.replacement.output + description = "The Cloudfoundry landscape label." +} + output "cf_org_id" { value = jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels)["Org ID"] description = "The Cloudfoundry org id." diff --git a/released/discovery_center/mission_3774/step1/variables.tf b/released/discovery_center/mission_3774/step1/variables.tf index 41f92a17..e8de385d 100644 --- a/released/discovery_center/mission_3774/step1/variables.tf +++ b/released/discovery_center/mission_3774/step1/variables.tf @@ -81,7 +81,7 @@ variable "origin_key" { # but are normally set to "sap.ids", "sap.default" or "sap.custom" } -variable "cf_environment_label" { +variable "cf_landscape_label" { type = string description = "In case there are multiple environments available for a subaccount, you can use this label to choose with which one you want to go. If nothing is given, we take by default the first available." default = "" @@ -143,12 +143,12 @@ variable "cf_space_developers" { } } -variable "qas_service_plan__build_workzone" { +variable "service_plan__build_workzone" { type = string description = "The plan for build_workzone subscription" default = "free" validation { - condition = contains(["free", "standard"], var.qas_service_plan__build_workzone) + condition = contains(["free", "standard"], var.service_plan__build_workzone) error_message = "Invalid value for qas_service_plan__build_workzone. Only 'free' and 'standard' are allowed." } } diff --git a/released/discovery_center/mission_3774/step2/provider.tf b/released/discovery_center/mission_3774/step2/provider.tf index d43ba5fa..d97e6e97 100644 --- a/released/discovery_center/mission_3774/step2/provider.tf +++ b/released/discovery_center/mission_3774/step2/provider.tf @@ -17,5 +17,5 @@ provider "btp" { cli_server_url = var.cli_server_url } provider "cloudfoundry" { - api_url = var.cf_api_endpoint + api_url = var.cf_api_url } diff --git a/released/discovery_center/mission_3774/step2/variables.tf b/released/discovery_center/mission_3774/step2/variables.tf index 57d6c3e0..fc0749ef 100644 --- a/released/discovery_center/mission_3774/step2/variables.tf +++ b/released/discovery_center/mission_3774/step2/variables.tf @@ -13,7 +13,7 @@ variable "cli_server_url" { default = "https://cli.btp.cloud.sap" } -variable "cf_api_endpoint" { +variable "cf_api_url" { type = string description = "The Cloud Foundry API endpoint from the Cloud Foundry environment instance." } @@ -30,64 +30,12 @@ variable "cf_space_name" { } # subaccount -variable "subaccount_name" { - type = string - description = "The subaccount name." - default = "UC - Establish a Central Inbox with SAP Task Center" -} variable "subaccount_id" { type = string description = "The subaccount ID." default = "" } -# Region -variable "region" { - type = string - description = "The region where the project account shall be created in." - default = "us10" -} -# Cloudfoundry environment label -variable "cf_environment_label" { - type = string - description = "The Cloudfoundry environment label" - default = "cf-us10" -} - -variable "subaccount_admins" { - type = list(string) - description = "Defines the colleagues who are added to each subaccount as subaccount administrators." - default = ["jane.doe@test.com", "john.doe@test.com"] - - # add validation to check if admins contains a list of valid email addresses - validation { - condition = length([for email in var.subaccount_admins : can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", email))]) == length(var.subaccount_admins) - error_message = "Please enter a valid email address." - } -} - -variable "subaccount_service_admins" { - type = list(string) - description = "Defines the colleagues who are added to each subaccount as subaccount service administrators." - default = ["jane.doe@test.com", "john.doe@test.com"] - - # add validation to check if admins contains a list of valid email addresses - validation { - condition = length([for email in var.subaccount_service_admins : can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", email))]) == length(var.subaccount_service_admins) - error_message = "Please enter a valid email address." - } -} -variable "launchpad_admins" { - type = list(string) - description = "Defines the colleagues who are added to each subaccount as subaccount service administrators." - default = ["jane.doe@test.com", "john.doe@test.com"] - - # add validation to check if admins contains a list of valid email addresses - validation { - condition = length([for email in var.launchpad_admins : can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", email))]) == length(var.launchpad_admins) - error_message = "Please enter a valid email address." - } -} variable "origin_key" { type = string @@ -97,28 +45,11 @@ variable "origin_key" { # but are normally set to "sap.ids", "sap.default" or "sap.custom" } -variable "environment_label" { - type = string - description = "In case there are multiple environments available for a subaccount, you can use this label to choose with which one you want to go. If nothing is given, we take by default the first available." - default = "cf-us10" -} - variable "cf_org_id" { type = string description = "The Cloud Foundry Org ID from the Cloud Foundry environment instance." } -variable "cf_org_name" { - type = string - description = "Name of the Cloud Foundry org." - default = "mission-3774-sap-task-center" - - validation { - condition = can(regex("^.{1,255}$", var.cf_org_name)) - error_message = "The Cloud Foundry org name must not be emtpy and not exceed 255 characters." - } -} - variable "cf_org_admins" { type = list(string) description = "List of users to set as Cloudfoundry org administrators." @@ -151,13 +82,3 @@ variable "cf_space_developers" { error_message = "Please enter a valid email address for the CF space developers." } } - -variable "service_plan__build_workzone" { - type = string - description = "The plan for build_workzone subscription" - default = "free" - validation { - condition = contains(["free", "standard"], var.service_plan__build_workzone) - error_message = "Invalid value for service_plan__build_workzone. Only 'free' and 'standard' are allowed." - } -}