Skip to content

Commit 8d8cb63

Browse files
authored
update readme for SIT hands-on (#368)
* update readme * update readme
1 parent c0702fb commit 8d8cb63

File tree

9 files changed

+75
-76
lines changed

9 files changed

+75
-76
lines changed

released/SAP-Inside-Tracks/SITBLR_DEC_2024/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SITBLR DECEMBER 2024 - HandsOn SAP Terraform Provider for SAP BTP
22

3-
## Goal of this HandsOn 🎯
3+
## Goal of this Hands-on 🎯
44

55
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.
66

released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE1/README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ terraform {
3434
3535
provider "btp" {
3636
globalaccount = var.globalaccount
37+
idp = var.idp
3738
}
3839
```
3940

40-
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.
41+
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.
4142

4243
> [!NOTE]
4344
> We do not need any authentication information in this file. We provided the authentication information via environment variables.
@@ -49,18 +50,26 @@ variable "globalaccount" {
4950
type = string
5051
description = "The subdomain of the SAP BTP global account."
5152
}
53+
variable "idp" {
54+
type = string
55+
description = "Orgin key of Identity Provider"
56+
default = null
57+
}
5258
```
5359

54-
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
60+
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
5561
the file `terraform.tfvars` and add the following content:
5662

5763
```terraform
5864
globalaccount = "<YOUR GLOBAL ACCOUNT SUBDOMAIN>"
65+
idp = null
5966
```
6067

6168
The SAP BTP Global Account Subdomain can be found in the SAP BTP Cockpit as shown below
6269
<img width="600px" src="assets/trial-account.png" alt="SAP BTP Global Account Subdomain">
6370

71+
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`
72+
6473
> [!NOTE]
6574
> 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.
6675

released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE2/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ As we have all variables in place, you should save the changes now.
112112
> [!NOTE]
113113
> 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.
114114
115+
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
116+
the file `terraform.tfvars` and append the following content to the end of the file:
117+
118+
```terraform
119+
project_name = "<YOUR LAST NAME>"
120+
```
121+
115122
### Step 2: Local values
116123

117124
Now we want to leverage the input variables to create a subaccount name that follows a specific naming convention. Here are the conditions:

released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE3/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ variable "bas_plan" {
3636
}
3737
```
3838

39-
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.
39+
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.
4040

4141
## Step 2: Add the variable to the tfvars file
4242

released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE4/README.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ variable "cf_landscape_label" {
2424
description = "The region where the project account shall be created in."
2525
default = "cf-us10-001"
2626
}
27+
variable "cf_plan" {
28+
type = string
29+
description = "Plan name for Cloud Foundry Runtime."
30+
default = "standard"
31+
}
2732
```
2833

2934
Then add the following code to the `main.tf`
@@ -35,7 +40,7 @@ resource "btp_subaccount_environment_instance" "cloudfoundry" {
3540
landscape_label = var.cf_landscape_label
3641
environment_type = "cloudfoundry"
3742
service_name = "cloudfoundry"
38-
plan_name = "trial"
43+
plan_name = var.cf_plan
3944
parameters = jsonencode({
4045
instance_name = local.project_subaccount_cf_org
4146
})
@@ -46,8 +51,15 @@ resource "btp_subaccount_environment_instance" "cloudfoundry" {
4651
}
4752
}
4853
```
54+
### Step 2: Add the variables to tfvar file
55+
56+
Add following variables to your `tfvars` file to configure the CloudFoundry Plan.
4957

50-
### Step 2: Adjust the output variables
58+
```terraform
59+
cf_plan = "trial"
60+
```
61+
Save the changes.
62+
### Step 3: Adjust the output variables
5163

5264
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:
5365

@@ -57,7 +69,7 @@ output "cloudfoundry_org_name" {
5769
description = "The name of the cloudfoundry org connected to the project account."
5870
}
5971
```
60-
### Step 3: Apply the changes
72+
### Step 4: Apply the changes
6173

6274
1. Plan the Terraform configuration to see what will be created:
6375

@@ -76,6 +88,13 @@ output "cloudfoundry_org_name" {
7688
```
7789

7890
You will be prompted to confirm the creation of the environment. Type `yes` and press `Enter` to continue.
91+
The output should look like this:
92+
93+
<img width="600px" src="assets/ex7_3.png" alt="executing terraform apply with cloud foundry provider">
94+
95+
You can also check that everything is in place via the SAP BTP cockpit. You should see the Cloud Foundry environment in the subaccount:
96+
97+
<img width="600px" src="assets/ex7_4.png" alt="SAP BTP Cockpit with Cloud Foundry environment">
7998
## Summary
8099

81100
You've now successfully created a Cloud Foundry environment instance as well as a Cloud Foundry space in SAP BTP.

released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/README.md

Lines changed: 33 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,6 @@
44

55
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.
66

7-
### Step 3: Adjust the provider configuration
8-
9-
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:
10-
11-
```terraform
12-
cloudfoundry = {
13-
source = "cloudfoundry/cloudfoundry"
14-
version = "1.1.0"
15-
}
16-
```
17-
18-
To configure the Cloud Foundry provider add the following lines at the end of the file:
19-
20-
```terraform
21-
provider "cloudfoundry" {
22-
api_url = "https://api.cf.${var.region}-001.hana.ondemand.com"
23-
}
24-
```
25-
Save your changes.
26-
27-
> [!WARNING]
28-
> 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.
29-
307
To fulfill all requirements for the authentication against the Cloud Foundry environment you must export the following environment variables:
318

329
- Windows:
@@ -43,57 +20,39 @@ To fulfill all requirements for the authentication against the Cloud Foundry env
4320
export CF_PASSWORD='<your SAP BTP password>'
4421
```
4522
46-
> [!NOTE]
47-
> 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.
4823
49-
### Step 3: Apply the changes
24+
### Step 1: Adjust the provider configuration
5025
51-
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:
26+
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:
5227
53-
```bash
54-
terraform init
28+
```terraform
29+
cloudfoundry = {
30+
source = "cloudfoundry/cloudfoundry"
31+
version = "1.1.0"
32+
}
5533
```
5634

57-
The output should look like this:
58-
59-
<img width="600px" src="assets/ex7_1.png" alt="executing terraform init with cloud foundry provider">
60-
61-
> [!NOTE]
62-
> 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.
63-
64-
You know the drill by now:
65-
66-
1. Plan the Terraform configuration to see what will be created:
67-
68-
```bash
69-
terraform plan
70-
```
71-
72-
The output should look like this:
73-
74-
<img width="600px" src="assets/ex7_2.png" alt="executing terraform plan with cloud foundry">
75-
76-
2. Apply the Terraform configuration to create the environment:
77-
78-
```bash
79-
terraform apply
80-
```
81-
82-
You will be prompted to confirm the creation of the environment. Type `yes` and press `Enter` to continue.
35+
To configure the Cloud Foundry provider add the following lines at the end of the file:
8336

84-
The result should look like this:
37+
```terraform
38+
provider "cloudfoundry" {
39+
api_url = "https://api.cf.${var.region}-001.hana.ondemand.com"
40+
origin = var.idp
41+
}
42+
```
43+
Save your changes after editing the file.
44+
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.
8545

86-
<img width="600px" src="assets/ex7_3.png" alt="executing terraform apply with cloud foundry provider">
8746

88-
You can also check that everything is in place via the SAP BTP cockpit. You should see the Cloud Foundry environment in the subaccount:
47+
> [!WARNING]
48+
> 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.
8949
90-
<img width="600px" src="assets/ex7_4.png" alt="SAP BTP Cockpit with Cloud Foundry environment">
9150

92-
## Creation of a Cloud Foundry space
51+
> [!NOTE]
52+
> 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.
9353
94-
As a last task we also want to add a Cloud Foundry space to the Cloud Foundry environment.
9554

96-
### Step 1: Add the variable to the configuration for Space creation
55+
### Step 2: Add the variable to the configuration for Space creation
9756

9857
First we need to add more variable in the `variables.tf` file. Open the `variables.tf` file and add the following code:
9958

@@ -131,7 +90,7 @@ variable "cf_space_auditors" {
13190

13291
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.
13392

134-
### Step 2: Cloudfoundry Space Creation and Role Assignments
93+
### Step 3: Cloudfoundry Space Creation and Role Assignments
13594

13695
To trigger the creation of a Cloud Foundry space and space roles, Open the `main.tf` file and add the following code:
13796

@@ -173,7 +132,7 @@ resource "cloudfoundry_space_role" "cf_space_auditors" {
173132
}
174133
```
175134

176-
### Step 3: Add the variables to tfvar file
135+
### Step 4: Add the variables to tfvar file
177136

178137
Now we can add `space developers` and `space managers` to the space we created, Add following variables to your `tfvars` file.
179138

@@ -183,21 +142,26 @@ cf_space_developers = ["[email protected]"]
183142
```
184143
Save the changes.
185144

186-
### Step 4: Apply the changes
187-
145+
### Step 5: Apply the changes
188146
As we have all prerequisites already in place when it comes to provider configuration and authentication, we can proceed with applying the changes.
189147

190-
1. Plan the Terraform configuration to see what will be created:
148+
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:
149+
150+
```bash
151+
terraform init
152+
```
153+
154+
2. Plan the Terraform configuration to see what will be created:
191155

192156
```bash
193157
terraform plan
194158
```
195159

196160
The output should look like this:
197161

198-
<img width="600px" src="assets/ex7_6.png" alt="executing terraform plan for cloud foundry space creation">
162+
<img width="600px" src="assets/ex7_2.png" alt="executing terraform plan for cloud foundry space creation">
199163

200-
2. Apply the Terraform configuration to create the space:
164+
3. Apply the Terraform configuration to create the space:
201165

202166
```bash
203167
terraform apply
-530 KB
Loading
-180 KB
Loading
-447 KB
Loading

0 commit comments

Comments
 (0)