Skip to content

Commit 0eea48d

Browse files
authored
Mission 3585 (enterprise and trial) enabled for (new) quick account setup (#301)
1 parent 2b272a1 commit 0eea48d

File tree

12 files changed

+478
-139
lines changed

12 files changed

+478
-139
lines changed
Lines changed: 63 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,63 @@
1-
# Discovery Center mission - Get Started on SAP BTP with SAPUI5/Fiori - Create a Hello World App
2-
3-
## Overview
4-
5-
This sample shows how to set up your SAP BTP account for the Discovery Center Mission - [Get Started on SAP BTP with SAPUI5/Fiori - Create a Hello World App](https://discovery-center.cloud.sap/missiondetail/3585/)
6-
7-
## Content of setup
8-
9-
The setup comprises the following resources:
10-
11-
- Creation of the SAP BTP subaccount
12-
- Enablement of Cloudfoundry Environment - [see available regions and endpoints](https://help.sap.com/docs/btp/sap-business-technology-platform/regions-and-api-endpoints-available-for-cloud-foundry-environment)
13-
- Entitlements of services
14-
* SAP Business Application Studio
15-
* SAP Build Work Zone, standard edition
16-
* Continous Integration & Delivery - Optional
17-
- Subscriptions to applications
18-
- Role collection assignments to users
19-
20-
## Deploying the resources
21-
22-
Make sure that you are familiar with SAP BTP and know both the [Get Started with btp-terraform-samples](https://github.com/SAP-samples/btp-terraform-samples/blob/main/GET_STARTED.md) and the [Get Started with the Terraform Provider for BTP](https://developers.sap.com/tutorials/btp-terraform-get-started.html)
23-
24-
To deploy the resources you must:
25-
26-
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.
27-
28-
```bash
29-
export BTP_USERNAME=<your_username>
30-
export BTP_PASSWORD=<your_password>
31-
```
32-
33-
2. Change the variables in the `sample.tfvars` file to meet your requirements
34-
35-
> The minimal set of parameters you should specify (besides user_email and password) is global account (i.e. its subdomain) and the used custom_idp and all user assignments
36-
37-
> ⚠ 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]`.
38-
39-
40-
3. Initialize your workspace:
41-
42-
```bash
43-
terraform init
44-
```
45-
46-
4. You can check what Terraform plans to apply based on your configuration:
47-
48-
```bash
49-
terraform plan -var-file="sample.tfvars"
50-
```
51-
52-
6. Apply your configuration to provision the resources:
53-
54-
```bash
55-
terraform apply -var-file="sample.tfvars"
56-
```
57-
58-
## When finished
59-
60-
You probably want to remove the assets after trying them out to avoid unnecessary costs. To do so execute the following command:
61-
62-
```bash
63-
terraform destroy -var-file="sample.tfvars"
64-
```
1+
# Discovery Center Mission: Get Started on SAP BTP with SAPUI5/Fiori - Create a Hello World App
2+
3+
## Overview
4+
5+
This sample shows how to setup your SAP BTP account for the Discovery Center Mission - [Get Started on SAP BTP with SAPUI5/Fiori - Create a Hello World App](https://discovery-center.cloud.sap/protected/index.html#/missiondetail/3585) for your Enterprise BTP Account.
6+
7+
The respective setup of a trial account is described in [SAP-samples/btp-terraform-samples/tree/main/released/discovery_center/mission_3585_trial/README.md](https://github.com/SAP-samples/btp-terraform-samples/tree/main/released/discovery_center/mission_3585_trial/README.md)
8+
9+
## Content of setup
10+
11+
The setup comprises the following resources:
12+
13+
- Creation of the SAP BTP subaccount
14+
- Entitlements of services
15+
- Subscriptions to applications
16+
- Role collection assignments to users
17+
18+
## Deploying the resources
19+
20+
Make sure that you are familiar with SAP BTP and know both the [Get Started with btp-terraform-samples](https://github.com/SAP-samples/btp-terraform-samples/blob/main/GET_STARTED.md) and the [Get Started with the Terraform Provider for BTP](https://developers.sap.com/tutorials/btp-terraform-get-started.html)
21+
22+
To deploy the resources you must:
23+
24+
1. Set your credentials as environment variables
25+
26+
```bash
27+
export BTP_USERNAME ='<Email address of your BTP user>'
28+
export BTP_PASSWORD ='<Password of your BTP user>'
29+
```
30+
31+
2. Change the variables in the `sample.tfvars` file to meet your requirements
32+
33+
> The minimal set of parameters you should specify (besides user_email and password) is global account (i.e. its subdomain) and all user assignments
34+
35+
3. Then initialize your workspace:
36+
37+
```bash
38+
terraform init
39+
```
40+
41+
4. You can check what Terraform plans to apply based on your configuration:
42+
43+
```bash
44+
terraform plan -var-file="sample.tfvars"
45+
```
46+
47+
5. Apply your configuration to provision the resources:
48+
49+
```bash
50+
terraform apply -var-file="sample.tfvars"
51+
```
52+
53+
6. Verify e.g., in [BTP Cockpit](https://cockpit.btp.cloud.sap) that a new subaccount with a SAP Business Application Studio subscription has been created and respective users were assigned to role collections
54+
55+
With this you have completed the quick account setup as described in the Discovery Center Mission - [Get Started on SAP BTP with SAPUI5/Fiori - Create a Hello World App](https://discovery-center.cloud.sap/protected/index.html#/missiondetail/3585).
56+
57+
## In the end
58+
59+
You probably want to remove the assets after trying them out to avoid unnecessary costs. To do so execute the following command:
60+
61+
```bash
62+
terraform destroy -var-file="sample.tfvars"
63+
```

released/discovery_center/mission_3585/main.tf

Lines changed: 59 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,33 @@ resource "btp_subaccount" "dc_mission" {
1717
# SERVICES
1818
# ------------------------------------------------------------------------------------------------------
1919
#
20+
locals {
21+
# optional
22+
service_name__cicd_service = "cicd-service"
23+
}
2024
# ------------------------------------------------------------------------------------------------------
21-
# Setup cicd-service (not running in CF environment)
25+
# Setup cicd-service (SAP Continuous Integration and Delivery), (not running in CF environment)
2226
# ------------------------------------------------------------------------------------------------------
2327
# Entitle
2428
resource "btp_subaccount_entitlement" "cicd_service" {
29+
count = var.use_optional_resources ? 1 : 0
2530
subaccount_id = btp_subaccount.dc_mission.id
26-
service_name = "cicd-service"
27-
plan_name = "default"
31+
service_name = local.service_name__cicd_service
32+
plan_name = var.service_plan__cicd_service
2833
}
2934
# Get serviceplan_id for cicd-service with plan_name "default"
3035
data "btp_subaccount_service_plan" "cicd_service" {
36+
count = var.use_optional_resources ? 1 : 0
3137
subaccount_id = btp_subaccount.dc_mission.id
32-
offering_name = "cicd-service"
33-
name = "default"
38+
offering_name = local.service_name__cicd_service
39+
name = var.service_plan__cicd_service
3440
depends_on = [btp_subaccount_entitlement.cicd_service]
3541
}
3642
# Create service instance
3743
resource "btp_subaccount_service_instance" "cicd_service" {
44+
count = var.use_optional_resources ? 1 : 0
3845
subaccount_id = btp_subaccount.dc_mission.id
39-
serviceplan_id = data.btp_subaccount_service_plan.cicd_service.id
46+
serviceplan_id = data.btp_subaccount_service_plan.cicd_service[0].id
4047
name = "default_cicd-service"
4148
# Subscription to the cicd-app subscription is required for creating the service instance
4249
# See as well https://help.sap.com/docs/continuous-integration-and-delivery/sap-continuous-integration-and-delivery/optional-enabling-api-usage?language=en-US
@@ -47,20 +54,27 @@ resource "btp_subaccount_service_instance" "cicd_service" {
4754
# APP SUBSCRIPTIONS
4855
# ------------------------------------------------------------------------------------------------------
4956
#
57+
locals {
58+
service_name__sapappstudio = "sapappstudio"
59+
# optional
60+
service_name__sap_launchpad = "SAPLaunchpad"
61+
service_name__cicd_app = "cicd-app"
62+
63+
}
5064
# ------------------------------------------------------------------------------------------------------
51-
# Setup sapappstudio
65+
# Setup sapappstudio (SAP Business Application Studio)
5266
# ------------------------------------------------------------------------------------------------------
5367
# Entitle
5468
resource "btp_subaccount_entitlement" "sapappstudio" {
5569
subaccount_id = btp_subaccount.dc_mission.id
56-
service_name = "sapappstudio"
57-
plan_name = "standard-edition"
70+
service_name = local.service_name__sapappstudio
71+
plan_name = var.service_plan__sapappstudio
5872
}
5973
# Subscribe (depends on subscription of standard-edition)
6074
resource "btp_subaccount_subscription" "sapappstudio" {
6175
subaccount_id = btp_subaccount.dc_mission.id
62-
app_name = "sapappstudio"
63-
plan_name = "standard-edition"
76+
app_name = local.service_name__sapappstudio
77+
plan_name = var.service_plan__sapappstudio
6478
depends_on = [btp_subaccount_entitlement.sapappstudio]
6579
}
6680

@@ -69,15 +83,18 @@ resource "btp_subaccount_subscription" "sapappstudio" {
6983
# ------------------------------------------------------------------------------------------------------
7084
# Entitle
7185
resource "btp_subaccount_entitlement" "sap_launchpad" {
86+
count = var.use_optional_resources ? 1 : 0
7287
subaccount_id = btp_subaccount.dc_mission.id
73-
service_name = "SAPLaunchpad"
74-
plan_name = "standard"
88+
service_name = local.service_name__sap_launchpad
89+
plan_name = var.service_plan__sap_launchpad
90+
amount = var.service_plan__sap_launchpad == "free" ? 1 : null
7591
}
7692
# Subscribe
7793
resource "btp_subaccount_subscription" "sap_launchpad" {
94+
count = var.use_optional_resources ? 1 : 0
7895
subaccount_id = btp_subaccount.dc_mission.id
79-
app_name = "SAPLaunchpad"
80-
plan_name = "standard"
96+
app_name = local.service_name__sap_launchpad
97+
plan_name = var.service_plan__sap_launchpad
8198
depends_on = [btp_subaccount_entitlement.sap_launchpad]
8299
}
83100

@@ -86,45 +103,26 @@ resource "btp_subaccount_subscription" "sap_launchpad" {
86103
# ------------------------------------------------------------------------------------------------------
87104
# Entitle
88105
resource "btp_subaccount_entitlement" "cicd_app" {
106+
count = var.use_optional_resources ? 1 : 0
89107
subaccount_id = btp_subaccount.dc_mission.id
90-
service_name = "cicd-app"
91-
plan_name = "default"
108+
service_name = local.service_name__cicd_app
109+
plan_name = var.service_plan__cicd_app
110+
amount = var.service_plan__cicd_app == "free" ? 1 : null
92111
}
93112
# Subscribe
94113
resource "btp_subaccount_subscription" "cicd_app" {
114+
count = var.use_optional_resources ? 1 : 0
95115
subaccount_id = btp_subaccount.dc_mission.id
96-
app_name = "cicd-app"
97-
plan_name = "default"
116+
app_name = local.service_name__cicd_app
117+
plan_name = var.service_plan__cicd_app
98118
depends_on = [btp_subaccount_entitlement.cicd_app]
99119
}
100120

101-
# ------------------------------------------------------------------------------------------------------
102-
# USERS AND ROLES
103-
# ------------------------------------------------------------------------------------------------------
104-
#
105-
# Get all available subaccount roles
106-
data "btp_subaccount_roles" "all" {
107-
subaccount_id = btp_subaccount.dc_mission.id
108-
depends_on = [btp_subaccount_subscription.sap_launchpad, btp_subaccount_subscription.sapappstudio, btp_subaccount_subscription.cicd_app]
109-
}
110-
111-
# ------------------------------------------------------------------------------------------------------
112-
# Assign role collection "Launchpad_Admin"
113-
# ------------------------------------------------------------------------------------------------------
114-
resource "btp_subaccount_role_collection_assignment" "launchpad_admin" {
115-
for_each = toset("${var.launchpad_admins}")
116-
subaccount_id = btp_subaccount.dc_mission.id
117-
role_collection_name = "Launchpad_Admin"
118-
user_name = each.value
119-
depends_on = [btp_subaccount_subscription.sap_launchpad]
120-
}
121-
122-
123121
# ------------------------------------------------------------------------------------------------------
124122
# Assign role collection "Subaccount Administrator"
125123
# ------------------------------------------------------------------------------------------------------
126124
resource "btp_subaccount_role_collection_assignment" "subaccount_admin" {
127-
for_each = toset("${var.subaccount_admins}")
125+
for_each = toset(var.subaccount_admins)
128126
subaccount_id = btp_subaccount.dc_mission.id
129127
role_collection_name = "Subaccount Administrator"
130128
user_name = each.value
@@ -135,7 +133,7 @@ resource "btp_subaccount_role_collection_assignment" "subaccount_admin" {
135133
# Assign role collection "Business_Application_Studio_Administrator"
136134
# ------------------------------------------------------------------------------------------------------
137135
resource "btp_subaccount_role_collection_assignment" "bas_admins" {
138-
for_each = toset("${var.bas_admins}")
136+
for_each = toset(var.bas_admins)
139137
subaccount_id = btp_subaccount.dc_mission.id
140138
role_collection_name = "Business_Application_Studio_Administrator"
141139
user_name = each.value
@@ -146,18 +144,32 @@ resource "btp_subaccount_role_collection_assignment" "bas_admins" {
146144
# Assign role collection "Business_Application_Studio_Developer"
147145
# ------------------------------------------------------------------------------------------------------
148146
resource "btp_subaccount_role_collection_assignment" "bas_developer" {
149-
for_each = toset("${var.bas_developers}")
147+
for_each = toset(var.bas_developers)
150148
subaccount_id = btp_subaccount.dc_mission.id
151149
role_collection_name = "Business_Application_Studio_Developer"
152150
user_name = each.value
153151
depends_on = [btp_subaccount_subscription.sapappstudio]
154152
}
155153

154+
# ------------------------------------------------------------------------------------------------------
155+
# Assign role collection "Launchpad_Admin"
156+
# ------------------------------------------------------------------------------------------------------
157+
# optional app subscription
158+
resource "btp_subaccount_role_collection_assignment" "launchpad_admin" {
159+
for_each = toset(var.use_optional_resources == true ? var.launchpad_admins : [])
160+
subaccount_id = btp_subaccount.dc_mission.id
161+
role_collection_name = "Launchpad_Admin"
162+
user_name = each.value
163+
depends_on = [btp_subaccount_subscription.sap_launchpad]
164+
}
165+
156166
# ------------------------------------------------------------------------------------------------------
157167
# Assign role collection "CICD Service Administrator"
158168
# ------------------------------------------------------------------------------------------------------
169+
# optional app subscription
170+
159171
resource "btp_subaccount_role_collection_assignment" "cicd_admins" {
160-
for_each = toset("${var.cicd_admins}")
172+
for_each = toset(var.use_optional_resources == true ? var.cicd_admins : [])
161173
subaccount_id = btp_subaccount.dc_mission.id
162174
role_collection_name = "CICD Service Administrator"
163175
user_name = each.value
@@ -167,8 +179,9 @@ resource "btp_subaccount_role_collection_assignment" "cicd_admins" {
167179
# ------------------------------------------------------------------------------------------------------
168180
# Assign role collection "CICD Service Developer"
169181
# ------------------------------------------------------------------------------------------------------
182+
# optional app subscription
170183
resource "btp_subaccount_role_collection_assignment" "cicd_developers" {
171-
for_each = toset("${var.cicd_developers}")
184+
for_each = toset(var.use_optional_resources == true ? var.cicd_developers : [])
172185
subaccount_id = btp_subaccount.dc_mission.id
173186
role_collection_name = "CICD Service Developer"
174187
user_name = each.value

released/discovery_center/mission_3585/outputs.tf

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,21 @@ output "subaccount_id" {
33
description = "The Global Account subdomain id."
44
}
55

6-
output "cicd_app_subscription_url" {
7-
value = btp_subaccount_subscription.cicd_app.subscription_url
8-
description = "Continuous Integration & Delivery subscription URL."
9-
}
10-
116
output "sapappstudio_subscription_url" {
127
value = btp_subaccount_subscription.sapappstudio.subscription_url
138
description = "SAP Business Application Studio subscription URL."
149
}
1510

1611
output "sap_launchpad_subscription_url" {
17-
value = btp_subaccount_subscription.sap_launchpad.subscription_url
12+
value = var.use_optional_resources ? btp_subaccount_subscription.sap_launchpad[0].subscription_url : null
1813
description = "SAP Build Work Zone, standard edition subscription URL."
1914
}
15+
16+
output "cicd_service_id" {
17+
value = var.use_optional_resources ? btp_subaccount_service_instance.cicd_service[0].id : null
18+
}
19+
20+
output "cicd_app_subscription_url" {
21+
value = var.use_optional_resources ? btp_subaccount_subscription.cicd_app[0].subscription_url : null
22+
description = "Continuous Integration & Delivery subscription URL."
23+
}

released/discovery_center/mission_3585/provider.tf

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ terraform {
88
}
99

1010
provider "btp" {
11-
# Comment out the idp in case you need it to connect to your global account
12-
# -------------------------------------------------------------------------
13-
# idp = var.custom_idp
1411
globalaccount = var.globalaccount
1512
cli_server_url = var.cli_server_url
1613
}

released/discovery_center/mission_3585/sample.tfvars

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
# Your global account subdomain
55
globalaccount = "xxxxxxxx-xxxxxxx-xxxxxxx-xxxxxxxx-xxxxxx"
66

7-
# The CLI server URL (needs to be set to null if you are using the default CLI server)
8-
cli_server_url = null
9-
107
# Region for your subaccount
118
region = "us10"
129

@@ -18,10 +15,10 @@ subaccount_name = "SAP Discovery Center Mission 3585"
1815
# ------------------------------------------------------------------------------------------------------
1916
subaccount_admins = ["[email protected]"]
2017

18+
19+
bas_developers = ["[email protected]", "[email protected]"]
20+
2121
launchpad_admins = ["[email protected]", "[email protected]"]
2222

2323
24-
cicd_developers = ["[email protected]", "[email protected]"]
25-
26-
27-
bas_developers = ["[email protected]", "[email protected]"]
24+
cicd_developers = ["[email protected]", "[email protected]"]

0 commit comments

Comments
 (0)