1
+ # ------------------------------------------------------------------------------------------------------
2
+ # Subaccount setup for DC mission 4024 (trial)
3
+ # ------------------------------------------------------------------------------------------------------
4
+ # Setup subaccount domain (to ensure uniqueness in BTP global account)
1
5
resource "random_uuid" "uuid" {}
2
6
3
7
locals {
4
8
random_uuid = random_uuid. uuid . result
5
9
subaccount_domain = " dcmission4024${ local . random_uuid } "
6
-
7
- # used (mandatory) services
8
- service_name__sap_build_apps = " sap-build-apps"
9
- service_name__sap_launchpad = " SAPLaunchpad"
10
- service_name__destination = " destination"
11
- # optional, if custom idp is used
12
- service_name__sap_identity_services_onboarding = " sap-identity-services-onboarding"
13
10
}
14
11
15
12
# ------------------------------------------------------------------------------------------------------
@@ -31,8 +28,80 @@ data "btp_subaccount" "subaccount" {
31
28
id = data. btp_subaccount . dc_mission . id
32
29
}
33
30
# ------------------------------------------------------------------------------------------------------
34
- # SERVICES/SUBSCRIPTIONS
31
+ # SERVICES
35
32
# ------------------------------------------------------------------------------------------------------
33
+ #
34
+ locals {
35
+ service_name__destination = " destination"
36
+ # optional
37
+ service_name__application_runtime = " APPLICATION_RUNTIME"
38
+ }
39
+ # ------------------------------------------------------------------------------------------------------
40
+ # Setup destination (Destination Service)
41
+ # ------------------------------------------------------------------------------------------------------
42
+ # Entitle
43
+ resource "btp_subaccount_entitlement" "destination" {
44
+ subaccount_id = data. btp_subaccount . dc_mission . id
45
+ service_name = local. service_name__destination
46
+ plan_name = var. service_plan__destination
47
+ }
48
+
49
+ # Get plan for destination service
50
+ data "btp_subaccount_service_plan" "by_name" {
51
+ subaccount_id = data. btp_subaccount . dc_mission . id
52
+ name = var. service_plan__destination
53
+ offering_name = local. service_name__destination
54
+ depends_on = [btp_subaccount_subscription . sap_launchpad ]
55
+ }
56
+
57
+ # Create destination for Visual Cloud Functions
58
+ resource "btp_subaccount_service_instance" "vcf_destination" {
59
+ subaccount_id = data. btp_subaccount . dc_mission . id
60
+ serviceplan_id = data. btp_subaccount_service_plan . by_name . id
61
+ name = " SAP-Build-Apps-Runtime"
62
+ parameters = jsonencode ({
63
+ HTML5Runtime_enabled = true
64
+ init_data = {
65
+ subaccount = {
66
+ existing_destinations_policy = " update"
67
+ destinations = [
68
+ {
69
+ Name = " SAP-Build-Apps-Runtime"
70
+ Type = " HTTP"
71
+ Description = " Endpoint to SAP Build Apps runtime"
72
+ URL = " https://${ data . btp_subaccount . subaccount . subdomain } .cr1.${ data . btp_subaccount . subaccount . region } .apps.build.cloud.sap/"
73
+ ProxyType = " Internet"
74
+ Authentication = " NoAuthentication"
75
+ " HTML5.ForwardAuthToken" = true
76
+ }
77
+ ]
78
+ }
79
+ }
80
+ })
81
+ }
82
+
83
+ # ------------------------------------------------------------------------------------------------------
84
+ # Setup APPLICATION_RUNTIME (Cloud Foundry Runtime)
85
+ # ------------------------------------------------------------------------------------------------------
86
+ # Entitle
87
+ resource "btp_subaccount_entitlement" "application_runtime" {
88
+ count = var. use_optional_resources ? 1 : 0
89
+ subaccount_id = data. btp_subaccount . dc_mission . id
90
+ service_name = local. service_name__application_runtime
91
+ plan_name = var. service_plan__application_runtime
92
+ amount = 1
93
+ }
94
+
95
+ # ------------------------------------------------------------------------------------------------------
96
+ # APP SUBSCRIPTIONS
97
+ # ------------------------------------------------------------------------------------------------------
98
+ #
99
+ locals {
100
+ service_name__sap_build_apps = " sap-build-apps"
101
+ service_name__sap_launchpad = " SAPLaunchpad"
102
+ # optional, if custom idp is used
103
+ service_name__sap_identity_services_onboarding = " sap-identity-services-onboarding"
104
+ }
36
105
# ------------------------------------------------------------------------------------------------------
37
106
# Setup sap-identity-services-onboarding (Cloud Identity Services)
38
107
# ------------------------------------------------------------------------------------------------------
@@ -69,7 +138,7 @@ resource "btp_subaccount_entitlement" "sap_build_apps" {
69
138
depends_on = [btp_subaccount_trust_configuration . fully_customized ]
70
139
}
71
140
# Subscribe
72
- resource "btp_subaccount_subscription" "sap-build-apps " {
141
+ resource "btp_subaccount_subscription" "sap_build_apps " {
73
142
subaccount_id = data. btp_subaccount . dc_mission . id
74
143
app_name = " sap-appgyver-ee"
75
144
plan_name = var. service_plan__sap_build_apps
@@ -84,7 +153,6 @@ resource "btp_subaccount_entitlement" "sap_launchpad" {
84
153
subaccount_id = data. btp_subaccount . dc_mission . id
85
154
service_name = local. service_name__sap_launchpad
86
155
plan_name = var. service_plan__sap_launchpad
87
- # amount = var.service_plan__sap_launchpad == "free" ? 1 : null
88
156
}
89
157
90
158
# Subscribe
@@ -95,58 +163,14 @@ resource "btp_subaccount_subscription" "sap_launchpad" {
95
163
depends_on = [btp_subaccount_entitlement . sap_launchpad ]
96
164
}
97
165
98
- # ------------------------------------------------------------------------------------------------------
99
- # Setup destination (Destination Service)
100
- # ------------------------------------------------------------------------------------------------------
101
- # Entitle
102
- resource "btp_subaccount_entitlement" "destination" {
103
- subaccount_id = data. btp_subaccount . dc_mission . id
104
- service_name = local. service_name__destination
105
- plan_name = var. service_plan__destination
106
- }
107
-
108
- # Get plan for destination service
109
- data "btp_subaccount_service_plan" "by_name" {
110
- subaccount_id = data. btp_subaccount . dc_mission . id
111
- name = var. service_plan__destination
112
- offering_name = local. service_name__destination
113
- depends_on = [btp_subaccount_subscription . sap_launchpad ]
114
- }
115
-
116
- # Create destination for Visual Cloud Functions
117
- resource "btp_subaccount_service_instance" "vcf_destination" {
118
- subaccount_id = data. btp_subaccount . dc_mission . id
119
- serviceplan_id = data. btp_subaccount_service_plan . by_name . id
120
- name = " SAP-Build-Apps-Runtime"
121
- parameters = jsonencode ({
122
- HTML5Runtime_enabled = true
123
- init_data = {
124
- subaccount = {
125
- existing_destinations_policy = " update"
126
- destinations = [
127
- {
128
- Name = " SAP-Build-Apps-Runtime"
129
- Type = " HTTP"
130
- Description = " Endpoint to SAP Build Apps runtime"
131
- URL = " https://${ data . btp_subaccount . subaccount . subdomain } .cr1.${ data . btp_subaccount . subaccount . region } .apps.build.cloud.sap/"
132
- ProxyType = " Internet"
133
- Authentication = " NoAuthentication"
134
- " HTML5.ForwardAuthToken" = true
135
- }
136
- ]
137
- }
138
- }
139
- })
140
- }
141
-
142
166
# ------------------------------------------------------------------------------------------------------
143
167
# USERS AND ROLES
144
168
# ------------------------------------------------------------------------------------------------------
145
169
#
146
170
# Get all roles in the subaccount
147
171
data "btp_subaccount_roles" "all" {
148
172
subaccount_id = data. btp_subaccount . dc_mission . id
149
- depends_on = [btp_subaccount_subscription . sap-build-apps ]
173
+ depends_on = [btp_subaccount_subscription . sap_build_apps ]
150
174
}
151
175
# ------------------------------------------------------------------------------------------------------
152
176
# Assign role collection "Subaccount Administrator"
@@ -263,12 +287,16 @@ resource "btp_subaccount_role_collection_assignment" "build_apps_registry_develo
263
287
depends_on = [btp_subaccount_role_collection . build_apps_registry_developer ]
264
288
}
265
289
290
+ # ------------------------------------------------------------------------------------------------------
291
+ # Assign role collection "Launchpad_Admin"
292
+ # ------------------------------------------------------------------------------------------------------
266
293
# Assign users
267
294
resource "btp_subaccount_role_collection_assignment" "launchpad_admin" {
268
295
for_each = toset (" ${ var . launchpad_admins } " )
269
296
subaccount_id = data. btp_subaccount . dc_mission . id
270
297
role_collection_name = " Launchpad_Admin"
271
298
user_name = each. value
299
+ origin = btp_subaccount_trust_configuration. fully_customized . origin
272
300
depends_on = [btp_subaccount_subscription . sap_launchpad ]
273
301
}
274
302
0 commit comments