Skip to content

Commit eb347d2

Browse files
committed
3680 QAS Polished and few fixes
1 parent 7b13304 commit eb347d2

File tree

11 files changed

+376
-124
lines changed

11 files changed

+376
-124
lines changed

released/discovery_center/mission_3680/step1/README.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Discovery Center Mission: Create a custom mobile app to extend HR capabilities (3680)
1+
# Discovery Center Mission: Create a custom mobile app to extend HR capabilities (3680) - Step 1
22

33
## Overview
44

@@ -18,27 +18,31 @@ The setup comprises the following resources:
1818

1919
To deploy the resources you must:
2020

21-
1. Export environment variables BTP_USERNAME, BTP_PASSWORD, CF_USER, and CF_PASSWORD with your username and password for the custom IdP of your global account.
21+
1. Set the environment variables BTP_USERNAME and BTP_PASSWORD to pass credentials to the BTP provider to authenticate and interact with your BTP environments.
2222

23-
2. Change the variables in the `samples.tfvars` file in the main folder to meet your requirements
23+
```bash
24+
export BTP_USERNAME=<your_username>
25+
export BTP_PASSWORD=<your_password>
26+
```
27+
28+
2. Change the variables in the `sample.tfvars` file to meet your requirements
2429

2530
> ⚠ NOTE: You should pay attention **specifically** to the users defined in the samples.tfvars whether they already exist in your SAP BTP accounts. Otherwise you might get error messages like e.g. `Error: The user could not be found: [email protected]`.
2631
27-
3. Execute the apply.sh script.
2832

29-
4. Verify e.g., in BTP cockpit that a new subaccount with a integration suite, SAP Business Application Studio, CF environment instance and a CF space have been created.
33+
3. Initialize your workspace:
3034

3135
```bash
3236
terraform init
3337
```
3438

35-
5. You can check what Terraform plans to apply based on your configuration:
39+
4. You can check what Terraform plans to apply based on your configuration:
3640

3741
```bash
38-
terraform plan -var-file="samples.tfvars"
42+
terraform plan -var-file="sample.tfvars"
3943
```
4044

41-
6. Apply your configuration to provision the resources:
45+
5. Apply your configuration to provision the resources:
4246

4347
```bash
4448
terraform apply -var-file="samples.tfvars"
@@ -50,4 +54,4 @@ You probably want to remove the assets after trying them out to avoid unnecessar
5054

5155
```bash
5256
terraform destroy -var-file="samples.tfvars"
53-
```
57+
```

released/discovery_center/mission_3680/step1/locals.tf

Lines changed: 0 additions & 4 deletions
This file was deleted.

released/discovery_center/mission_3680/step1/main.tf

Lines changed: 198 additions & 22 deletions
Large diffs are not rendered by default.
Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
output "subaccount_id" {
2-
value = btp_subaccount.dc_mission.id
2+
value = data.btp_subaccount.dc_mission.id
33
description = "The ID of the subaccount."
44
}
55

@@ -27,38 +27,12 @@ output "hana_tools_url" {
2727
value = btp_subaccount_subscription.hana_cloud_tools.subscription_url
2828
description = "HANA Tools URL"
2929
}
30+
output "build_apps_url" {
31+
value = btp_subaccount_subscription.sap-build-apps_standard.subscription_url
32+
description = "SAP Build Apps URL"
33+
}
3034

3135
output "cf_org_name" {
3236
value = jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels)["Org Name"]
3337
description = "The Cloudfoundry org name."
3438
}
35-
36-
output "cf_org_admins" {
37-
value = var.cf_org_admins
38-
description = "The Cloudfoundry org admins."
39-
}
40-
41-
output "cf_org_users" {
42-
value = var.cf_org_users
43-
description = "The Cloudfoundry org users."
44-
}
45-
46-
output "cf_space_developers" {
47-
value = var.cf_space_developers
48-
description = "The Cloudfoundry space developers."
49-
}
50-
51-
output "cf_space_managers" {
52-
value = var.cf_space_managers
53-
description = "The Cloudfoundry space managers."
54-
}
55-
56-
output "cf_space_name" {
57-
value = var.cf_space_name
58-
description = "The Cloudfoundry space name."
59-
}
60-
61-
output "origin" {
62-
value = var.origin
63-
description = "The origin of the identity provider."
64-
}

released/discovery_center/mission_3680/step1/samples.tfvars renamed to released/discovery_center/mission_3680/step1/sample.tfvars

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
globalaccount = "yourglobalaccount"
66
region = "us10"
77
subaccount_name = "SAP Discovery Center Mission 3680"
8+
custom_idp = "<your_idp>.accounts.ondemand.com"
89

910
# ------------------------------------------------------------------------------------------------------
1011
# Project specific configuration (please adapt!)
@@ -14,15 +15,21 @@ subaccount_name = "SAP Discovery Center Mission 3680"
1415
subaccount_admins = ["[email protected]"]
1516
subaccount_service_admins = ["[email protected]"]
1617

