diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE1/README.md b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE1/README.md index e511d940..37730944 100644 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE1/README.md +++ b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE1/README.md @@ -65,10 +65,11 @@ globalaccount = "" idp = null ``` + The SAP BTP Global Account Subdomain can be found in the SAP BTP Cockpit as shown below SAP BTP Global Account Subdomain -The `idp` (Identity Provider Orgin Key ) is set to null. If a [Custom Identity Provider](https://help.sap.com/docs/btp/sap-business-technology-platform/log-on-with-custom-identity-provider-to-sap-btp-cockpit) is used to login to SAP BTP this value is set to Orgin Key of the Custom Identity Provider` +The `idp` (Identity Provider Orgin Key ) value is set to null. If a [SAP Cloud Identity Services tenant (Custom Identity Provider)](https://help.sap.com/docs/btp/sap-business-technology-platform/log-on-with-custom-identity-provider-to-sap-btp-cockpit) is used to login to SAP BTP Cockpit this value is set to Orgin Key of the Custom Identity Provider`. The orgin key of the SAP Cloud Identity Services tenant can be found in SAP BTP Cockpit. Go to the Global Account where teh Subaccount is being created. Navigate to Security -> Trust Configuration and the orgin key can be found under the Trust Configuration of the Identity Provider. > [!NOTE] > We are using here a naming convention of Terraform to define the variable values. The file `terraform.tfvars` is used to define the variable values. The file is not checked into the source code repository. This is important to keep sensitive information out of the source code repository. When you run Terraform, it will automatically load the variable values from this file. diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE1/SOLUTION_EX1/main.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE1/SOLUTION_EX1/main.tf deleted file mode 100644 index e69de29b..00000000 diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE1/SOLUTION_EX1/outputs.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE1/SOLUTION_EX1/outputs.tf deleted file mode 100644 index e69de29b..00000000 diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE1/SOLUTION_EX1/provider.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE1/SOLUTION_EX1/provider.tf deleted file mode 100644 index 96cf1596..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE1/SOLUTION_EX1/provider.tf +++ /dev/null @@ -1,16 +0,0 @@ - -terraform { - required_providers { - btp = { - source = "sap/btp" - version = "~> 1.8.0" - } - } - -} - -# Please checkout documentation on how best to authenticate against SAP BTP -# via the Terraform provider for SAP BTP -provider "btp" { - globalaccount = var.globalaccount -} diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE1/SOLUTION_EX1/terraform.tfvars-sample b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE1/SOLUTION_EX1/terraform.tfvars-sample deleted file mode 100644 index c281dae5..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE1/SOLUTION_EX1/terraform.tfvars-sample +++ /dev/null @@ -1 +0,0 @@ -globalaccount = "" diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE1/SOLUTION_EX1/variables.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE1/SOLUTION_EX1/variables.tf deleted file mode 100644 index 4658db07..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE1/SOLUTION_EX1/variables.tf +++ /dev/null @@ -1,7 +0,0 @@ -### -# Provider configuration -### -variable "globalaccount" { - type = string - description = "The subdomain of the SAP BTP global account." -} diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE2/SOLUTION_EX2/main.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE2/SOLUTION_EX2/main.tf deleted file mode 100644 index a80d4665..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE2/SOLUTION_EX2/main.tf +++ /dev/null @@ -1,20 +0,0 @@ -### -# Setup of names in accordance to the company's naming conventions -### -locals { - project_subaccount_name = "${var.org_name} | ${var.project_name}: CF - ${var.stage}" - project_subaccount_domain = lower(replace("${var.org_name}-${var.project_name}-${var.stage}", " ", "-")) -} - -### -# Creation of subaccount -### -resource "btp_subaccount" "project" { - name = local.project_subaccount_name - subdomain = local.project_subaccount_domain - region = lower(var.region) - labels = { - "stage" = ["${var.stage}"], - "costcenter" = ["${var.costcenter}"] - } -} diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE2/SOLUTION_EX2/outputs.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE2/SOLUTION_EX2/outputs.tf deleted file mode 100644 index 9cc0c349..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE2/SOLUTION_EX2/outputs.tf +++ /dev/null @@ -1,9 +0,0 @@ -output "subaccount_id" { - value = btp_subaccount.project.id - description = "The ID of the project subaccount." -} - -output "subaccount_name" { - value = btp_subaccount.project.name - description = "The name of the project subaccount." -} diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE2/SOLUTION_EX2/provider.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE2/SOLUTION_EX2/provider.tf deleted file mode 100644 index 96cf1596..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE2/SOLUTION_EX2/provider.tf +++ /dev/null @@ -1,16 +0,0 @@ - -terraform { - required_providers { - btp = { - source = "sap/btp" - version = "~> 1.8.0" - } - } - -} - -# Please checkout documentation on how best to authenticate against SAP BTP -# via the Terraform provider for SAP BTP -provider "btp" { - globalaccount = var.globalaccount -} diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE2/SOLUTION_EX2/terraform.tfvars-sample b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE2/SOLUTION_EX2/terraform.tfvars-sample deleted file mode 100644 index c281dae5..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE2/SOLUTION_EX2/terraform.tfvars-sample +++ /dev/null @@ -1 +0,0 @@ -globalaccount = "" diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE2/SOLUTION_EX2/variables.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE2/SOLUTION_EX2/variables.tf deleted file mode 100644 index fd3e3a5a..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE2/SOLUTION_EX2/variables.tf +++ /dev/null @@ -1,55 +0,0 @@ -### -# Provider configuration -### -variable "globalaccount" { - type = string - description = "The subdomain of the SAP BTP global account." -} - -variable "region" { - type = string - description = "The region where the project account shall be created in." - default = "us10" -} - -### -# Subaccount setup -### -variable "project_name" { - type = string - description = "The subaccount name." - default = "proj-1234" - - validation { - condition = can(regex("^[a-zA-Z0-9_\\-]{1,200}", var.project_name)) - error_message = "Provide a valid project name." - } -} - -variable "stage" { - type = string - description = "The stage/tier the account will be used for." - default = "DEV" - - validation { - condition = contains(["DEV", "TST", "PRD"], var.stage) - error_message = "Select a valid stage for the project account." - } -} - -variable "costcenter" { - type = string - description = "The cost center the account will be billed to." - default = "1234567890" - - validation { - condition = can(regex("^[0-9]{10}", var.costcenter)) - error_message = "Provide a valid cost center." - } -} - -variable "org_name" { - type = string - description = "Defines to which organisation the project account shall belong to." - default = "B2C" -} diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE3/README.md b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE3/README.md index 143b3179..b5b28888 100644 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE3/README.md +++ b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE3/README.md @@ -40,13 +40,9 @@ We define a complex variable type, which is a [list](https://developer.hashicorp ## Step 2: Add the variable to the tfvars file -Now we need to specify the entitlements we want to create to the `terraform.tfvars` file. +Now we need to specify the entitlements we want to create to the `terraform.tfvars` file. -We want to add the following entitlements to the subaccount: - -- `sapappstudiotrial` application with the `trial` plan - -Open the `terraform.tfvars` file and add the following code: +If you are creating subaccount in **SAP BTP Trial landscape**, open the `terraform.tfvars` file and add the following code: ```terraform bas_service_name = "sapappstudiotrial" @@ -54,6 +50,16 @@ bas_plan = "trial" bas_admins = ["admin1@example.com", "admin2@example.com"] bas_developers = ["dev1@example.com", "dev2@example.com"] ``` +OR + +If you are creating Subaccount in **Live or Production landscapes** such as `EU10`, `US10`, `AP10` etc, open the `terraform.tfvars` file and add the following code: + +```terraform +bas_service_name = "sapappstudio" +bas_plan = "standard-edition" +bas_admins = ["admin1@example.com", "admin2@example.com"] +bas_developers = ["dev1@example.com", "dev2@example.com"] +``` ## Step 3: Add the entitlements configuration diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE3/SOLUTION_EX3/main.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE3/SOLUTION_EX3/main.tf deleted file mode 100644 index ecf25620..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE3/SOLUTION_EX3/main.tf +++ /dev/null @@ -1,55 +0,0 @@ -### -# Setup of names in accordance to the company's naming conventions -### -locals { - project_subaccount_name = "${var.org_name} | ${var.project_name}: CF - ${var.stage}" - project_subaccount_domain = lower(replace("${var.org_name}-${var.project_name}-${var.stage}", " ", "-")) - project_subaccount_cf_org = replace("${var.org_name}_${lower(var.project_name)}-${lower(var.stage)}", " ", "_") -} - -### -# Creation of subaccount -### -resource "btp_subaccount" "project" { - name = local.project_subaccount_name - subdomain = local.project_subaccount_domain - region = lower(var.region) - labels = { - "stage" = ["${var.stage}"], - "costcenter" = ["${var.costcenter}"] - } - usage = "NOT_USED_FOR_PRODUCTION" -} - -### -# Entitlement Subscription and Role Assignment for BAS -### - -resource "btp_subaccount_entitlement" "bas" { - subaccount_id = btp_subaccount.project.id - service_name = var.bas_service_name - plan_name = var.bas_plan -} - -resource "btp_subaccount_subscription" "bas" { - subaccount_id = btp_subaccount.project.id - app_name = var.bas_service_name - plan_name = var.bas_plan - depends_on = [btp_subaccount_entitlement.bas] -} - -resource "btp_subaccount_role_collection_assignment" "bas_admin" { - for_each = toset(var.bas_admins) - subaccount_id = btp_subaccount.project.id - role_collection_name = "Business_Application_Studio_Administrator" - user_name = each.value - depends_on = [btp_subaccount_subscription.bas] -} - -resource "btp_subaccount_role_collection_assignment" "bas_developer" { - for_each = toset(var.bas_developers) - subaccount_id = btp_subaccount.project.id - role_collection_name = "Business_Application_Studio_Developer" - user_name = each.value - depends_on = [btp_subaccount_subscription.bas] -} \ No newline at end of file diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE3/SOLUTION_EX3/outputs.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE3/SOLUTION_EX3/outputs.tf deleted file mode 100644 index 9cc0c349..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE3/SOLUTION_EX3/outputs.tf +++ /dev/null @@ -1,9 +0,0 @@ -output "subaccount_id" { - value = btp_subaccount.project.id - description = "The ID of the project subaccount." -} - -output "subaccount_name" { - value = btp_subaccount.project.name - description = "The name of the project subaccount." -} diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE3/SOLUTION_EX3/provider.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE3/SOLUTION_EX3/provider.tf deleted file mode 100644 index 96cf1596..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE3/SOLUTION_EX3/provider.tf +++ /dev/null @@ -1,16 +0,0 @@ - -terraform { - required_providers { - btp = { - source = "sap/btp" - version = "~> 1.8.0" - } - } - -} - -# Please checkout documentation on how best to authenticate against SAP BTP -# via the Terraform provider for SAP BTP -provider "btp" { - globalaccount = var.globalaccount -} diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE3/SOLUTION_EX3/terraform.tfvars-sample b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE3/SOLUTION_EX3/terraform.tfvars-sample deleted file mode 100644 index 50182288..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE3/SOLUTION_EX3/terraform.tfvars-sample +++ /dev/null @@ -1,5 +0,0 @@ -globalaccount = "" -bas_service_name = "sapappstudiotrial" -bas_plan = "trial" -bas_admins = ["admin1@example.com", "admin2@example.com"] -bas_developers = ["dev1@example.com", "dev2@example.com"] \ No newline at end of file diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE3/SOLUTION_EX3/variables.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE3/SOLUTION_EX3/variables.tf deleted file mode 100644 index 96e06fd2..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE3/SOLUTION_EX3/variables.tf +++ /dev/null @@ -1,91 +0,0 @@ -### -# Provider configuration -### -variable "globalaccount" { - type = string - description = "The subdomain of the SAP BTP global account." -} - -variable "region" { - type = string - description = "The region where the project account shall be created in." - default = "us10" -} - -### -# Subaccount setup -### -variable "project_name" { - type = string - description = "The subaccount name." - default = "proj-1234" - - validation { - condition = can(regex("^[a-zA-Z0-9_\\-]{1,200}", var.project_name)) - error_message = "Provide a valid project name." - } -} - -variable "stage" { - type = string - description = "The stage/tier the account will be used for." - default = "DEV" - - validation { - condition = contains(["DEV", "TST", "PRD"], var.stage) - error_message = "Select a valid stage for the project account." - } -} - -variable "costcenter" { - type = string - description = "The cost center the account will be billed to." - default = "1234567890" - - validation { - condition = can(regex("^[0-9]{10}", var.costcenter)) - error_message = "Provide a valid cost center." - } -} - -variable "org_name" { - type = string - description = "Defines to which organisation the project account shall belong to." - default = "B2C" - - validation { - condition = contains(concat( - // Cross Development - ["B2B", "B2C", "ECOMMERCE"], - // Internal IT - ["PLATFORMDEV", "INTIT"], - // Financial Services - ["FSIT"], - ), var.org_name) - error_message = "Please select a valid org name for the project account." - } -} - -### -# Entitlement for BAS -### -variable "bas_admins" { - type = list(string) - description = "List of users to assign the Administrator role." - -} -variable "bas_developers" { - type = list(string) - description = "List of users to assign the Developer role." -} -variable "bas_service_name" { - type = string - description = "Service name for Business Application Studio." - default = "sapappstudio" - -} -variable "bas_plan" { - type = string - description = "Plan name for Business Application Studio." - default = "standard" -} \ No newline at end of file diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE4/README.md b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE4/README.md index 6fea0832..a608fa81 100644 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE4/README.md +++ b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE4/README.md @@ -53,12 +53,20 @@ resource "btp_subaccount_environment_instance" "cloudfoundry" { ``` ### Step 2: Add the variables to tfvar file -Add following variables to your `tfvars` file to configure the CloudFoundry Plan. +If you are creating subaccount in **SAP BTP Trial landscape**, open the `terraform.tfvars` file and add the following variable: ```terraform cf_plan = "trial" ``` +**OR** + +If you are creating subaccount in **Live or Production landscapes** such as `EU10`, `US10`, `AP10` etc, open the `terraform.tfvars` file and add the following variable: + +```terraform +cf_plan = "standard" +``` Save the changes. + ### Step 3: Adjust the output variables As we are using the output variables, we need to adjust the output variables in the `outputs.tf` file. Open the `outputs.tf` file and add the following code: @@ -99,4 +107,4 @@ output "cloudfoundry_org_name" { You've now successfully created a Cloud Foundry environment instance as well as a Cloud Foundry space in SAP BTP. -Continue to - [Exercise 5 - Create a CloudFoundry Space](../EXERCISE5/README.md). \ No newline at end of file +Continue to - [Exercise 5 - Create a CloudFoundry Space](../EXERCISE5/README.md). diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE4/SOLUTION_EX4/main.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE4/SOLUTION_EX4/main.tf deleted file mode 100644 index 6ba9c133..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE4/SOLUTION_EX4/main.tf +++ /dev/null @@ -1,42 +0,0 @@ -### -# Setup of names in accordance to the company's naming conventions -### -locals { - project_subaccount_name = "${var.org_name} | ${var.project_name}: CF - ${var.stage}" - project_subaccount_domain = lower(replace("${var.org_name}-${var.project_name}-${var.stage}", " ", "-")) - project_subaccount_cf_org = replace("${var.org_name}_${lower(var.project_name)}-${lower(var.stage)}", " ", "_") -} - -### -# Creation of subaccount -### -resource "btp_subaccount" "project" { - name = local.project_subaccount_name - subdomain = local.project_subaccount_domain - region = lower(var.region) - labels = { - "stage" = ["${var.stage}"], - "costcenter" = ["${var.costcenter}"] - } -} - -### -# Creation of Cloud Foundry environment -### -resource "btp_subaccount_environment_instance" "cloudfoundry" { - subaccount_id = btp_subaccount.project.id - name = local.project_subaccount_cf_org - landscape_label = var.cf_landscape_label - environment_type = "cloudfoundry" - service_name = "cloudfoundry" - plan_name = "trial" - parameters = jsonencode({ - instance_name = local.project_subaccount_cf_org - memory = 1024 - }) - timeouts = { - create = "1h" - update = "35m" - delete = "30m" - } -} \ No newline at end of file diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE4/SOLUTION_EX4/outputs.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE4/SOLUTION_EX4/outputs.tf deleted file mode 100644 index 4352f77b..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE4/SOLUTION_EX4/outputs.tf +++ /dev/null @@ -1,14 +0,0 @@ -output "subaccount_id" { - value = btp_subaccount.project.id - description = "The ID of the project subaccount." -} - -output "subaccount_name" { - value = btp_subaccount.project.name - description = "The name of the project subaccount." -} - -output "cloudfoundry_org_name" { - value = local.project_subaccount_cf_org - description = "The name of the cloudfoundry org connected to the project account." -} \ No newline at end of file diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE4/SOLUTION_EX4/provider.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE4/SOLUTION_EX4/provider.tf deleted file mode 100644 index b69795af..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE4/SOLUTION_EX4/provider.tf +++ /dev/null @@ -1,15 +0,0 @@ - -terraform { - required_providers { - btp = { - source = "sap/btp" - version = "~> 1.8.0" - } - } -} - -# Please checkout documentation on how best to authenticate against SAP BTP -# via the Terraform provider for SAP BTP -provider "btp" { - globalaccount = var.globalaccount -} \ No newline at end of file diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE4/SOLUTION_EX4/terraform.tfvars-sample b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE4/SOLUTION_EX4/terraform.tfvars-sample deleted file mode 100644 index f6ef2f0a..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE4/SOLUTION_EX4/terraform.tfvars-sample +++ /dev/null @@ -1,9 +0,0 @@ -globalaccount = "" - -region = "us10" - -costcenter = "" - -bas_plan_name = "trial" -bas_admins = ["john.doe@test.com"] -bas_developers = ["john.doe@test.com"] diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE4/SOLUTION_EX4/variables.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE4/SOLUTION_EX4/variables.tf deleted file mode 100644 index 70bbc5c1..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE4/SOLUTION_EX4/variables.tf +++ /dev/null @@ -1,79 +0,0 @@ -### -# Provider configuration -### -variable "globalaccount" { - type = string - description = "The subdomain of the SAP BTP global account." -} - -variable "region" { - type = string - description = "The region where the project account shall be created in." - default = "us10" -} - -### -# Subaccount setup -### -variable "project_name" { - type = string - description = "The subaccount name." - default = "proj-1234" - - validation { - condition = can(regex("^[a-zA-Z0-9_\\-]{1,200}", var.project_name)) - error_message = "Provide a valid project name." - } -} - -variable "stage" { - type = string - description = "The stage/tier the account will be used for." - default = "DEV" - - validation { - condition = contains(["DEV", "TST", "PRD"], var.stage) - error_message = "Select a valid stage for the project account." - } -} - -variable "costcenter" { - type = string - description = "The cost center the account will be billed to." - default = "1234567890" - - validation { - condition = can(regex("^[0-9]{10}", var.costcenter)) - error_message = "Provide a valid cost center." - } -} - -variable "org_name" { - type = string - description = "Defines to which organisation the project account shall belong to." - default = "B2C" -} - -variable "bas_plan_name" { - description = "BAS plan" - type = string - default = "free" -} - -variable "bas_developers" { - description = "BAS developers" - type = list(string) - default = ["jane.doe@test.com", "john.doe@test.com"] -} - -variable "bas_admins" { - description = "BAS Admininstrators" - type = list(string) - default = ["jane.doe@test.com", "john.doe@test.com"] -} - -variable "cf_landscape_label" { - type = string - description = "The region where the project account shall be created in." - default = "cf-us10-001" -} diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/SOLUTION_EX5/main.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/SOLUTION_EX5/main.tf deleted file mode 100644 index 40270ea8..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/SOLUTION_EX5/main.tf +++ /dev/null @@ -1,95 +0,0 @@ -locals { - project_subaccount_name = "${var.org_name} | ${var.project_name}: CF - ${var.stage}" - project_subaccount_domain = lower(replace("${var.org_name}-${var.project_name}-${var.stage}", " ", "-")) - project_subaccount_cf_org = replace("${var.org_name}_${lower(var.project_name)}-${lower(var.stage)}", " ", "_") -} - -resource "btp_subaccount" "project" { - name = local.project_subaccount_name - subdomain = local.project_subaccount_domain - region = lower(var.region) - labels = { - "stage" = ["${var.stage}"], - "costcenter" = ["${var.costcenter}"] - } -} - -resource "btp_subaccount_entitlement" "bas" { - subaccount_id = btp_subaccount.project.id - service_name = "sapappstudiotrial" - plan_name = var.bas_plan_name -} -resource "btp_subaccount_subscription" "bas-subscribe" { - subaccount_id = btp_subaccount.project.id - app_name = "sapappstudiotrial" - plan_name = var.bas_plan_name - depends_on = [btp_subaccount_entitlement.bas] -} -resource "btp_subaccount_role_collection_assignment" "Business_Application_Studio_Administrator" { - for_each = toset(var.bas_admins) - subaccount_id = btp_subaccount.project.id - role_collection_name = "Business_Application_Studio_Administrator" - user_name = each.value - 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" - for_each = toset(var.bas_developers) - user_name = each.value - depends_on = [btp_subaccount_subscription.bas-subscribe] -} - -resource "btp_subaccount_environment_instance" "cloudfoundry" { - subaccount_id = btp_subaccount.project.id - name = local.project_subaccount_cf_org - landscape_label = var.cf_landscape_label - environment_type = "cloudfoundry" - service_name = "cloudfoundry" - plan_name = "trial" - parameters = jsonencode({ - instance_name = local.project_subaccount_cf_org - }) - timeouts = { - create = "1h" - update = "35m" - delete = "30m" - } -} - -resource "cloudfoundry_org_role" "my_role" { - for_each = var.cf_org_user - username = each.value - type = "organization_user" - org = btp_subaccount_environment_instance.cloudfoundry.platform_id -} - -resource "cloudfoundry_space" "space" { - name = var.cf_space_name - org = btp_subaccount_environment_instance.cloudfoundry.platform_id -} - -resource "cloudfoundry_space_role" "cf_space_managers" { - for_each = toset(var.cf_space_managers) - username = each.value - type = "space_manager" - space = cloudfoundry_space.space.id - depends_on = [cloudfoundry_org_role.my_role] -} - -resource "cloudfoundry_space_role" "cf_space_developers" { - for_each = toset(var.cf_space_developers) - username = each.value - type = "space_developer" - space = cloudfoundry_space.space.id - depends_on = [cloudfoundry_org_role.my_role] -} - -resource "cloudfoundry_space_role" "cf_space_auditors" { - for_each = toset(var.cf_space_auditors) - username = each.value - type = "space_auditor" - space = cloudfoundry_space.space.id - depends_on = [cloudfoundry_org_role.my_role] -} diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/SOLUTION_EX5/outputs.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/SOLUTION_EX5/outputs.tf deleted file mode 100644 index 4352f77b..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/SOLUTION_EX5/outputs.tf +++ /dev/null @@ -1,14 +0,0 @@ -output "subaccount_id" { - value = btp_subaccount.project.id - description = "The ID of the project subaccount." -} - -output "subaccount_name" { - value = btp_subaccount.project.name - description = "The name of the project subaccount." -} - -output "cloudfoundry_org_name" { - value = local.project_subaccount_cf_org - description = "The name of the cloudfoundry org connected to the project account." -} \ No newline at end of file diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/SOLUTION_EX5/provider.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/SOLUTION_EX5/provider.tf deleted file mode 100644 index 021cbfa8..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/SOLUTION_EX5/provider.tf +++ /dev/null @@ -1,21 +0,0 @@ -terraform { - required_providers { - btp = { - source = "sap/btp" - version = "~> 1.8.0" - } - cloudfoundry = { - source = "cloudfoundry/cloudfoundry" - version = "~> 1.1.0" - } - } - -} - -provider "btp" { - globalaccount = var.globalaccount -} - -provider "cloudfoundry" { - api_url = "https://api.cf.${var.region}-001.hana.ondemand.com" -} diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/SOLUTION_EX5/terraform.tfvars-sample b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/SOLUTION_EX5/terraform.tfvars-sample deleted file mode 100644 index ce73a263..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/SOLUTION_EX5/terraform.tfvars-sample +++ /dev/null @@ -1,12 +0,0 @@ -globalaccount = "" - -region = "us10" - - -bas_plan_name = "trial" -bas_admins = ["john.doe@test.com"] -bas_developers = ["john.doe@test.com"] - - -cf_org_user = ["john.doe@test.com"] -cf_space_developers = ["john.doe@test.com"] \ No newline at end of file diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/SOLUTION_EX5/variables.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/SOLUTION_EX5/variables.tf deleted file mode 100644 index 772e3754..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/SOLUTION_EX5/variables.tf +++ /dev/null @@ -1,115 +0,0 @@ -variable "globalaccount" { - type = string - description = "The subdomain of the SAP BTP global account." -} - -variable "region" { - type = string - description = "The region where the project account shall be created in." - default = "us10" -} - -variable "project_name" { - type = string - description = "The subaccount name." - default = "myproj-1234" - - validation { - condition = can(regex("^[a-zA-Z0-9_\\-]{1,200}", var.project_name)) - error_message = "Provide a valid project name." - } -} - -variable "stage" { - type = string - description = "The stage/tier the account will be used for." - default = "DEV" - - validation { - condition = contains(["DEV", "TST", "PRD"], var.stage) - error_message = "Select a valid stage for the project account." - } -} - -variable "costcenter" { - type = string - description = "The cost center the account will be billed to." - default = "1234567890" - - validation { - condition = can(regex("^[0-9]{10}", var.costcenter)) - error_message = "Provide a valid cost center." - } -} - -variable "bas_plan_name" { - description = "BAS plan" - type = string - default = "free" -} - -variable "bas_developers" { - description = "BAS developers" - type = list(string) - default = ["jane.doe@test.com", "john.doe@test.com"] -} - -variable "bas_admins" { - description = "BAS Admininstrators" - type = list(string) - default = ["jane.doe@test.com", "john.doe@test.com"] -} - -variable "org_name" { - type = string - description = "Defines to which organisation the project account shall belong to." - default = "B2C" -} - -variable "cf_space_name" { - type = string - description = "The name of the Cloud Foundry space." - default = "dev" -} - -variable "cf_landscape_label" { - type = string - description = "The region where the project account shall be created in." - default = "cf-us10-001" -} - -variable "cf_org_name" { - type = string - description = "The name for the Cloud Foundry Org." - default = "" -} - -variable "cf_org_user" { - type = set(string) - description = "Defines the colleagues who are added to each subaccount as subaccount administrators." - default = ["jane.doe@test.com", "john.doe@test.com"] -} - -variable "name" { - type = string - description = "The name of the Cloud Foundry space." - default = "dev" -} - -variable "cf_space_managers" { - type = list(string) - description = "The list of Cloud Foundry space managers." - default = [] -} - -variable "cf_space_developers" { - type = list(string) - description = "The list of Cloud Foundry space developers." - default = [] -} - -variable "cf_space_auditors" { - type = list(string) - description = "The list of Cloud Foundry space auditors." - default = [] -} diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/main.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/main.tf index 4dd46ca6..5900bff3 100644 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/main.tf +++ b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/main.tf @@ -3,7 +3,6 @@ locals { project_subaccount_domain = lower(replace("${var.org_name}-${var.project_name}-${var.stage}", " ", "")) project_subaccount_cf_org = replace("${var.org_name}_${lower(var.project_name)}-${lower(var.stage)}", " ", "_") } - resource "btp_subaccount" "project" { name = local.project_subaccount_name subdomain = local.project_subaccount_domain @@ -13,48 +12,41 @@ resource "btp_subaccount" "project" { "costcenter" = ["${var.costcenter}"] } } - -resource "btp_subaccount_role_collection_assignment" "subaccount_users" { - for_each = toset(var.emergency_admins) - subaccount_id = btp_subaccount.project.id - role_collection_name = "Subaccount Administrator" - user_name = each.value -} - resource "btp_subaccount_entitlement" "bas" { subaccount_id = btp_subaccount.project.id - service_name = "sapappstudiotrial" - plan_name = var.bas_plan_name + service_name = var.bas_service_name + plan_name = var.bas_plan } -resource "btp_subaccount_subscription" "bas-subscribe" { + +resource "btp_subaccount_subscription" "bas" { subaccount_id = btp_subaccount.project.id - app_name = "sapappstudiotrial" - plan_name = var.bas_plan_name + app_name = var.bas_service_name + plan_name = var.bas_plan depends_on = [btp_subaccount_entitlement.bas] } -resource "btp_subaccount_role_collection_assignment" "Business_Application_Studio_Administrator" { + +resource "btp_subaccount_role_collection_assignment" "bas_admin" { for_each = toset(var.bas_admins) subaccount_id = btp_subaccount.project.id role_collection_name = "Business_Application_Studio_Administrator" user_name = each.value - depends_on = [btp_subaccount_subscription.bas-subscribe] + depends_on = [btp_subaccount_subscription.bas] } -resource "btp_subaccount_role_collection_assignment" "Business_Application_Studio_Developer" { +resource "btp_subaccount_role_collection_assignment" "bas_developer" { + for_each = toset(var.bas_developers) subaccount_id = btp_subaccount.project.id role_collection_name = "Business_Application_Studio_Developer" - for_each = toset(var.bas_developers) user_name = each.value - depends_on = [btp_subaccount_subscription.bas-subscribe] + depends_on = [btp_subaccount_subscription.bas] } - resource "btp_subaccount_environment_instance" "cloudfoundry" { subaccount_id = btp_subaccount.project.id name = local.project_subaccount_cf_org landscape_label = var.cf_landscape_label environment_type = "cloudfoundry" service_name = "cloudfoundry" - plan_name = "trial" + plan_name = var.cf_plan parameters = jsonencode({ instance_name = local.project_subaccount_cf_org }) @@ -64,7 +56,6 @@ resource "btp_subaccount_environment_instance" "cloudfoundry" { delete = "30m" } } - resource "cloudfoundry_org_role" "my_role" { for_each = var.cf_org_user username = each.value @@ -99,4 +90,4 @@ resource "cloudfoundry_space_role" "cf_space_auditors" { type = "space_auditor" space = cloudfoundry_space.space.id depends_on = [cloudfoundry_org_role.my_role] -} +} \ No newline at end of file diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/outputs.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/outputs.tf index 77ccfb21..ec3e393c 100644 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/outputs.tf +++ b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/outputs.tf @@ -7,7 +7,6 @@ output "subaccount_name" { value = btp_subaccount.project.name description = "The name of the project subaccount." } - output "cloudfoundry_org_name" { value = local.project_subaccount_cf_org description = "The name of the cloudfoundry org connected to the project account." diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/provider.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/provider.tf index 021cbfa8..f4b7151a 100644 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/provider.tf +++ b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/provider.tf @@ -9,13 +9,13 @@ terraform { version = "~> 1.1.0" } } - } provider "btp" { globalaccount = var.globalaccount + idp = var.idp } - provider "cloudfoundry" { api_url = "https://api.cf.${var.region}-001.hana.ondemand.com" -} + origin = var.idp +} \ No newline at end of file diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/terraform-live.tfvars-sample b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/terraform-live.tfvars-sample new file mode 100644 index 00000000..0ff4e264 --- /dev/null +++ b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/terraform-live.tfvars-sample @@ -0,0 +1,12 @@ +globalaccount = "" +idp = null +project_name = "" + +bas_service_name = "sapappstudio" +bas_plan = "standard-edition" +bas_admins = ["admin1@example.com", "admin2@example.com"] +bas_developers = ["dev1@example.com", "dev2@example.com"] + +cf_plan = "standard" +cf_org_user = ["john.doe@test.com"] +cf_space_developers = ["john.doe@test.com"] \ No newline at end of file diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/terraform-trial.tfvars-sample b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/terraform-trial.tfvars-sample new file mode 100644 index 00000000..ca95f80a --- /dev/null +++ b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/terraform-trial.tfvars-sample @@ -0,0 +1,12 @@ +globalaccount = "" +idp = null +project_name = "" + +bas_service_name = "sapappstudiotrial" +bas_plan = "trial" +bas_admins = ["admin1@example.com", "admin2@example.com"] +bas_developers = ["dev1@example.com", "dev2@example.com"] + +cf_plan = "trial" +cf_org_user = ["john.doe@test.com"] +cf_space_developers = ["john.doe@test.com"] \ No newline at end of file diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/terraform.tfvars-sample b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/terraform.tfvars-sample deleted file mode 100644 index f57506dc..00000000 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/terraform.tfvars-sample +++ /dev/null @@ -1,8 +0,0 @@ -globalaccount = "" - -bas_plan_name = "trial" -bas_admins = ["john.doe@test.com"] -bas_developers = ["john.doe@test.com"] - -cf_org_user = ["john.doe@test.com"] -cf_space_developers = ["john.doe@test.com"] \ No newline at end of file diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/variables.tf b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/variables.tf index 981185de..473037bd 100644 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/variables.tf +++ b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/solution/variables.tf @@ -3,23 +3,26 @@ variable "globalaccount" { description = "The subdomain of the SAP BTP global account." } +variable "idp" { + type = string + description = "Orgin key of Identity Provider" + default = null +} variable "region" { type = string description = "The region where the project account shall be created in." default = "us10" } - variable "project_name" { type = string description = "The subaccount name." - default = "myproj-1234" + default = "proj-1234" validation { condition = can(regex("^[a-zA-Z0-9_\\-]{1,200}", var.project_name)) error_message = "Provide a valid project name." } } - variable "stage" { type = string description = "The stage/tier the account will be used for." @@ -30,7 +33,6 @@ variable "stage" { error_message = "Select a valid stage for the project account." } } - variable "costcenter" { type = string description = "The cost center the account will be billed to." @@ -41,41 +43,30 @@ variable "costcenter" { error_message = "Provide a valid cost center." } } - -variable "bas_plan_name" { - description = "BAS plan" +variable "org_name" { type = string - default = "free" -} - -variable "bas_developers" { - description = "BAS developers" - type = list(string) - default = ["jane.doe@test.com", "john.doe@test.com"] + description = "Defines to which organization the project account shall belong to." + default = "B2C" } - variable "bas_admins" { - description = "BAS Admininstrators" type = list(string) - default = ["jane.doe@test.com", "john.doe@test.com"] -} + description = "List of users to assign the Administrator role." -variable "org_name" { - type = string - description = "Defines to which organisation the project account shall belong to." - default = "B2C" } - -variable "emergency_admins" { +variable "bas_developers" { type = list(string) - description = "Defines the colleagues who are added to each subaccount as emergency administrators." - default = ["jane.doe@test.com", "john.doe@test.com"] + description = "List of users to assign the Developer role." } +variable "bas_service_name" { + type = string + description = "Service name for Business Application Studio." + default = "sapappstudio" -variable "cf_space_name" { +} +variable "bas_plan" { type = string - description = "The name of the Cloud Foundry space." - default = "dev" + description = "Plan name for Business Application Studio." + default = "standard-edition" } variable "cf_landscape_label" { @@ -83,6 +74,16 @@ variable "cf_landscape_label" { description = "The region where the project account shall be created in." default = "cf-us10-001" } +variable "cf_plan" { + type = string + description = "Plan name for Cloud Foundry Runtime." + default = "standard" +} +variable "cf_space_name" { + type = string + description = "The name of the Cloud Foundry space." + default = "dev" +} variable "cf_org_user" { type = set(string)