Skip to content

Commit d0b3172

Browse files
committed
fix cf requirement for sbpa instance
1 parent 1f381ca commit d0b3172

File tree

3 files changed

+57
-4
lines changed

3 files changed

+57
-4
lines changed

released/discovery_center/mission_4033/step1/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ To deploy the resources you must:
4545
5. Apply your configuration to provision the resources:
4646

4747
```bash
48-
terraform apply -var-file="samples.tfvars"
48+
terraform apply -var-file="sample.tfvars"
4949
```
5050

5151
## In the end
5252

5353
You probably want to remove the assets after trying them out to avoid unnecessary costs. To do so execute the following command:
5454

5555
```bash
56-
terraform destroy -var-file="samples.tfvars"
56+
terraform destroy -var-file="sample.tfvars"
5757
```

released/discovery_center/mission_4033/step1/main.tf

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ resource "random_uuid" "uuid" {}
66
locals {
77
random_uuid = random_uuid.uuid.result
88
subaccount_domain = lower(replace("mission-4033-${local.random_uuid}", "_", "-"))
9+
subaccount_cf_org = substr(replace("${local.subaccount_domain}", "-", ""), 0, 32)
910
}
1011

1112
locals {
@@ -128,6 +129,33 @@ resource "btp_subaccount_environment_instance" "kyma" {
128129
depends_on = [btp_subaccount_entitlement.kymaruntime]
129130
}
130131

132+
# ------------------------------------------------------------------------------------------------------
133+
# Extract list of CF landscape labels from environments
134+
# ------------------------------------------------------------------------------------------------------
135+
data "btp_subaccount_environments" "all" {
136+
subaccount_id = data.btp_subaccount.dc_mission.id
137+
}
138+
139+
# Take the landscape label from the first CF environment if no environment label is provided
140+
resource "terraform_data" "cf_landscape_label" {
141+
input = length(var.cf_landscape_label) > 0 ? var.cf_landscape_label : [for env in data.btp_subaccount_environments.all.values : env if env.service_name == "cloudfoundry" && env.environment_type == "cloudfoundry"][0].landscape_label
142+
}
143+
144+
# ------------------------------------------------------------------------------------------------------
145+
# Creation of Cloud Foundry environment
146+
# ------------------------------------------------------------------------------------------------------
147+
resource "btp_subaccount_environment_instance" "cloudfoundry" {
148+
subaccount_id = data.btp_subaccount.dc_mission.id
149+
name = var.cf_org_name
150+
environment_type = "cloudfoundry"
151+
service_name = "cloudfoundry"
152+
plan_name = "standard"
153+
landscape_label = terraform_data.cf_landscape_label.output
154+
parameters = jsonencode({
155+
instance_name = local.subaccount_cf_org
156+
})
157+
}
158+
131159
# ------------------------------------------------------------------------------------------------------
132160
# Create app subscription to SAP Integration Suite
133161
# ------------------------------------------------------------------------------------------------------
@@ -230,7 +258,7 @@ resource "btp_subaccount_entitlement" "process_automation_service" {
230258
depends_on = [btp_subaccount_subscription.build_process_automation]
231259
}
232260

233-
# Get plan for SAP AI Core service
261+
# Get plan for SAP Build Process Automation service
234262
data "btp_subaccount_service_plan" "process_automation_service" {
235263
subaccount_id = data.btp_subaccount.dc_mission.id
236264
offering_name = local.service_name__sap_process_automation_service
@@ -243,7 +271,7 @@ resource "btp_subaccount_service_instance" "process_automation_service_instance"
243271
subaccount_id = data.btp_subaccount.dc_mission.id
244272
serviceplan_id = data.btp_subaccount_service_plan.process_automation_service.id
245273
name = "build-process-automation-service-instance"
246-
depends_on = [btp_subaccount_entitlement.process_automation_service]
274+
depends_on = [btp_subaccount_entitlement.process_automation_service, btp_subaccount_environment_instance.cloudfoundry]
247275
}
248276

249277
# Create service binding to SAP Build Process Automation Service (exposed for a specific user group)

released/discovery_center/mission_4033/step1/variables.tf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,20 @@ variable "cli_server_url" {
3434
default = "https://cli.btp.cloud.sap"
3535
}
3636

37+
# cf org name
38+
variable "cf_org_name" {
39+
type = string
40+
description = "Cloud Foundry Org Name"
41+
default = "cloud-foundry"
42+
}
43+
44+
# cf landscape label
45+
variable "cf_landscape_label" {
46+
type = string
47+
description = "The Cloud Foundry landscape (format example eu10-004)."
48+
default = ""
49+
}
50+
3751
variable "subaccount_admins" {
3852
type = list(string)
3953
description = "Defines the colleagues who are added to each subaccount as Subaccount administrators."
@@ -190,4 +204,15 @@ variable "create_tfvars_file_for_step2" {
190204
type = bool
191205
description = "Switch to enable the creation of the tfvars file for step 2."
192206
default = true
207+
}
208+
209+
variable "cf_space_name" {
210+
type = string
211+
description = "Name of the Cloud Foundry space."
212+
default = "dev"
213+
214+
validation {
215+
condition = can(regex("^.{1,255}$", var.cf_space_name))
216+
error_message = "The Cloud Foundry space name must not be emtpy and not exceed 255 characters."
217+
}
193218
}

0 commit comments

Comments
 (0)