File tree Expand file tree Collapse file tree 5 files changed +119
-0
lines changed
sample-setups/modules/sap-btp-environment/cloudfoundry Expand file tree Collapse file tree 5 files changed +119
-0
lines changed Original file line number Diff line number Diff line change
1
+ # SAP BTP - Cloud Foundry Environment Setup
2
+
3
+ This module encapsulates the creation of a Cloud Foundry environment in a subaccount on SAP BTP.
4
+
5
+ ## Requirements
6
+
7
+ | Name | Version |
8
+ | ------| ---------|
9
+ | <a name =" requirement_terraform " ></a > [ terraform] ( #requirement\_ terraform ) | >= 1.11 |
10
+ | <a name =" requirement_btp " ></a > [ btp] ( #requirement\_ btp ) | >= 1.11.0 |
11
+
12
+ ## Providers
13
+
14
+ | Name | Version |
15
+ | ------| ---------|
16
+ | <a name =" provider_btp " ></a > [ btp] ( #provider\_ btp ) | >= 1.11.0 |
17
+ | <a name =" provider_null " ></a > [ null] ( #provider\_ null ) | n/a |
18
+
19
+ ## Modules
20
+
21
+ No modules.
22
+
23
+ ## Resources
24
+
25
+ | Name | Type |
26
+ | ------| ------|
27
+ | [ btp_subaccount_environment_instance.self] ( https://registry.terraform.io/providers/SAP/btp/latest/docs/resources/subaccount_environment_instance ) | resource |
28
+ | [ null_resource.cache_target_environment] ( https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource ) | resource |
29
+ | [ btp_subaccount_environments.all] ( https://registry.terraform.io/providers/SAP/btp/latest/docs/data-sources/subaccount_environments ) | data source |
30
+
31
+ ## Inputs
32
+
33
+ | Name | Description | Type | Default | Required |
34
+ | ------| -------------| ------| ---------| :--------:|
35
+ | <a name =" input_cf_org_name " ></a > [ cf\_ org\_ name] ( #input\_ cf\_ org\_ name ) | Name of the Cloud Foundry org. | ` string ` | n/a | yes |
36
+ | <a name =" input_instance_name " ></a > [ instance\_ name] ( #input\_ instance\_ name ) | Name of the Cloud Foundry environment instance. | ` string ` | n/a | yes |
37
+ | <a name =" input_plan_name " ></a > [ plan\_ name] ( #input\_ plan\_ name ) | Desired service plan for the Cloud Foundry environment instance. | ` string ` | ` "standard" ` | no |
38
+ | <a name =" input_subaccount_id " ></a > [ subaccount\_ id] ( #input\_ subaccount\_ id ) | ID of the subaccount where the Cloud Foundry environment will be created. | ` string ` | n/a | yes |
39
+
40
+ ## Outputs
41
+
42
+ | Name | Description |
43
+ | ------| -------------|
44
+ | <a name =" output_cf_api_url " ></a > [ cf\_ api\_ url] ( #output\_ cf\_ api\_ url ) | The Cloud Foundry API URL |
45
+ | <a name =" output_cf_org_id " ></a > [ cf\_ org\_ id] ( #output\_ cf\_ org\_ id ) | The Cloud Foundry org ID |
Original file line number Diff line number Diff line change
1
+ data "btp_subaccount_environments" "all" {
2
+ subaccount_id = var. subaccount_id
3
+ }
4
+
5
+ resource "null_resource" "cache_target_environment" {
6
+ triggers = {
7
+ label = [for env in data . btp_subaccount_environments . all . values : env if env . service_name == " cloudfoundry" && env . environment_type == " cloudfoundry" ][0 ].landscape_label
8
+ }
9
+
10
+ lifecycle {
11
+ ignore_changes = all
12
+ }
13
+ }
14
+
15
+ resource "btp_subaccount_environment_instance" "self" {
16
+ subaccount_id = var. subaccount_id
17
+ name = var. instance_name
18
+ environment_type = " cloudfoundry"
19
+ service_name = " cloudfoundry"
20
+ plan_name = var. plan_name
21
+ landscape_label = null_resource. cache_target_environment . triggers . label
22
+
23
+ parameters = jsonencode ({
24
+ instance_name = var.cf_org_name
25
+ })
26
+ }
Original file line number Diff line number Diff line change
1
+ output "cf_api_url" {
2
+ value = jsondecode (btp_subaccount_environment_instance. self . labels )[" API Endpoint" ]
3
+ description = " The Cloud Foundry API URL"
4
+ }
5
+
6
+ output "cf_org_id" {
7
+ value = jsondecode (btp_subaccount_environment_instance. self . labels )[" Org ID" ]
8
+ description = " The Cloud Foundry org ID"
9
+ }
Original file line number Diff line number Diff line change
1
+ variable "subaccount_id" {
2
+ type = string
3
+ description = " ID of the subaccount where the Cloud Foundry environment will be created."
4
+ }
5
+
6
+ variable "instance_name" {
7
+ type = string
8
+ description = " Name of the Cloud Foundry environment instance."
9
+
10
+ validation {
11
+ condition = can (regex (" ^[a-zA-Z0-9_\\ -\\ .]{1,32}$" , var. instance_name ))
12
+ error_message = " Please provide a valid instance name (^[a-zA-Z0-9_\\ -\\ .]{1,32})."
13
+ }
14
+ }
15
+
16
+ variable "plan_name" {
17
+ type = string
18
+ description = " Desired service plan for the Cloud Foundry environment instance."
19
+ default = " standard"
20
+ }
21
+
22
+ variable "cf_org_name" {
23
+ type = string
24
+ description = " Name of the Cloud Foundry org."
25
+
26
+ validation {
27
+ condition = can (regex (" ^.{1,255}$" , var. cf_org_name ))
28
+ error_message = " The Cloud Foundry org name must not be emtpy and not exceed 255 characters."
29
+ }
30
+ }
Original file line number Diff line number Diff line change
1
+ terraform {
2
+ required_version = " >= 1.11"
3
+ required_providers {
4
+ btp = {
5
+ source = " SAP/btp"
6
+ version = " >= 1.11.0"
7
+ }
8
+ }
9
+ }
You can’t perform that action at this time.
0 commit comments