-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
47 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,36 @@ To fulfill all requirements for the authentication against the Cloud Foundry env | |
export CF_PASSWORD='<your SAP BTP 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: | ||
|
||
<img width="600px" src="assets/ex7_1.png" alt="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: | ||
|
||
<img width="600px" src="assets/ex7_2.png" alt="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. | ||
|
||
The result should look like this: | ||
To configure the Cloud Foundry provider add the following lines at the end of the file: | ||
|
||
<img width="600px" src="assets/ex7_3.png" alt="executing terraform apply with cloud foundry provider"> | ||
```terraform | ||
provider "cloudfoundry" { | ||
api_url = "https://api.cf.${var.region}-001.hana.ondemand.com" | ||
} | ||
``` | ||
Save your changes. | ||
|
||
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. | ||
<img width="600px" src="assets/ex7_4.png" alt="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 +87,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 +129,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,21 +139,26 @@ cf_space_developers = ["[email protected]"] | |
``` | ||
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 | ||
``` | ||
|
||
The output should look like this: | ||
|
||
<img width="600px" src="assets/ex7_6.png" alt="executing terraform plan for cloud foundry space creation"> | ||
<img width="600px" src="assets/ex7_2.png" alt="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 | ||
|
Binary file modified
BIN
-530 KB
(23%)
released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/assets/ex7_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-180 KB
(51%)
released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/assets/ex7_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-447 KB
(23%)
released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE5/assets/ex7_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.