Skip to content

Commit 70c9b6a

Browse files
prajin-opCHERIANS
andauthored
feat: SIT BLR handson exercises (#365)
* feat: Update SIT BLR handson * chore: update for SIT * chore: update SIT scripts * chore: update cf steps * feat: Update SIT BLR handson * chore: fixes validation issues * fix typos and update images * update sample * refactor chapters * chore: update exercises for SIT * fixes: removed amount field from script --------- Co-authored-by: Stephen Cherian <[email protected]>
1 parent ddc61f3 commit 70c9b6a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1984
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# SITBLR DECEMBER 2024 - HandsOn SAP Terraform Provider for SAP BTP
2+
3+
## Goal of this HandsOn 🎯
4+
5+
In this HandsOn you will learn how to use the [Terraform Provider for SAP BTP](https://registry.terraform.io/providers/SAP/cp/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.
6+
7+
## Prerequisites 📝
8+
9+
Make sure that the following prerequisites are met:
10+
11+
- You have an SAP BTP Trial Account. If you don't have one yet, you can get one [here](https://developers.sap.com/tutorials/hcp-create-trial-account.html).
12+
- Make sure that your SAP Universal ID is configured correctly. You can find the instructions in [SAP Note 3085908](https://me.sap.com/notes/3085908).
13+
- The Terraform provider does not support SSO or 2FA. Make sure that these options are not enforced for your account.
14+
15+
16+
## Tools 🛠️
17+
18+
To execute the exercises you have the following options concerning the required tools installed:
19+
20+
In general you must clone this GitHub repository. You must have the Git client installed on your machine. You can find the installation instructions [here](https://git-scm.com/downloads).
21+
22+
You can then clone the repository via the following command:
23+
24+
```bash
25+
git clone https://github.com/SAP-samples/btp-terraform-samples.git
26+
```
27+
28+
you find the exercises in the folder `released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises`.
29+
30+
31+
You can install the required tools locally on your machine. The following tools are required:
32+
33+
- [Terraform CLI](https://developer.hashicorp.com/terraform/install?product_intent=terraform)
34+
- An editor of your choice. We recommend [Visual Studio Code](https://code.visualstudio.com/Download) with the [Terraform extension](https://marketplace.visualstudio.com/items?itemName=HashiCorp.terraform).
35+
36+
37+
## Exporting environment variables
38+
39+
The last step in the setup is the export of the environment variables that are required to authenticate against the Terraform provider for SAP BTP. Fo that export the following environment variables:
40+
41+
- Windows:
42+
43+
```pwsh
44+
$env:BTP_USERNAME=<your SAP BTP username>
45+
$env:BTP_PASSWORD='<your SAP BTP password>'
46+
```
47+
48+
- Linux/MacOS/GitHub Codespaces:
49+
50+
```bash
51+
export BTP_USERNAME=<your SAP BTP username>
52+
export BTP_PASSWORD='<your SAP BTP password>'
53+
```
54+
55+
Validate that the values are set via:
56+
57+
- Windows: `$env:BTP_USERNAME` and `$env:BTP_PASSWORD`
58+
- Linux/MacOS/GitHub Codeapses: `echo $BTP_USERNAME` and `echo $BTP_PASSWORD`
59+
60+
61+
## Summary
62+
63+
You've now prepared your development environment and have all information to finally start using Terraform provider for SAP BTP.
64+
65+
66+
67+
## Exercises 📚
68+
69+
In this HandsOn we want to make you familiar with the Terraform Provider for SAP BTP. We will use the provider to provision and manage resources in SAP BTP. To achieve this we will walk through the following steps:
70+
71+
1. [Exercise 1 - Configure the Terraform Provider for SAP BTP](exercises/EXERCISE1/README.md)
72+
1. [Exercise 2 - Setup of a subaccount](exercises/EXERCISE2/README.md)
73+
1. [Exercise 3 - Assign entitlement,Subscription and its role assignments to a subaccount](exercises/EXERCISE3/README.md)
74+
1. [Exercise 4 - Setup a Cloud Foundry environment](exercises/EXERCISE4/README.md)
75+
1. [Exercise 5 - Create a CloudFoundry Space](exercises/EXERCISE5/README.md)
76+
1. [Exercise 6 - Cleanup](exercises/EXERCISE6/README.md)
77+
78+
79+
80+
34.4 KB
Loading
126 KB
Loading
30.7 KB
Loading
13 KB
Loading
55.9 KB
Loading
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Exercise 1 - Configure the Terraform Provider for SAP BTP
2+
3+
## Goal of this Exercise 🎯
4+
5+
The goal of this exercise is to configure the Terraform provider for SAP BTP. In addition we will create a basic setup of the file structure to implement the Terraform configuration.
6+
7+
## Step 1: Create a new directory
8+
9+
To make use of Terraform you must create several configuration files using the [Terraform configuration language](https://developer.hashicorp.com/terraform/language). Create a new directory named `my-tf-handson` under the folder `SITBLR2024`.
10+
11+
Terraform expects a specific file layout for its configurations. Create the following empty files in the directory `my-tf-handson`:
12+
13+
- `main.tf` - this file will contain the main configuration of the Terraform setup
14+
- `provider.tf` - this file will contain the provider configuration
15+
- `variables.tf` - this file will contain the variables to be used in the Terraform configuration
16+
- `outputs.tf` - this file will contain the outputs of the Terraform configuration
17+
- `terraform.tfvars` - this file will contain your specific variable values
18+
19+
## Step 2: Create the provider configuration
20+
21+
Next we must configure the Terraform provider for SAP BTP. This is done by adding the provider configuration to the `provider.tf` file. You find the information about the required parameters in the documentation of the [Terraform Provider for SAP BTP](https://registry.terraform.io/providers/SAP/btp/latest/docs).
22+
23+
Open the file `provider.tf` and add the following content:
24+
25+
```terraform
26+
terraform {
27+
required_providers {
28+
btp = {
29+
source = "sap/btp"
30+
version = "~> 1.8.0"
31+
}
32+
}
33+
}
34+
35+
provider "btp" {
36+
globalaccount = var.globalaccount
37+
}
38+
```
39+
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+
42+
> [!NOTE]
43+
> We do not need any authentication information in this file. We provided the authentication information via environment variables.
44+
45+
Next we must add the required variables to the `variables.tf` file. Open the file `variables.tf` and add the following content:
46+
47+
```terraform
48+
variable "globalaccount" {
49+
type = string
50+
description = "The subdomain of the SAP BTP global account."
51+
}
52+
```
53+
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
55+
the file `terraform.tfvars` and add the following content:
56+
57+
```terraform
58+
globalaccount = "<YOUR GLOBAL ACCOUNT SUBDOMAIN>"
59+
```
60+
61+
The SAP BTP Global Account Subdomain can be found in the SAP BTP Cockpit as shown below
62+
<img width="600px" src="assets/trial-account.png" alt="SAP BTP Global Account Subdomain">
63+
64+
> [!NOTE]
65+
> 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.
66+
67+
## Summary
68+
69+
You've now created a basic setup of the Terraform provider including its configuration.
70+
71+
Continue to - [Exercise 2 - Setup of a subaccount](../EXERCISE2/README.md).

released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE1/SOLUTION_EX1/main.tf

Whitespace-only changes.

released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE1/SOLUTION_EX1/outputs.tf

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
terraform {
3+
required_providers {
4+
btp = {
5+
source = "sap/btp"
6+
version = "~> 1.8.0"
7+
}
8+
}
9+
10+
}
11+
12+
# Please checkout documentation on how best to authenticate against SAP BTP
13+
# via the Terraform provider for SAP BTP
14+
provider "btp" {
15+
globalaccount = var.globalaccount
16+
}

0 commit comments

Comments
 (0)