You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: released/SAP-Inside-Tracks/SITBLR_DEC_2024/exercises/EXERCISE3/README.md
+53-38Lines changed: 53 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,25 +1,32 @@
1
-
# Exercise 4 - Assign entitlements to a subaccount
1
+
# Exercise 3 - Assign entitlement,Subscription and its role assignments to a subaccount
2
2
3
3
## Goal of this Exercise 🎯
4
4
5
-
In this exercise, you will learn how to assign entitlements to a subaccount using Terraform. In addition, you will learn how to work with complex variables.
5
+
In this exercise, you will learn how add an entitlement to a subaccount using Terraform.
6
6
7
-
## Entitle the subaccount
7
+
## Entitle the subaccount with Business Application Stuido (BAS)
8
8
9
-
## Step 1: Enhance the variables
9
+
## Step 1: Configure BAS
10
+
11
+
Our goal is to configure Business Application Studio (BAS) for the subaccount by defining the necessary resources for entitlement, subscription, and role assignments.
12
+
13
+
We will define the variables in the `variable.tf` file. Open the `variable.tf` file and add the following code.
10
14
11
-
Our goal is to have one variable that contains the list of entitlements that we want to assign to the subaccount. An entitlement is an object that consists of several attributes, such as the service name, the plan name, and if necessary the amount.
12
-
We will define the variable `entitlements` in the `variables.tf` file. Open the `variables.tf` file and add the following code:
13
15
14
16
```terraform
15
-
variable "entitlements" {
16
-
type = list(object({
17
-
name = string
18
-
plan = string
19
-
amount = number
20
-
}))
21
-
description = "List of entitlements for the subaccount."
22
-
default = []
17
+
variable "bas_admins" {
18
+
type = list(string)
19
+
description = "List of users to assign the Administrator role."
20
+
21
+
}
22
+
variable "bas_developers" {
23
+
type = list(string)
24
+
description = "List of users to assign the Developer role."
25
+
}
26
+
variable "bas_plan" {
27
+
type = string
28
+
description = "Plan name for Business Application Studio."
29
+
default = "standard"
23
30
}
24
31
```
25
32
@@ -32,45 +39,53 @@ Now we need to specify the entitlements we want to create to the `terraform.tfva
32
39
We want to add the following entitlements to the subaccount:
33
40
34
41
-`sapappstudiotrial` application with the `trial` plan
35
-
-`cf_application_runtime` runtime with memory`1 GB`
36
42
37
43
Open the `terraform.tfvars` file and add the following code:
38
44
39
45
```terraform
40
-
entitlements = [
41
-
{
42
-
name = "sapappstudiotrial"
43
-
plan = "trial"
44
-
amount = null
45
-
},
46
-
{
47
-
name = "application_runtime"
48
-
plan = "memory"
49
-
amount = "null"
50
-
}
51
-
]
52
-
```
46
+
bas_plan = "trial"
53
47
54
-
As you can see, we define a list of objects, where each object has the attributes `name`, `plan`, and `amount`. We set the `amount` attribute to `null` for all entitlements. Save the changes.
As we have the variable and the values for the entitlements in place, we can now add the configuration to assign the entitlements to the subaccount. We use the resource [btp_subaccount_entitlement](https://registry.terraform.io/providers/SAP/btp/latest/docs/resources/subaccount_entitlement) to achieve this. Open the `main.tf` file and add the following code:
54
+
As we have the variable and the values for the `BAS` in place, we can now add the configuration to assign the entitlement to the subaccount. We use the resource [btp_subaccount_entitlement](https://registry.terraform.io/providers/SAP/btp/latest/docs/resources/subaccount_entitlement) to achieve this. Open the `main.tf` file and add the following code:
We iterate through the list of entitlements and create a resource for each entitlement. We use the[`for_each` meta-argument](https://developer.hashicorp.com/terraform/language/meta-arguments/for_each) to achieve this. The `for_each` argument works on a map, so we must transform our list of entitlements into a map leveraging Terraform's automatic type conversion via the [`for` expression](https://developer.hashicorp.com/terraform/language/expressions/for#result-types) for setting up the map. As for the subaccount administrators we access the value of the current iteration via `each.value` and reference the corresponding attributes of the object. The `subaccount_id` is set to the id of the subaccount we created in the previous exercise. Save the changes.
88
+
We iterate through the list of entitlement and create a resource for `BAS`. We use the[`for_each` meta-argument](https://developer.hashicorp.com/terraform/language/meta-arguments/for_each) to achieve this. The `for_each` argument works on a map, so we must transform our list of users into a map leveraging Terraform's automatic type conversion via the [`for` expression](https://developer.hashicorp.com/terraform/language/expressions/for#result-types) for setting up the map. As for the subaccount administrators we access the value of the current iteration via `each.value` and reference the corresponding attributes of the object. The `subaccount_id` is set to the id of the subaccount we created in the previous exercise. Save the changes.
0 commit comments