|
| 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. |
| 6 | + |
| 7 | +## Scenario 📚 |
| 8 | + |
| 9 | +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: |
| 10 | + |
| 11 | +1. [Exercise 1 - Configure the Terraform Provider for SAP BTP](exercises/EXERCISE1/README.md) |
| 12 | +1. [Exercise 2 - Setup of a subaccount](exercises/EXERCISE2/README.md) |
| 13 | +1. [Exercise 3 - Assignment of subaccount emergency administrators](exercises/EXERCISE3/README.md) |
| 14 | +1. [Exercise 4 - Assign entitlements to a subaccount](exercises/EXERCISE4/README.md) |
| 15 | +1. [Exercise 5 - Create a service instance](exercises/EXERCISE5/README.md) |
| 16 | +1. [Exercise 6 - Handle configuration drift](exercises/EXERCISE6/README.md) |
| 17 | +1. [Exercise 7 - Setup a Cloud Foundry environment and a space (optional)](exercises/EXERCISE7/README.md) |
| 18 | +1. [Exercise 8 - Cleanup](exercises/EXERCISE8/README.md) |
| 19 | + |
| 20 | +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. |
| 21 | + |
| 22 | +## Prerequisites 📝 |
| 23 | + |
| 24 | +Make sure that the following prerequisites are met: |
| 25 | + |
| 26 | +- 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). |
| 27 | +- 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). |
| 28 | +- The Terraform provider does not support SSO or 2FA. Make sure that these options are not enforced for your account. |
| 29 | + |
| 30 | +## Tools 🛠️ |
| 31 | + |
| 32 | +To execute the exercises you have the following options concerning the required tools installed: |
| 33 | + |
| 34 | +- local installation |
| 35 | +- usage of the provided dev container |
| 36 | +- usage of GitHub Codespaces |
| 37 | + |
| 38 | +You find details about the installation of the tools in the following sections |
| 39 | + |
| 40 | +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). |
| 41 | + |
| 42 | +You can then clone the repository via the following command: |
| 43 | + |
| 44 | +```bash |
| 45 | +git clone https://github.com/SAP-samples/btp-terraform-samples.git |
| 46 | +``` |
| 47 | + |
| 48 | +you find the exercises in the folder `released/dsag/betriebstag2024/exercises`. |
| 49 | + |
| 50 | +### Local Installation |
| 51 | + |
| 52 | +You can install the required tools locally on your machine. The following tools are required: |
| 53 | + |
| 54 | +- [Terraform CLI](https://developer.hashicorp.com/terraform/install?product_intent=terraform) |
| 55 | +- 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). |
| 56 | + |
| 57 | +### Dev Container |
| 58 | + |
| 59 | +As an alternative to the local installation you can use the provided dev container that contains all required tools. This requires that you have [Docker](https://www.docker.com/products/docker-desktop) installed on your machine. In addition you need the dev container extension for Visual Studio Code. You can find detailed instructions about the setup [here](https://code.visualstudio.com/docs/devcontainers/containers#_getting-started). |
| 60 | + |
| 61 | +To start a dev container Docker must be running on your machine. |
| 62 | + |
| 63 | +To use the dev container you must open the folder that contains the cloned repository in Visual Studio Code. You will be asked if you want to reopen the folder in the dev container. Confirm this. |
| 64 | + |
| 65 | +If this is not the case execute the following steps: |
| 66 | + |
| 67 | +1. Open the command palette in Visual Studio Code: |
| 68 | + |
| 69 | + - Windows / Linux: `Ctrl + Shift + P` |
| 70 | + - Mac: `Cmd + Shift + P` |
| 71 | + |
| 72 | +2. Enter `Dev Containers: Reopen in Container` and confirm with `Enter`. |
| 73 | + |
| 74 | +3. You will then be asked to select a dev container. Select the `Terraform provider for SAP BTP - Default` container: |
| 75 | + |
| 76 | +  |
| 77 | + |
| 78 | +The dev container will automatically start and you are ready to go |
| 79 | + |
| 80 | +### GitHub Codespaces |
| 81 | + |
| 82 | +To use [Codespaces](https://docs.github.com/codespaces/overview) you must have a GitHub account. If you don't have one so far, please [sign-up on GitHub](https://github.com/signup) before going through the exercises. |
| 83 | + |
| 84 | +You can then access the Codespace following these steps: |
| 85 | + |
| 86 | +1. Open the [GitHub repository of the Terraform samples](https://github.com/SAP-samples/btp-terraform-samples). |
| 87 | + |
| 88 | +  |
| 89 | + |
| 90 | +2. Click on this button and create the code space: |
| 91 | + |
| 92 | + [](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=656281656&skip_quickstart=true&machine=basicLinux32gb&geo=EuropeWest&devcontainer_path=.devcontainer%2Fdevcontainer.json) |
| 93 | + |
| 94 | + This will take a few minutes. Be patient 🙂 |
| 95 | + |
| 96 | +  |
| 97 | + |
| 98 | +3. While the Codespace is created for you, you will see this screen |
| 99 | + |
| 100 | +  |
| 101 | + |
| 102 | +4. Once all is done, you are in your Codespace. |
| 103 | + |
| 104 | +  |
| 105 | + |
| 106 | +> [!IMPORTANT] |
| 107 | +> GitHub codespaces are free for a certain amount of time per month. For the hands-on session the free time is more than enough. **Don't forget to delete your codespace again after the hands-on session!** |
| 108 | +
|
| 109 | + |
| 110 | +## Exporting environment variables |
| 111 | + |
| 112 | +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: |
| 113 | + |
| 114 | +- Windows: |
| 115 | + |
| 116 | + ```pwsh |
| 117 | + $env:BTP_USERNAME=<your SAP BTP username> |
| 118 | + $env:BTP_PASSWORD='<your SAP BTP password>' |
| 119 | + ``` |
| 120 | +
|
| 121 | +- Linux/MacOS/GitHub Codespaces: |
| 122 | +
|
| 123 | + ```bash |
| 124 | + export BTP_USERNAME=<your SAP BTP username> |
| 125 | + export BTP_PASSWORD='<your SAP BTP password>' |
| 126 | + ``` |
| 127 | +
|
| 128 | +Validate that the values are set via: |
| 129 | +
|
| 130 | +- Windows: `$env:BTP_USERNAME` and `$env:BTP_PASSWORD` |
| 131 | +- Linux/MacOS/GitHub Codeapses: `echo $BTP_USERNAME` and `echo $BTP_PASSWORD` |
| 132 | +
|
| 133 | +## Folder layout |
| 134 | +
|
| 135 | +You find all exercises of this tutorial in the folder `released/dsag/betriebstag2024/exercises`. Each exercise is contained in a dedicated folder containing: |
| 136 | +
|
| 137 | +- A `README.md` file with the instructions for the exercise |
| 138 | +- A folder `SOLUTION_EX<number>` which contains the solution for the exercise if needed including the file `terraform.tfvars-sample` contains the definition of the local variables. In case you get stuck you can check the content of this folder. |
| 139 | +
|
| 140 | +In addition the folder `solution` contains the final configuration setup if you have gone through all exercises. |
| 141 | +
|
| 142 | +## Summary |
| 143 | +
|
| 144 | +You've now prepared your development environment and have all information to finally start using Terraform provider for SAP BTP. |
| 145 | +
|
| 146 | +Continue to - [Exercise 1 - Configure the Terraform Provider for SAP BTP](exercises/EXERCISE1/README.md). |
0 commit comments