diff --git a/released/discovery_center/mission_3585/step1/README.md b/released/discovery_center/mission_3585/README.md similarity index 73% rename from released/discovery_center/mission_3585/step1/README.md rename to released/discovery_center/mission_3585/README.md index 844811d7..66120e3d 100644 --- a/released/discovery_center/mission_3585/step1/README.md +++ b/released/discovery_center/mission_3585/README.md @@ -1,8 +1,8 @@ -# Discovery Center mission - Get Started on SAP BTP with SAPUI5/Fiori - Create a Hello World App (Step 1) +# Discovery Center mission - Get Started on SAP BTP with SAPUI5/Fiori - Create a Hello World App ## Overview -Step 1 of this sample shows how to set up your SAP BTP account for the Discovery Center Mission - [Get Started on SAP BTP with SAPUI5/Fiori - Create a Hello World App](https://discovery-center.cloud.sap/missiondetail/3585/) +This sample shows how to set up your SAP BTP account for the Discovery Center Mission - [Get Started on SAP BTP with SAPUI5/Fiori - Create a Hello World App](https://discovery-center.cloud.sap/missiondetail/3585/) ## Content of setup @@ -32,19 +32,18 @@ To deploy the resources you must: 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 + > 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`. -3. The outputs of this `step1` will be needed for the `step2` of this use case. In case you want to create a file with the content of the variables, you should set the variable `create_tfvars_file_for_next_step` to `true`. This will create a `terraform.tfvars` file in the `step2` folder. -4. Initialize your workspace: +3. Initialize your workspace: ```bash terraform init ``` -5. You can check what Terraform plans to apply based on your configuration: +4. You can check what Terraform plans to apply based on your configuration: ```bash terraform plan -var-file="sample.tfvars" diff --git a/released/discovery_center/mission_3585/step1/main.tf b/released/discovery_center/mission_3585/main.tf similarity index 73% rename from released/discovery_center/mission_3585/step1/main.tf rename to released/discovery_center/mission_3585/main.tf index 3fe5e731..dafdd428 100644 --- a/released/discovery_center/mission_3585/step1/main.tf +++ b/released/discovery_center/mission_3585/main.tf @@ -2,61 +2,17 @@ # Subaccount setup for DC mission 3585 # ------------------------------------------------------------------------------------------------------ # Setup subaccount domain (to ensure uniqueness in BTP global account) -resource "random_id" "subaccount_domain_suffix" { - byte_length = 12 -} +resource "random_uuid" "uuid" {} + # ------------------------------------------------------------------------------------------------------ # Creation of subaccount # ------------------------------------------------------------------------------------------------------ resource "btp_subaccount" "dc_mission" { name = var.subaccount_name - subdomain = join("-", ["dc-mission-3585", random_id.subaccount_domain_suffix.hex]) + subdomain = join("-", ["dc-mission-3585", random_uuid.uuid.result]) region = lower(var.region) } -# ------------------------------------------------------------------------------------------------------ -# CLOUDFOUNDRY PREPARATION -# ------------------------------------------------------------------------------------------------------ -# -# 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 -# (this replaces the previous null_resource) -# ------------------------------------------------------------------------------------------------------ -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" { - subaccount_id = btp_subaccount.dc_mission.id - name = "cf-${random_id.subaccount_domain_suffix.hex}" - environment_type = "cloudfoundry" - service_name = "cloudfoundry" - plan_name = "standard" - landscape_label = terraform_data.replacement.output - - parameters = jsonencode({ - instance_name = "cf-${random_id.subaccount_domain_suffix.hex}" - }) -} - -############################################################################################### -# Prepare CF -############################################################################################### -# Entitle subaccount for usage of cf runtime - -resource "btp_subaccount_entitlement" "cf_runtime" { - subaccount_id = btp_subaccount.dc_mission.id - service_name = "APPLICATION_RUNTIME" - plan_name = "MEMORY" - amount = 1 -} - # ------------------------------------------------------------------------------------------------------ # SERVICES # ------------------------------------------------------------------------------------------------------ @@ -218,24 +174,3 @@ resource "btp_subaccount_role_collection_assignment" "cicd_developers" { user_name = each.value depends_on = [btp_subaccount_subscription.cicd_app] } - - -# ------------------------------------------------------------------------------------------------------ -# Create tfvars file for step 2 (if variable `create_tfvars_file_for_step2` is set to true) -# ------------------------------------------------------------------------------------------------------ -resource "local_file" "output_vars_step1" { - count = var.create_tfvars_file_for_next_step ? 1 : 0 - content = <<-EOT - cf_api_url = "${jsondecode(btp_subaccount_environment_instance.cf.labels)["API Endpoint"]}" - - cf_org_id = "${jsondecode(btp_subaccount_environment_instance.cf.labels)["Org ID"]}" - - cf_origin = "${var.cf_origin}" - - cf_space_name = "${var.cf_space_name}" - - cf_org_admins = ${jsonencode(var.cf_org_admins)} - - EOT - filename = "../step2/terraform.tfvars" -} diff --git a/released/discovery_center/mission_3585/outputs.tf b/released/discovery_center/mission_3585/outputs.tf new file mode 100644 index 00000000..1d4e2ec8 --- /dev/null +++ b/released/discovery_center/mission_3585/outputs.tf @@ -0,0 +1,19 @@ +output "subaccount_id" { + value = btp_subaccount.dc_mission.id + description = "The Global Account subdomain id." +} + +output "cicd_app_subscription_url" { + value = btp_subaccount_subscription.cicd_app.subscription_url + description = "Continuous Integration & Delivery subscription URL." +} + +output "sapappstudio_subscription_url" { + value = btp_subaccount_subscription.sapappstudio.subscription_url + description = "SAP Business Application Studio subscription URL." +} + +output "sap_launchpad_subscription_url" { + value = btp_subaccount_subscription.sap_launchpad.subscription_url + description = "SAP Build Work Zone, standard edition subscription URL." +} diff --git a/released/discovery_center/mission_3585/step1/provider.tf b/released/discovery_center/mission_3585/provider.tf similarity index 100% rename from released/discovery_center/mission_3585/step1/provider.tf rename to released/discovery_center/mission_3585/provider.tf diff --git a/released/discovery_center/mission_3585/step1/sample.tfvars b/released/discovery_center/mission_3585/sample.tfvars similarity index 88% rename from released/discovery_center/mission_3585/step1/sample.tfvars rename to released/discovery_center/mission_3585/sample.tfvars index accda4a8..0f197faa 100644 --- a/released/discovery_center/mission_3585/step1/sample.tfvars +++ b/released/discovery_center/mission_3585/sample.tfvars @@ -17,7 +17,6 @@ subaccount_name = "SAP Discovery Center Mission 3585" # USER ROLES # ------------------------------------------------------------------------------------------------------ subaccount_admins = ["another.user@test.com"] -cf_org_admins = ["another.user@test.com"] launchpad_admins = ["another.user@test.com", "you@test.com"] @@ -26,6 +25,3 @@ cicd_developers = ["another.user@test.com", "you@test.com"] bas_admins = ["another.user@test.com", "you@test.com"] bas_developers = ["another.user@test.com", "you@test.com"] - -# Create variables file for step 2 (disabled by default) -create_tfvars_file_for_next_step = true diff --git a/released/discovery_center/mission_3585/step1/outputs.tf b/released/discovery_center/mission_3585/step1/outputs.tf deleted file mode 100644 index db09ecc8..00000000 --- a/released/discovery_center/mission_3585/step1/outputs.tf +++ /dev/null @@ -1,39 +0,0 @@ -output "globalaccount" { - value = var.globalaccount - description = "The Global Account subdomain." -} - -output "subaccount_id" { - value = btp_subaccount.dc_mission.id - description = "The Global Account subdomain id." -} - -output "cf_api_url" { - value = jsondecode(btp_subaccount_environment_instance.cf.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.cf.labels)["Org ID"] - description = "The Cloudfoundry org id." -} - -output "cf_org_name" { - value = jsondecode(btp_subaccount_environment_instance.cf.labels)["Org Name"] - description = "The Cloudfoundry org name." -} - -output "custom_idp" { - value = var.custom_idp - description = "The custom identity provider." -} - -output "cf_org_admins" { - value = var.cf_org_admins - description = "List of users to set as Cloudfoundry org administrators." -} diff --git a/released/discovery_center/mission_3585/step2/README.md b/released/discovery_center/mission_3585/step2/README.md deleted file mode 100644 index cf5a0467..00000000 --- a/released/discovery_center/mission_3585/step2/README.md +++ /dev/null @@ -1,58 +0,0 @@ -# Discovery Center mission - Get Started on SAP BTP with SAPUI5/Fiori - Create a Hello World App (Step 2) - -## Overview - -Step 2 of this sample shows how to Cloud Foundry environment for the Discovery Center Mission - [Get Started on SAP BTP with SAPUI5/Fiori - Create a Hello World App](https://discovery-center.cloud.sap/missiondetail/3585/) - -## Content of setup - -This setup step comprises the following resources: - -- Creation of a Cloud Foundry space -- Cloud Foundry role 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 you must: - -1. Set the environment variables CF_USER and CF_PASSWORD to pass credentials to the Cloud Foundry provider to authenticate and interact with your Cloud Foundry environment instance. - - ```bash - export CF_USER= - export CF_PASSWORD= - ``` - -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 Cloud Foundry API URL and all Cloud Foundry 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`. - - -3. Initialize your workspace: - - ```bash - terraform init - ``` - -4. You can check what Terraform plans to apply based on your configuration: - - ```bash - terraform plan -var-file="sample.tfvars" - ``` - -5. Apply your configuration to provision the resources: - - ```bash - terraform apply -var-file="sample.tfvars" - ``` - -## 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="sample.tfvars" -``` diff --git a/released/discovery_center/mission_3585/step2/main.tf b/released/discovery_center/mission_3585/step2/main.tf deleted file mode 100644 index 843b7207..00000000 --- a/released/discovery_center/mission_3585/step2/main.tf +++ /dev/null @@ -1,32 +0,0 @@ -# ------------------------------------------------------------------------------------------------------ -# Create the Cloud Foundry space -# ------------------------------------------------------------------------------------------------------ -resource "cloudfoundry_space" "space" { - name = var.cf_space_name - org = var.cf_org_id -} - -# ------------------------------------------------------------------------------------------------------ -# USERS AND ROLES -# ------------------------------------------------------------------------------------------------------ -# -# ------------------------------------------------------------------------------------------------------ -# 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.cf_origin -} -# Define Org Manager role -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.cf_origin - depends_on = [cloudfoundry_org_role.organization_user] -} diff --git a/released/discovery_center/mission_3585/step2/provider.tf b/released/discovery_center/mission_3585/step2/provider.tf deleted file mode 100644 index 554e0843..00000000 --- a/released/discovery_center/mission_3585/step2/provider.tf +++ /dev/null @@ -1,15 +0,0 @@ -### -# Define the required providers for this module -### -terraform { - required_providers { - cloudfoundry = { - source = "SAP/cloudfoundry" - version = "0.2.1-beta" - } - } -} - -provider "cloudfoundry" { - api_url = var.cf_api_url -} diff --git a/released/discovery_center/mission_3585/step2/sample.tfvars b/released/discovery_center/mission_3585/step2/sample.tfvars deleted file mode 100644 index e6ae97e4..00000000 --- a/released/discovery_center/mission_3585/step2/sample.tfvars +++ /dev/null @@ -1,8 +0,0 @@ -# ------------------------------------------------------------------------------------------------------ -# Provider configuration (this file will be either created automatically in step 1 or manually in step 2) -# ------------------------------------------------------------------------------------------------------ -cf_origin = "sap.ids" -cf_api_url = "https://api.cf.us10.hana.ondemand.com" -cf_org_id = "your_cf_org_id" -cf_space_name = "dev" -cf_org_admins = ["another.user@test.com"] diff --git a/released/discovery_center/mission_3585/step2/variables.tf b/released/discovery_center/mission_3585/step2/variables.tf deleted file mode 100644 index 7f08b545..00000000 --- a/released/discovery_center/mission_3585/step2/variables.tf +++ /dev/null @@ -1,34 +0,0 @@ -variable "cf_api_url" { - type = string - description = "The API URL of the Cloud Foundry environment instance." -} - -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_id" { - type = string - description = "The Cloud Foundry Org ID to use." -} - -variable "cf_origin" { - type = string - description = "Defines the origin key of the identity provider" - default = "sap.ids" - # The value for the cf_origin can be defined - # but are normally set to "sap.ids", "sap.default" or "sap.custom" -} - -variable "cf_space_name" { - type = string - description = "The Cloud Foundry Space name to use." - default = "dev" -} diff --git a/released/discovery_center/mission_3585/step1/variables.tf b/released/discovery_center/mission_3585/variables.tf similarity index 72% rename from released/discovery_center/mission_3585/step1/variables.tf rename to released/discovery_center/mission_3585/variables.tf index 83a00076..fbd8bec0 100644 --- a/released/discovery_center/mission_3585/step1/variables.tf +++ b/released/discovery_center/mission_3585/variables.tf @@ -87,45 +87,8 @@ variable "cicd_admins" { } } -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_origin" { - type = string - description = "Defines the origin key of the identity provider" - default = "sap.ids" - # The value for the cf_origin can be defined - # but are normally set to "sap.ids", "sap.default" or "sap.custom" -} - -variable "cf_landscape_label" { - type = string - description = "In case there are multiple landscapes 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 = "" -} - -variable "cf_space_name" { - type = string - description = "The Cloud Foundry space name to use" - default = "dev" -} - variable "custom_idp" { type = string description = "The custom identity provider for the subaccount." default = "sap.ids" } - -variable "create_tfvars_file_for_next_step" { - type = bool - description = "Switch to enable the creation of the tfvars file for step 2." - default = false -} diff --git a/released/discovery_center/mission_4024/outputs.tf b/released/discovery_center/mission_4024/outputs.tf index e2d65408..ca33f69e 100644 --- a/released/discovery_center/mission_4024/outputs.tf +++ b/released/discovery_center/mission_4024/outputs.tf @@ -6,4 +6,4 @@ output "subaccount_id" { output "sap_build_apps_subscription_url" { value = btp_subaccount_subscription.sap-build-apps_standard.subscription_url description = "SAP Build Apps subscription URL." -} \ No newline at end of file +}