diff --git a/released/discovery_center/mission_3488/step1/README.md b/released/discovery_center/mission_3488/step1/README.md new file mode 100644 index 00000000..3c364e4a --- /dev/null +++ b/released/discovery_center/mission_3488/step1/README.md @@ -0,0 +1,51 @@ +# Discovery Center mission - Get started with Extended Planning and Analysis (xP&A) + +## Overview + +This sample shows how to set up your SAP BTP account for the Discovery Center Mission - [Get started with Extended Planning and Analysis (xP&A)](https://discovery-center.cloud.sap/missiondetail/3488/) + +## Content of setup + +The setup comprises the following resources: + +- Creation of the SAP BTP subaccount +- Enablement of Cloudfoundry Environment - [see available regions and endpoints](https://help.sap.com/docs/btp/sap-business-technology-platform/regions-and-api-endpoints-available-for-cloud-foundry-environment) +- Entitlements of services +- Subscriptions to applications +- Role collection assignments to users + +## Deploying the resources + +Make sure that you are familiar with SAP BTP and know both the [Get Started with btp-terraform-samples](https://github.com/SAP-samples/btp-terraform-samples/blob/main/GET_STARTED.md) and the [Get Started with the Terraform Provider for BTP](https://developers.sap.com/tutorials/btp-terraform-get-started.html) + +To deploy the resources execute the following commands: + +1. Initialize your workspace: + + ```bash + terraform init + ``` + +1. Assign the variable values in a `*.tfvars` file e.g., the global account subdomain + +1. You can check what Terraform plans to apply based on your configuration: + + ```bash + terraform plan -var-file=".tfvars" + ``` + +1. Apply your configuration to provision the resources: + + ```bash + terraform apply -var-file=".tfvars" + ``` + +> **Note** - Some variables of the output of the first step are needed as input for the second step. + +## When finished + +You probably want to remove the assets after trying them out to avoid unnecessary costs. To do so execute the following command: + +```bash +terraform destroy -var-file=".tfvars" +``` \ No newline at end of file diff --git a/released/discovery_center/mission_3488/step1/locals.tf b/released/discovery_center/mission_3488/step1/locals.tf new file mode 100644 index 00000000..09136428 --- /dev/null +++ b/released/discovery_center/mission_3488/step1/locals.tf @@ -0,0 +1,3 @@ +locals { + service_name__sac = "analytics-planning-osb" +} diff --git a/released/discovery_center/mission_3488/step1/main.tf b/released/discovery_center/mission_3488/step1/main.tf new file mode 100644 index 00000000..4c8fd870 --- /dev/null +++ b/released/discovery_center/mission_3488/step1/main.tf @@ -0,0 +1,90 @@ +# ------------------------------------------------------------------------------------------------------ +# Setup of names based on variables +# ------------------------------------------------------------------------------------------------------ +resource "random_uuid" "uuid" {} + +locals { + random_uuid = random_uuid.uuid.result + subaccount_domain = lower("${var.subaccount_name}-${local.random_uuid}") + subaccount_name = var.subaccount_name + subaccount_cf_org = substr(replace("${local.subaccount_domain}", "-", ""), 0, 32) +} + +# ------------------------------------------------------------------------------------------------------ +# Creation of subaccount +# ------------------------------------------------------------------------------------------------------ +resource "btp_subaccount" "dc_mission" { + name = var.subaccount_name + subdomain = join("-", ["dc-mission-3488", random_uuid.uuid.result]) + region = lower(var.region) +} + + +# ------------------------------------------------------------------------------------------------------ +# Assignment of basic entitlements for an SAC setup +# ------------------------------------------------------------------------------------------------------ +resource "btp_subaccount_entitlement" "sac__service_instance_plan" { + subaccount_id = btp_subaccount.dc_mission.id + service_name = local.service_name__sac + plan_name = var.service_plan__sac +} + + +# ------------------------------------------------------------------------------------------------------ +# Creation of Cloud Foundry environment +# ------------------------------------------------------------------------------------------------------ + +# Fetch all available environments for the subaccount +data "btp_subaccount_environments" "all" { + subaccount_id = btp_subaccount.dc_mission.id +} + +# Take the landscape label from the first CF environment if no environment label is provided +resource "terraform_data" "replacement" { + 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 +} + +# Create the Cloud Foundry environment instance +resource "btp_subaccount_environment_instance" "cf_sac" { + subaccount_id = btp_subaccount.dc_mission.id + name = local.subaccount_cf_org + environment_type = "cloudfoundry" + service_name = "cloudfoundry" + plan_name = var.cf_plan_name + landscape_label = terraform_data.replacement.output + + parameters = jsonencode({ + instance_name = local.subaccount_cf_org + }) +} + + +resource "local_file" "output_vars_step1" { + count = var.create_tfvars_file_for_next_stage ? 1 : 0 + content = <<-EOT + origin = "${var.origin}" + + cf_api_url = "${jsondecode(btp_subaccount_environment_instance.cf_sac.labels)["API Endpoint"]}" + cf_org_id = "${btp_subaccount_environment_instance.cf_sac.platform_id}" + + cf_org_auditors = ${jsonencode(var.cf_org_auditors)} + cf_org_billing_managers = ${jsonencode(var.cf_org_billing_managers)} + cf_org_admins = ${jsonencode(var.cf_org_admins)} + cf_space_auditors = ${jsonencode(var.cf_space_auditors)} + cf_space_developers = ${jsonencode(var.cf_space_developers)} + cf_space_managers = ${jsonencode(var.cf_space_managers)} + + service_plan__sac = "${var.service_plan__sac}" + + sac_param_first_name = "${var.sac_param_first_name}" + sac_param_last_name = "${var.sac_param_last_name}" + sac_param_email = "${var.sac_param_email}" + sac_param_host_name = "${var.sac_param_host_name}" + + sac_param_number_of_business_intelligence_licenses = ${var.sac_param_number_of_business_intelligence_licenses} + sac_param_number_of_professional_licenses = ${var.sac_param_number_of_professional_licenses} + sac_param_number_of_business_standard_licenses = ${var.sac_param_number_of_business_standard_licenses} + + EOT + filename = "../step2/terraform.tfvars" +} diff --git a/released/discovery_center/mission_3488/step1/outputs.tf b/released/discovery_center/mission_3488/step1/outputs.tf new file mode 100644 index 00000000..2ca0c372 --- /dev/null +++ b/released/discovery_center/mission_3488/step1/outputs.tf @@ -0,0 +1,105 @@ +output "subaccount_id" { + value = btp_subaccount.dc_mission.id + description = "The ID of the subaccount." +} + +output "cf_org_name" { + value = local.subaccount_cf_org + description = "The name of the Cloud Foundry org connected to the subaccount." +} + +output "cf_org_id" { + value = btp_subaccount_environment_instance.cf_sac.platform_id + description = "The ID of the Cloud Foundry org connected to the subaccount." +} + +output "cf_api_url" { + value = lookup(jsondecode(btp_subaccount_environment_instance.cf_sac.labels), "API Endpoint", "not found") + description = "API endpoint of the Cloud Foundry environment." +} + +output "cf_landscape_label" { + value = btp_subaccount_environment_instance.cf_sac.landscape_label + description = "Landscape label of the Cloud Foundry environment." +} + +output "cf_space_name" { + value = var.cf_space_name + description = "The name of the Cloud Foundry space." +} + +output "origin" { + value = var.origin + description = "The identity provider for the UAA user." +} + +output "cf_org_admins" { + value = var.cf_org_admins + description = "List of Cloud Foundry org admins." +} + +output "cf_org_billing_managers" { + value = var.cf_org_billing_managers + description = "List of Cloud Foundry org billing managers." +} + +output "cf_org_auditors" { + value = var.cf_org_auditors + description = "List of Cloud Foundry org auditors." +} + +output "cf_space_managers" { + value = var.cf_space_managers + description = "List of managers for the Cloud Foundry space." +} + +output "cf_space_developers" { + value = var.cf_space_developers + description = "List of developers for the Cloud Foundry space." +} + +output "cf_space_auditors" { + value = var.cf_space_auditors + description = "The list of Cloud Foundry space auditors." +} + +output "service_plan__sac" { + value = var.service_plan__sac + description = "Plan for the service instance of SAC." +} + +output "sac_param_first_name" { + value = var.sac_param_first_name + description = "First name of the SAC responsible" +} + +output "sac_param_last_name" { + value = var.sac_param_last_name + description = "Last name of the SAC responsible" +} + +output "sac_param_email" { + value = var.sac_param_email + description = "Email of the SAC responsible" +} + +output "sac_param_host_name" { + value = var.sac_param_host_name + description = "Host name of the SAC" +} + +output "sac_param_number_of_business_intelligence_licenses" { + value = var.sac_param_number_of_business_intelligence_licenses + description = "Number of business intelligence licenses" +} + + +output "sac_param_number_of_professional_licenses" { + value = var.sac_param_number_of_professional_licenses + description = "Number of business professional licenses" +} + +output "sac_param_number_of_business_standard_licenses" { + value = var.sac_param_number_of_business_standard_licenses + description = "Number of business standard licenses" +} diff --git a/released/discovery_center/mission_3488/step1/provider.tf b/released/discovery_center/mission_3488/step1/provider.tf new file mode 100644 index 00000000..1f3304c4 --- /dev/null +++ b/released/discovery_center/mission_3488/step1/provider.tf @@ -0,0 +1,20 @@ + +terraform { + required_providers { + btp = { + source = "sap/btp" + version = "~> 1.4.0" + } + } + +} + +# Please checkout documentation on how best to authenticate against SAP BTP +# via the Terraform provider for SAP BTP +provider "btp" { + # Comment out the idp in case you need it to connect to your global account + # ------------------------------------------------------------------------- + # idp = var.custom_idp + globalaccount = var.globalaccount + cli_server_url = var.cli_server_url +} diff --git a/released/discovery_center/mission_3488/step1/sample.tfvars b/released/discovery_center/mission_3488/step1/sample.tfvars new file mode 100644 index 00000000..74cbb709 --- /dev/null +++ b/released/discovery_center/mission_3488/step1/sample.tfvars @@ -0,0 +1,30 @@ +# ------------------------------------------------------------------------------------------------------ +# Provider configuration +# ------------------------------------------------------------------------------------------------------ +# Your global account subdomain +globalaccount = "yourglobalaccount" +region = "datacenter" +subaccount_name = "SAP Discovery Center Mission 3488" + +# ------------------------------------------------------------------------------------------------------ +# Project specific configuration (please adapt!) +# ------------------------------------------------------------------------------------------------------ + +subaccount_admins = ["another.user@test.com"] +subaccount_service_admins = ["another.user@test.com"] + +cf_org_admins = ["another.user@test.com"] +cf_space_managers = ["another.user@test.com", "you@test.com"] +cf_space_developers = ["another.user@test.com", "you@test.com"] + +custom_idp = "" + +create_tfvars_file_for_next_stage = true + +sac_param_first_name = "John" +sac_param_last_name = "Doe" +sac_param_email = "john.doe@test.com" +sac_param_host_name = "johndoetestsac" + + + diff --git a/released/discovery_center/mission_3488/step1/variables.tf b/released/discovery_center/mission_3488/step1/variables.tf new file mode 100644 index 00000000..d973d782 --- /dev/null +++ b/released/discovery_center/mission_3488/step1/variables.tf @@ -0,0 +1,179 @@ +variable "globalaccount" { + type = string + description = "The global account subdomain." +} + +variable "subaccount_name" { + type = string + description = "The name for the subaccount." + default = "" +} + +variable "cli_server_url" { + type = string + description = "The BTP CLI server URL." + default = "https://cli.btp.cloud.sap" +} + +variable "region" { + type = string + description = "The region where the project account shall be created in." + default = "eu11" +} + +variable "cf_plan_name" { + type = string + description = "Desired service plan for the Cloud Foundry environment instance." + default = "standard" +} + +variable "cf_landscape_label" { + type = string + description = "The Cloud Foundry landscape (format example eu10-004)." + default = "" +} + +variable "cf_space_name" { + type = string + description = "The name of the Cloud Foundry space." + default = "dev" +} + +variable "cf_org_admins" { + type = list(string) + description = "List of users to set as Cloudfoundry org administrators." + + # add validation to check if admins contains a list of valid email addresses + validation { + condition = length([for email in var.cf_org_admins : can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", email))]) == length(var.cf_org_admins) + error_message = "Please enter a valid email address for the CF Org admins." + } +} + +variable "cf_org_billing_managers" { + type = list(string) + description = "List of Cloud Foundry org billing managers." + default = [] + + # add validation to check if admins contains a list of valid email addresses + validation { + condition = length([for email in var.cf_org_billing_managers : can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", email))]) == length(var.cf_org_billing_managers) + error_message = "Please enter a valid email address for the subaccount admins." + } +} + +variable "cf_org_auditors" { + type = list(string) + description = "List of Cloud Foundry org auditors." + default = [] + + # add validation to check if admins contains a list of valid email addresses + validation { + condition = length([for email in var.cf_org_auditors : can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", email))]) == length(var.cf_org_auditors) + error_message = "Please enter a valid email address for the subaccount admins." + } +} + +variable "cf_space_managers" { + type = list(string) + description = "List of managers for the Cloud Foundry space." + default = [] + + # add validation to check if admins contains a list of valid email addresses + validation { + condition = length([for email in var.cf_space_managers : can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", email))]) == length(var.cf_space_managers) + error_message = "Please enter a valid email address for the subaccount admins." + } +} + +variable "cf_space_developers" { + type = list(string) + description = "List of developers for the Cloud Foundry space." + default = [] + + # add validation to check if admins contains a list of valid email addresses + validation { + condition = length([for email in var.cf_space_developers : can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", email))]) == length(var.cf_space_developers) + error_message = "Please enter a valid email address for the subaccount admins." + } +} + +variable "cf_space_auditors" { + type = list(string) + description = "The list of Cloud Foundry space auditors." + default = [] + + # add validation to check if admins contains a list of valid email addresses + validation { + condition = length([for email in var.cf_space_auditors : can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", email))]) == length(var.cf_space_auditors) + error_message = "Please enter a valid email address for the subaccount admins." + } +} + + +variable "service_plan__sac" { + type = string + description = "Plan for the service instance of ABAP." + default = "free" +} + + +variable "origin" { + type = string + description = "The identity provider for the UAA user." + default = "sap.ids" +} + +variable "create_tfvars_file_for_next_stage" { + type = bool + description = "Switch to enable the creation of the tfvars file for the next step." + default = false +} + +variable "sac_param_first_name" { + type = string + description = "First name of the SAC responsible" +} + +variable "sac_param_last_name" { + type = string + description = "Last name of the SAC responsible" +} + +variable "sac_param_email" { + type = string + description = "Email of the SAC responsible" + + validation { + condition = can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", var.sac_param_email)) + error_message = "Please enter a valid email address for the SAC responsible." + } +} + +variable "sac_param_host_name" { + type = string + description = "Host name of the SAC" + validation { + condition = can(regex("^[a-zA-Z0-9]", var.sac_param_host_name)) + error_message = "Please enter a valid host name. Should only contain letters and numbers." + } +} + +variable "sac_param_number_of_business_intelligence_licenses" { + type = number + description = "Number of business intelligence licenses" + default = 6 +} + + +variable "sac_param_number_of_professional_licenses" { + type = number + description = "Number of business professional licenses" + default = 1 +} + +variable "sac_param_number_of_business_standard_licenses" { + type = number + description = "Number of business standard licenses" + default = 2 +} diff --git a/released/discovery_center/mission_3488/step2/locals.tf b/released/discovery_center/mission_3488/step2/locals.tf new file mode 100644 index 00000000..09136428 --- /dev/null +++ b/released/discovery_center/mission_3488/step2/locals.tf @@ -0,0 +1,3 @@ +locals { + service_name__sac = "analytics-planning-osb" +} diff --git a/released/discovery_center/mission_3488/step2/main.tf b/released/discovery_center/mission_3488/step2/main.tf new file mode 100644 index 00000000..0665c887 --- /dev/null +++ b/released/discovery_center/mission_3488/step2/main.tf @@ -0,0 +1,107 @@ + +# ------------------------------------------------------------------------------------------------------ +# Assign CF Org roles to the admin users +# ------------------------------------------------------------------------------------------------------ +# Define Org User role +resource "cloudfoundry_org_role" "organization_user" { + for_each = toset("${var.cf_org_admins}") + username = each.value + type = "organization_user" + org = var.cf_org_id + origin = var.origin +} + +resource "cloudfoundry_org_role" "organization_manager" { + for_each = toset("${var.cf_org_admins}") + username = each.value + type = "organization_manager" + org = var.cf_org_id + origin = var.origin + depends_on = [cloudfoundry_org_role.organization_user] +} + +resource "cloudfoundry_org_role" "billing_managers" { + for_each = toset("${var.cf_org_billing_managers}") + username = each.value + type = "organization_billing_manager" + org = var.cf_org_id + origin = var.origin + depends_on = [cloudfoundry_org_role.organization_user] +} + +resource "cloudfoundry_org_role" "org_auditors" { + for_each = toset("${var.cf_org_auditors}") + username = each.value + type = "organization_auditor" + org = var.cf_org_id + origin = var.origin + depends_on = [cloudfoundry_org_role.organization_user] +} + +# ------------------------------------------------------------------------------------------------------ +# Creation of Cloud Foundry space +# ------------------------------------------------------------------------------------------------------ +resource "cloudfoundry_space" "sac_space" { + name = var.cf_space_name + org = var.cf_org_id +} + +# ------------------------------------------------------------------------------------------------------ +# Assignment of Cloud Foundry org roles +# ------------------------------------------------------------------------------------------------------ +resource "cloudfoundry_space_role" "space_managers" { + for_each = toset("${var.cf_space_managers}") + username = each.value + type = "space_manager" + space = cloudfoundry_space.sac_space.id + origin = var.origin + depends_on = [cloudfoundry_org_role.organization_user] +} + +resource "cloudfoundry_space_role" "space_developers" { + for_each = toset("${var.cf_space_developers}") + username = each.value + type = "space_developer" + space = cloudfoundry_space.sac_space.id + origin = var.origin + depends_on = [cloudfoundry_org_role.organization_user] +} + +resource "cloudfoundry_space_role" "space_auditors" { + for_each = toset("${var.cf_space_auditors}") + username = each.value + type = "space_auditor" + space = cloudfoundry_space.sac_space.id + origin = var.origin + depends_on = [cloudfoundry_org_role.organization_user] +} + +# ------------------------------------------------------------------------------------------------------ +# Creation of service instance for SAP Analytics Bloud +# ------------------------------------------------------------------------------------------------------ +data "cloudfoundry_service" "sac_service_plans" { + name = local.service_name__sac +} + +resource "cloudfoundry_service_instance" "sac_si" { + depends_on = [cloudfoundry_space_role.space_managers, cloudfoundry_space_role.space_developers] + name = "service-analytics-planning-osb" + space = cloudfoundry_space.sac_space.id + service_plan = data.cloudfoundry_service.sac_service_plans.service_plans[var.service_plan__sac] + type = "managed" + parameters = jsonencode({ + "first_name" : "${var.sac_param_first_name}", + "last_name" : "${var.sac_param_last_name}", + "email" : "${var.sac_param_email}", + "confirm_email" : "${var.sac_param_email}", + "host_name" : "${var.sac_param_host_name}", + "number_of_business_intelligence_licenses" : var.sac_param_number_of_business_intelligence_licenses, + "number_of_planning_professional_licenses" : var.sac_param_number_of_professional_licenses, + "number_of_planning_standard_licenses" : var.sac_param_number_of_business_standard_licenses + }) + timeouts = { + create = "2h" + delete = "2h" + update = "2h" + } +} diff --git a/released/discovery_center/mission_3488/step2/provider.tf b/released/discovery_center/mission_3488/step2/provider.tf new file mode 100644 index 00000000..7a11e78f --- /dev/null +++ b/released/discovery_center/mission_3488/step2/provider.tf @@ -0,0 +1,16 @@ +terraform { + required_providers { + cloudfoundry = { + source = "sap/cloudfoundry" + version = "0.2.1-beta" + } + } +} + +# This will only work if we know the region in advance +provider "cloudfoundry" { + # Comment out the origin in case you need it to connect to your CF environment + # ---------------------------------------------------------------------------- + # origin = var.origin + api_url = var.cf_api_url +} diff --git a/released/discovery_center/mission_3488/step2/variables.tf b/released/discovery_center/mission_3488/step2/variables.tf new file mode 100644 index 00000000..62fe9da5 --- /dev/null +++ b/released/discovery_center/mission_3488/step2/variables.tf @@ -0,0 +1,149 @@ +variable "cf_api_url" { + type = string + description = "The API endpoint of the Cloud Foundry environment." +} + +variable "cf_org_id" { + type = string + description = "The Cloud Foundry landscape (format example eu10-004)." +} + +variable "origin" { + type = string + description = "The identity provider for the UAA user." + default = "sap.ids" +} + +variable "cf_org_admins" { + type = list(string) + description = "List of users to set as Cloudfoundry org administrators." + + # add validation to check if admins contains a list of valid email addresses + validation { + condition = length([for email in var.cf_org_admins : can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", email))]) == length(var.cf_org_admins) + error_message = "Please enter a valid email address for the CF Org admins." + } +} + + +variable "cf_org_billing_managers" { + type = list(string) + description = "List of Cloud Foundry org billing managers." + default = [] + + # add validation to check if admins contains a list of valid email addresses + validation { + condition = length([for email in var.cf_org_billing_managers : can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", email))]) == length(var.cf_org_billing_managers) + error_message = "Please enter a valid email address for the subaccount admins." + } +} + +variable "cf_org_auditors" { + type = list(string) + description = "List of Cloud Foundry org auditors." + default = [] + + # add validation to check if admins contains a list of valid email addresses + validation { + condition = length([for email in var.cf_org_auditors : can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", email))]) == length(var.cf_org_auditors) + error_message = "Please enter a valid email address for the subaccount admins." + } +} + +variable "cf_space_managers" { + type = list(string) + description = "List of managers for the Cloud Foundry space." + default = [] + + # add validation to check if admins contains a list of valid email addresses + validation { + condition = length([for email in var.cf_space_managers : can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", email))]) == length(var.cf_space_managers) + error_message = "Please enter a valid email address for the subaccount admins." + } +} + +variable "cf_space_developers" { + type = list(string) + description = "List of developers for the Cloud Foundry space." + default = [] + + # add validation to check if admins contains a list of valid email addresses + validation { + condition = length([for email in var.cf_space_developers : can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", email))]) == length(var.cf_space_developers) + error_message = "Please enter a valid email address for the subaccount admins." + } +} + +variable "cf_space_auditors" { + type = list(string) + description = "The list of Cloud Foundry space auditors." + default = [] + + # add validation to check if admins contains a list of valid email addresses + validation { + condition = length([for email in var.cf_space_auditors : can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", email))]) == length(var.cf_space_auditors) + error_message = "Please enter a valid email address for the subaccount admins." + } +} + +variable "cf_space_name" { + type = string + description = "The name of the Cloud Foundry space." + default = "dev" +} + + +variable "service_plan__sac" { + type = string + description = "Plan for the service instance of ABAP." + default = "free" +} + +variable "sac_param_first_name" { + type = string + description = "First name of the SAC responsible" +} + +variable "sac_param_last_name" { + type = string + description = "Last name of the SAC responsible" +} + +variable "sac_param_email" { + type = string + description = "Email of the SAC responsible" + + validation { + condition = can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", var.sac_param_email)) + error_message = "Please enter a valid email address for the SAC responsible." + } +} + +variable "sac_param_host_name" { + type = string + description = "Host name of the SAC" + validation { + condition = can(regex("^[a-zA-Z0-9]", var.sac_param_host_name)) + error_message = "Please enter a valid host name. Should only contain letters and numbers." + } +} + + +variable "sac_param_number_of_business_intelligence_licenses" { + type = number + description = "Number of business intelligence licenses" + default = 6 +} + + +variable "sac_param_number_of_professional_licenses" { + type = number + description = "Number of business professional licenses" + default = 1 +} + +variable "sac_param_number_of_business_standard_licenses" { + type = number + description = "Number of business standard licenses" + default = 2 +} diff --git a/released/discovery_center/mission_3774/step1/README.md b/released/discovery_center/mission_3774/step1/README.md index 1b327508..0ecb21b1 100644 --- a/released/discovery_center/mission_3774/step1/README.md +++ b/released/discovery_center/mission_3774/step1/README.md @@ -1,43 +1,57 @@ -# Sample Setup of an SAP Task Center on SAP BTP - Step 1 +# SAP Discovery Center mission - Get started with Extended Planning and Analysis ## Overview -This directory contains the setup of SAP Task Center from scratch namely a new subaccount including the relevant entitlements, a Cloud Foundry environment and a Cloud Foundry space. +This terraform script demonstrates how to set up your SAP Datasphere tenant for the SAP Discovery Center Mission - [Get started with Extended Planning and Analysis](https://discovery-center.cloud.sap/missiondetail/4104/3488/) -This directory contains the configuration the first step of the setup namely: +## Content of setup -- a new subaccount -- the entitlements for SAP Task Center -- the subscription for SAP Build Workzone, standard edition -- the Cloud Foundry environment -- The trust setup to the custom IdP -- Assignment of users to the role collections +The setup comprises the following resources: + +- Creation of the SAP BTP subaccount +- Enablement of Cloudfoundry Environment - [see available regions and endpoints](https://help.sap.com/docs/btp/sap-business-technology-platform/regions-and-api-endpoints-available-for-cloud-foundry-environment) +- Entitlements of services + * SAP Analytics Cloud +- Subscription to the service +- Role collection assignments to users ## Deploying the resources -To deploy the resources of step 1 execute the following commands: +Make sure that you are familiar with SAP BTP and know both the [Get Started with btp-terraform-samples](https://github.com/SAP-samples/btp-terraform-samples/blob/main/GET_STARTED.md) and the [Get Started with the Terraform Provider for BTP](https://developers.sap.com/tutorials/btp-terraform-get-started.html) -1. Initialize your workspace: +To deploy the resources you must: +1. Set your credentials as environment variables + ```bash - terraform init + export BTP_USERNAME ='' + export BTP_PASSWORD ='' ``` -1. Assign the variable values in a `*.tfvars` file e.g., the global account subdomain +2. Change the variables in the `sample.tfvars` file to meet your requirements + + > The minimal set of parameters you should specify (besides user_email and password) is global account (i.e. its subdomain) and the used custom_idp and all user assignments + + > ⚠ NOTE: You should pay attention **specifically** to the users defined in the samples.tfvars whether they already exist in your SAP BTP accounts. Otherwise, you might get error messages like, e.g., `Error: The user could not be found: jane.doe@test.com`. + -1. You can check what Terraform plans to apply based on your configuration: +3. Initialize your workspace: ```bash - terraform plan -var-file=".tfvars" + terraform init ``` -1. Apply your configuration to provision the resources: +4. You can check what Terraform plans to apply based on your configuration: ```bash - terraform apply -var-file=".tfvars" + terraform plan -var-file="sample.tfvars" ``` -> **Note** - Some variables of the output of the first step are needed as input for the second step. +5. Apply your configuration to provision the resources: + + ```bash + terraform apply -var-file="sample.tfvars" + ``` ## When finished