diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/README.md b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/README.md index b70e6840..7fca23fb 100644 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/README.md +++ b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/README.md @@ -1,6 +1,6 @@ # SITBLR DECEMBER 2024 - HandsOn SAP Terraform Provider for SAP BTP -## Goal of this HandsOn 🎯 +## Goal of this Hands-on 🎯 In this hands-on exercise you will learn how to use the [Terraform Provider for SAP BTP](https://registry.terraform.io/providers/SAP/btp/latest/docs) to provision and manage resources in SAP BTP. The level of the exercises is beginner. You don't need any prior knowledge about Terraform or the Terraform Provider for SAP BTP. We will guide you through the exercises step by step. 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 19c21979..e511d940 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 @@ -34,10 +34,11 @@ terraform { provider "btp" { globalaccount = var.globalaccount + idp = var.idp } ``` -What have we done? First we defined which provider we want to use and which version of the provider we want to use. In this case we want to use the provider `sap/btp` in version `1.8.0` (including potential patch versions). Then we defined the provider configuration. In this case we only need to provide the `globalaccount` parameter where we reference a variable. We will define this variable in the next step. +What have we done? First we defined which provider we want to use and which version of the provider we want to use. In this case we want to use the provider `sap/btp` in version `1.8.0` (including potential patch versions). Then we defined the provider configuration. In this case we need to provide the `globalaccount` and `idp` parameters where we reference a variable. We will define this variable in the next step. > [!NOTE] > We do not need any authentication information in this file. We provided the authentication information via environment variables. @@ -49,18 +50,26 @@ variable "globalaccount" { type = string description = "The subdomain of the SAP BTP global account." } +variable "idp" { + type = string + description = "Orgin key of Identity Provider" + default = null +} ``` -We have now defined the variable `globalaccount` which is required for the provider configuration. We will provide the value for this variable via the `terraform.tfvars` file. Open +We have now defined the variable `globalaccount` and `idp` which is required for the provider configuration. We will provide the value for this variable via the `terraform.tfvars` file. Open the file `terraform.tfvars` and add the following content: ```terraform 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` + > [!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/EXERCISE2/README.md b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE2/README.md index 6a56eaf2..024f92ea 100644 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE2/README.md +++ b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE2/README.md @@ -112,6 +112,13 @@ As we have all variables in place, you should save the changes now. > [!NOTE] > As you can see you have a lot of possibilities to validate the user input in Terraform in this way ensure that the input is correct and meets your corporate requirements. +We have defined the `project_name` which is required for the subaccount creation. We will provide the value for this variable via the `terraform.tfvars` file. Open +the file `terraform.tfvars` and append the following content to the end of the file: + +```terraform +project_name = "" +``` + ### Step 2: Local values Now we want to leverage the input variables to create a subaccount name that follows a specific naming convention. Here are the conditions: 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 88c4260f..143b3179 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 @@ -36,7 +36,7 @@ variable "bas_plan" { } ``` -We define a complex variable type, which is a [list](https://developer.hashicorp.com/terraform/language/expressions/types#lists-tuples) of [objects](https://developer.hashicorp.com/terraform/language/expressions/types#maps-objects). Each object has three attributes: `name`, `plan`, and `amount`. The `name` and `plan` attributes are strings, and the `amount` attribute is a number. We define a default value for the variable, which is an empty list.We will provide values for this parameter via the file `terraform.tfvars` in the next step. Save the changes. +We define a complex variable type, which is a [list](https://developer.hashicorp.com/terraform/language/expressions/types#lists-tuples) of [objects](https://developer.hashicorp.com/terraform/language/expressions/types#maps-objects). Each object has three attributes: `name` and `plan`. The `name` and `plan` attributes are strings. We define a default value for the variable, which is an empty list.We will provide values for this parameter via the file `terraform.tfvars` in the next step. Save the changes. ## Step 2: Add the variable to the tfvars 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 aab081c5..6fea0832 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 @@ -24,6 +24,11 @@ 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" +} ``` Then add the following code to the `main.tf` @@ -35,7 +40,7 @@ resource "btp_subaccount_environment_instance" "cloudfoundry" { 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 }) @@ -46,8 +51,15 @@ 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. -### Step 2: Adjust the output variables +```terraform +cf_plan = "trial" +``` +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: @@ -57,7 +69,7 @@ output "cloudfoundry_org_name" { description = "The name of the cloudfoundry org connected to the project account." } ``` -### Step 3: Apply the changes +### Step 4: Apply the changes 1. Plan the Terraform configuration to see what will be created: @@ -76,6 +88,13 @@ output "cloudfoundry_org_name" { ``` You will be prompted to confirm the creation of the environment. Type `yes` and press `Enter` to continue. + The output should look like this: + + executing terraform apply with cloud foundry provider + + You can also check that everything is in place via the SAP BTP cockpit. You should see the Cloud Foundry environment in the subaccount: + + SAP BTP Cockpit with Cloud Foundry environment ## Summary You've now successfully created a Cloud Foundry environment instance as well as a Cloud Foundry space in SAP BTP. diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/README.md b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/README.md index 34b1ad9a..b29a71f6 100644 --- a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/README.md +++ b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/README.md @@ -4,29 +4,6 @@ In this exercise you will learn how to use the [Terraform Provider for CloudFoundry](https://registry.terraform.io/providers/cloudfoundry/cloudfoundry/latest/docs) and create a space. -### Step 3: Adjust the provider configuration - -As we are using an additional provider we must make Terraform aware of this in the `provider.tf` file. Open the `provider.tf` file and add the following code to the `required_provider` block: - -```terraform -cloudfoundry = { - source = "cloudfoundry/cloudfoundry" - version = "1.1.0" - } -``` - -To configure the Cloud Foundry provider add the following lines at the end of the file: - -```terraform -provider "cloudfoundry" { - api_url = "https://api.cf.${var.region}-001.hana.ondemand.com" -} -``` -Save your changes. - -> [!WARNING] -> We assume that the Cloud Foundry environment is deployed to the extension landscape 001. If this is not the case the authentication might fail. In a real-world scenario you would probably have a different boundary of content to the module. - To fulfill all requirements for the authentication against the Cloud Foundry environment you must export the following environment variables: - Windows: @@ -43,57 +20,39 @@ To fulfill all requirements for the authentication against the Cloud Foundry env export CF_PASSWORD='' ``` -> [!NOTE] -> Although we do not use the Cloud Foundry part of the module namely the assignment of users to the organization, Terraform will initialize the Cloud Foundry provider and try to authenticate against the Cloud Foundry environment. This is why we need to define the configuration and provide the credentials. -### Step 3: Apply the changes +### Step 1: Adjust the provider configuration -As we have a new provider in place, we need to re-initialize the setup to download the required provider and module. Run the following command: +As we are using an additional provider we must make Terraform aware of this in the `provider.tf` file. Open the `provider.tf` file and add the following code to the `required_provider` block: -```bash -terraform init +```terraform +cloudfoundry = { + source = "cloudfoundry/cloudfoundry" + version = "1.1.0" + } ``` -The output should look like this: - -executing terraform init with cloud foundry provider - -> [!NOTE] -> There is also a command parameter called `--upgrade` for the `terraform init` command. This parameter will *upgrade* the provider to the latest version. As we are adding new providers, we do not need to use this parameter. - -You know the drill by now: - -1. Plan the Terraform configuration to see what will be created: - - ```bash - terraform plan - ``` - - The output should look like this: - - executing terraform plan with cloud foundry - -2. Apply the Terraform configuration to create the environment: - - ```bash - terraform apply - ``` - - You will be prompted to confirm the creation of the environment. Type `yes` and press `Enter` to continue. +To configure the Cloud Foundry provider add the following lines at the end of the file: -The result should look like this: +```terraform +provider "cloudfoundry" { + api_url = "https://api.cf.${var.region}-001.hana.ondemand.com" + origin = var.idp +} +``` +Save your changes after editing the file. +The `origin` (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-cloud-foundry-environment-using-cloud-foundry-command-line-interface) is used to login to SAP BTP CloudFoundry Environment, this value is set to Orgin Key of the Custom Identity Provider. The `api_url ` is the API URL of SAP BTP CloudFoundry Environment. -executing terraform apply with cloud foundry provider -You can also check that everything is in place via the SAP BTP cockpit. You should see the Cloud Foundry environment in the subaccount: +> [!WARNING] +> We assume that the Cloud Foundry environment is deployed to the extension landscape 001. If this is not the case the authentication might fail. In a real-world scenario you would probably have a different boundary of content to the module. - SAP BTP Cockpit with Cloud Foundry environment -## Creation of a Cloud Foundry space +> [!NOTE] +> Although we do not use the Cloud Foundry part of the module namely the assignment of users to the organization, Terraform will initialize the Cloud Foundry provider and try to authenticate against the Cloud Foundry environment. This is why we need to define the configuration and provide the credentials. -As a last task we also want to add a Cloud Foundry space to the Cloud Foundry environment. -### Step 1: Add the variable to the configuration for Space creation +### Step 2: Add the variable to the configuration for Space creation First we need to add more variable in the `variables.tf` file. Open the `variables.tf` file and add the following code: @@ -131,7 +90,7 @@ variable "cf_space_auditors" { This allows us to specify the name of the Cloud Foundry space. We also define a default value (`dev`) for the variable. Save the changes. -### Step 2: Cloudfoundry Space Creation and Role Assignments +### Step 3: Cloudfoundry Space Creation and Role Assignments To trigger the creation of a Cloud Foundry space and space roles, Open the `main.tf` file and add the following code: @@ -173,7 +132,7 @@ resource "cloudfoundry_space_role" "cf_space_auditors" { } ``` -### Step 3: Add the variables to tfvar file +### Step 4: Add the variables to tfvar file Now we can add `space developers` and `space managers` to the space we created, Add following variables to your `tfvars` file. @@ -183,11 +142,16 @@ cf_space_developers = ["john.doe@test.com"] ``` Save the changes. -### Step 4: Apply the changes - +### Step 5: Apply the changes As we have all prerequisites already in place when it comes to provider configuration and authentication, we can proceed with applying the changes. -1. Plan the Terraform configuration to see what will be created: +1. As we have a new provider in place, we need to re-initialize the setup to download the required provider and module. Run the following command: + + ```bash + terraform init + ``` + +2. Plan the Terraform configuration to see what will be created: ```bash terraform plan @@ -195,9 +159,9 @@ As we have all prerequisites already in place when it comes to provider configur The output should look like this: - executing terraform plan for cloud foundry space creation + executing terraform plan for cloud foundry space creation -2. Apply the Terraform configuration to create the space: +3. Apply the Terraform configuration to create the space: ```bash terraform apply diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/assets/ex7_1.png b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/assets/ex7_1.png index 053485a3..a6d18688 100644 Binary files a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/assets/ex7_1.png and b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/assets/ex7_1.png differ diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/assets/ex7_2.png b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/assets/ex7_2.png index 40ccd768..ff25213a 100644 Binary files a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/assets/ex7_2.png and b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/assets/ex7_2.png differ diff --git a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/assets/ex7_7.png b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/assets/ex7_7.png index 0bbe96cb..12ffdc11 100644 Binary files a/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/assets/ex7_7.png and b/released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/assets/ex7_7.png differ