17-
hana_cloud_admins = ["[email protected]"]
18+
hana_system_admin = "[email protected]"
1819
hana_system_password = "Abc12345"
1920

2021
# Don't add the user, that is executing the TF script to cf_org_admins or cf_org_users!
2122
cf_org_admins = ["[email protected]"]
2223
cf_org_users = ["[email protected]"]
23-
cf_space_managers = ["[email protected]", "[email protected]"]
24-
cf_space_developers = ["[email protected]", "[email protected]"]
24+
cf_space_managers = ["[email protected]"]
25+
cf_space_developers = ["[email protected]"]
2526

2627
# Event Mesh users
27-
event_mesh_admins = ["[email protected]", "[email protected]"]
28-
event_mesh_developers = ["[email protected]", "[email protected]"]
28+
event_mesh_admins = ["[email protected]"]
29+
event_mesh_developers = ["[email protected]"]
30+
31+
# Build Apps
32+
users_buildApps_admins = ["[email protected]"]
33+
users_registry_admins = ["[email protected]"]
34+
users_buildApps_developers = ["[email protected]"]
35+
users_registry_developers = ["[email protected]"]

released/discovery_center/mission_3680/step1/variables.tf

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,9 @@ variable "region" {
5151
}
5252

5353

54-
variable "hana_cloud_admins" {
55-
type = list(string)
56-
description = "Defines the colleagues who are added as admins to access the instance of SAP HANA Cloud."
57-
58-
59-
# add validation to check if admins contains a list of valid email addresses
60-
validation {
61-
condition = length([for email in var.hana_cloud_admins : can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", email))]) == length(var.hana_cloud_admins)
62-
error_message = "Please enter a valid email address for the admins of SAP HANA Cloud instance."
63-
}
54+
variable "hana_system_admin" {
55+
type = string
56+
description = "Defines the colleague who is added as admin to access the instance of SAP HANA Cloud."
6457
}
6558

6659
variable "custom_idp" {
@@ -72,7 +65,7 @@ variable "custom_idp" {
7265
variable "create_tfvars_file_for_step2" {
7366
type = bool
7467
description = "Switch to enable the creation of the tfvars file for step 2."
75-
default = false
68+
default = true
7669
}
7770

7871
variable "hana_system_password" {
@@ -178,4 +171,49 @@ variable "event_mesh_developers" {
178171
179172
}
180173

174+
variable "custom_idp_apps_origin_key" {
175+
type = string
176+
description = "The custom identity provider for the subaccount."
177+
default = "sap.custom"
178+
}
179+
180+
variable "service_plan__sap_identity_services_onboarding" {
181+
type = string
182+
description = "The plan for service 'Cloud Identity Services' with technical name 'sap-identity-services-onboarding'"
183+
default = "default"
184+
validation {
185+
condition = contains(["default"], var.service_plan__sap_identity_services_onboarding)
186+
error_message = "Invalid value for service_plan__sap_identity_services_onboarding. Only 'default' is allowed."
187+
}
188+
}
189+
190+
variable "users_buildApps_admins" {
191+
type = list(string)
192+
description = "Defines the colleagues who have the role of 'BuildAppsAdmin' in SAP Build Apps."
193+
}
194+
195+
variable "users_buildApps_developers" {
196+
type = list(string)
197+
description = "Defines the colleagues who have the role of 'BuildAppsDeveloper' in SAP Build Apps."
198+
}
199+
200+
variable "users_registry_admins" {
201+
type = list(string)
202+
description = "Defines the colleagues who have the role of 'RegistryAdmin' in SAP Build Apps."
203+
}
204+
205+
variable "users_registry_developers" {
206+
type = list(string)
207+
description = "Defines the colleagues who have the role of RegistryDeveloper' in SAP Build Apps."
208+
}
209+
210+
variable "service_plan__sap_build_apps" {
211+
type = string
212+
description = "The plan for SAP Build Apps subscription"
213+
default = "free"
214+
validation {
215+
condition = contains(["free", "standard", "partner"], var.service_plan__sap_build_apps)
216+
error_message = "Invalid value for service_plan__sap_build_apps. Only 'free', 'standard' and 'partner' are allowed."
217+
}
218+
}
181219

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Discovery Center mission - Create a custom mobile app to extend HR capabilities (3680) - Step 2
2+
3+
## Overview
4+
5+
This script shows how to create a SAP BTP subaccount for Discovery Center Mission: Create a custom mobile app to extend HR capabilities (3680). Step 2 comprises all activities that depend on the step 1 completion.
6+
7+
## Deploying the resources
8+
9+
To deploy the resources you must:
10+
11+
12+
1. If you did not create a `tfvars` file in step 1 (via the variable `create_tfvars_file_for_step2`) you must manually Take the output of step 1 and transfer it in a `tfvars` file e.g. `sample.tfvars` file to meet your requirements. Of course you can also further adjust the generated `tfvars` file from step 1.
13+
14+
2. If not already done in step 1, initialize your workspace:
15+
16+
```bash
17+
terraform init
18+
```
19+
20+
3. You can check what Terraform plans to apply based on your configuration. If you use the generated `tfvars` file from step 1 you do not need need to explicitly add the filename to the command:
21+
22+
```bash
23+
terraform plan -var-file="terraform.tfvars"
24+
```
25+
26+
4. According to the variants of step 3. apply your configuration to provision the resources either via:
27+
28+
```bash
29+
terraform apply -var-file="terraform.tfvars"
30+
```
31+
32+
## In the end
33+
34+
You probably want to remove the assets after trying them out to avoid unnecessary costs. To do so execute the command fitting your setup:
35+
36+
```bash
37+
terraform destroy -var-file="terraform.tfvars"
38+
```
Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# ------------------------------------------------------------------------------------------------------
2+
# Import custom trust config and disable for user login
3+
# ------------------------------------------------------------------------------------------------------
4+
import {
5+
to = btp_subaccount_trust_configuration.default
6+
id = "${var.subaccount_id},sap.default"
7+
}
8+
9+
resource "btp_subaccount_trust_configuration" "default" {
10+
subaccount_id = var.subaccount_id
11+
identity_provider = ""
12+
auto_create_shadow_users = false
13+
available_for_user_logon = false
14+
}
15+
116
# ------------------------------------------------------------------------------------------------------
217
# Create space using CF provider
318
# ------------------------------------------------------------------------------------------------------
@@ -6,6 +21,24 @@ resource "cloudfoundry_space" "dev" {
621
org = var.cf_org_id
722
}
823

24+
# ------------------------------------------------------------------------------------------------------
25+
# SETUP ALL SERVICES FOR CF USAGE
26+
# ------------------------------------------------------------------------------------------------------
27+
# ------------------------------------------------------------------------------------------------------
28+
# USERS AND ROLES
29+
# ------------------------------------------------------------------------------------------------------
30+
data "btp_whoami" "me" {}
31+
32+
locals {
33+
# Remove current user if issuer (idp) of logged in user is not same as used custom idp
34+
cf_org_admins = data.btp_whoami.me.issuer != var.custom_idp ? var.cf_org_admins : setsubtract(toset(var.cf_org_admins), [data.btp_whoami.me.email])
35+
cf_org_users = data.btp_whoami.me.issuer != var.custom_idp ? var.cf_org_admins : setsubtract(toset(var.cf_org_users), [data.btp_whoami.me.email])
36+
37+
# get origin_key from custom.idp
38+
custom_idp_tenant = var.custom_idp != "" ? element(split(".", var.custom_idp), 0) : ""
39+
origin_key = local.custom_idp_tenant != "" ? "${local.custom_idp_tenant}-platform" : "sap.ids"
40+
}
41+
942
# ------------------------------------------------------------------------------------------------------
1043
# add org and space users and managers
1144
# ------------------------------------------------------------------------------------------------------
@@ -14,23 +47,23 @@ resource "cloudfoundry_org_role" "organization_user" {
1447
username = each.value
1548
type = "organization_user"
1649
org = var.cf_org_id
17-
origin = var.origin
50+
origin = local.origin_key
1851
}
1952

2053
resource "cloudfoundry_org_role" "organization_manager" {
2154
for_each = toset(var.cf_org_admins)
2255
username = each.value
2356
type = "organization_manager"
2457
org = var.cf_org_id
25-
origin = var.origin
58+
origin = local.origin_key
2659
}
2760

2861
resource "cloudfoundry_space_role" "space_developer" {
2962
for_each = toset(var.cf_space_developers)
3063
username = each.value
3164
type = "space_developer"
3265
space = cloudfoundry_space.dev.id
33-
origin = var.origin
66+
origin = local.origin_key
3467
depends_on = [cloudfoundry_org_role.organization_user, cloudfoundry_org_role.organization_manager]
3568
}
3669

@@ -39,6 +72,6 @@ resource "cloudfoundry_space_role" "space_manager" {
3972
username = each.value
4073
type = "space_manager"
4174
space = cloudfoundry_space.dev.id
42-
origin = var.origin
75+
origin = local.origin_key
4376
depends_on = [cloudfoundry_org_role.organization_user, cloudfoundry_org_role.organization_manager]
4477
}

released/discovery_center/mission_3680/step2/outputs.tf

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
terraform {
22
required_providers {
33
cloudfoundry = {
4-
source = "sap/cloudfoundry"
4+
source = "SAP/cloudfoundry"
55
version = "1.0.0-rc1"
66
}
7+
btp = {
8+
source = "SAP/btp"
9+
version = "~> 1.5.0"
10+
}
711
}
812
}
913

10-
# ------------------------------------------------------------------------------------------------------
11-
# Configure CF provider
12-
# ------------------------------------------------------------------------------------------------------
14+
provider "btp" {
15+
globalaccount = var.globalaccount
16+
cli_server_url = var.cli_server_url
17+
}
18+
19+
1320
provider "cloudfoundry" {
14-
# resolve API URL from environment instance
1521
api_url = var.cf_api_url
1622
}

0 commit comments

Comments
 (0)