Skip to content

Commit a53ea89

Browse files
committed
fix: renaming of diretcory
1 parent 04e535e commit a53ea89

File tree

5 files changed

+119
-0
lines changed

5 files changed

+119
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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 |
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
terraform {
2+
required_version = ">= 1.11"
3+
required_providers {
4+
btp = {
5+
source = "SAP/btp"
6+
version = ">= 1.11.0"
7+
}
8+
}
9+
}

0 commit comments

Comments
 (0)