Skip to content

Commit 567c464

Browse files
authored
Abap env small (#149)
1 parent 10b7429 commit 567c464

File tree

6 files changed

+329
-6
lines changed

6 files changed

+329
-6
lines changed

Diff for: released/usecases/abap_env_in_subaccount/README.md

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Sample Setup of an ABAP Environment in an existing Subaccount
2+
3+
## Overview
4+
5+
The configuration provided in this folder contains the setup of an ABAP environment in an existing subaccount. The assumption is that the subaccount already has the right entitlements to create an ABAP environment assigned to it.
6+
7+
You have three options to deploy the resources:
8+
9+
1. You can create a new CF environment including the CF space for the ABAP environment.
10+
1. You can an existing CF environment and create a new CF space for the ABAP environment.
11+
1. You can use an existing CF environment and an existing CF space for the ABAP environment.
12+
13+
The variable values must be provided correspondingly in the `terraform.tfvars` file. We will provide the relevant parameters for each of the three options in the following sections. Be aware to also add the other required parameters like `globalaccount` and `cf_landscape`.
14+
15+
### Option 1: Create a new CF environment including the CF space for the ABAP environment
16+
17+
The `terraform.tfvars` file should look like this:
18+
19+
```terraform
20+
create_cf_org = true
21+
create_cf_space = true
22+
project_name = "my-abap-project"
23+
cf_space_name = "dev"
24+
cf_space_developers = ["[email protected]"]
25+
cf_space_managers = ["[email protected]"]
26+
```
27+
28+
### Option 2: Use an existing CF environment and create a new CF space for the ABAP environment
29+
30+
The `terraform.tfvars` file should look like this:
31+
32+
```terraform
33+
create_cf_space = true
34+
cf_org_id = "ID of the existing CF organization"
35+
cf_space_name = "dev"
36+
cf_space_developers = ["[email protected]"]
37+
cf_space_managers = ["[email protected]"]
38+
```
39+
40+
### Option 3: Use an existing CF environment and an existing CF space for the ABAP environment
41+
42+
The `terraform.tfvars` file should look like this:
43+
44+
```terraform
45+
cf_org_id = "ID of the existing CF organization"
46+
cf_space_name = "Name of the existing CF space"
47+
```
48+
49+
## Deploying the resources
50+
51+
To deploy the resources you must:
52+
53+
1. Configure the provider in the `provider.tf` file
54+
2. Initialize your workspace:
55+
56+
```bash
57+
terraform init
58+
```
59+
60+
3. You can check what Terraform plans to apply based on your configuration:
61+
62+
```bash
63+
terraform plan -var-file="terraform.tfvars"
64+
```
65+
66+
4. Apply your configuration to provision the resources:
67+
68+
```bash
69+
terraform apply -var-file="terraform.tfvars"
70+
```
71+
72+
## When finished
73+
74+
You probably want to remove the assets after trying them out to avoid unnecessary costs. To do so execute the following command:
75+
76+
```bash
77+
terraform destroy -var-file="terraform.tfvars"
78+
```

Diff for: released/usecases/abap_env_in_subaccount/main.tf

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
###
2+
# Setup of names based on variables
3+
###
4+
locals {
5+
project_subaccount_cf_org = var.create_cf_org ? "CF-${var.project_name}-${var.abap_sid}" : ""
6+
abap_service_instance_name = "abap-${var.abap_sid}"
7+
}
8+
9+
###
10+
# Subscription to the ABAP web access
11+
###
12+
resource "btp_subaccount_subscription" "abap_web_access" {
13+
subaccount_id = var.subaccount_id
14+
app_name = "abapcp-web-router"
15+
plan_name = "default"
16+
}
17+
18+
19+
###
20+
# Creation of Cloud Foundry environment
21+
###
22+
module "cloudfoundry_environment" {
23+
count = var.create_cf_org ? 1 : 0
24+
source = "../../modules/environment/cloudfoundry/envinstance_cf"
25+
26+
subaccount_id = var.subaccount_id
27+
instance_name = local.project_subaccount_cf_org
28+
environment_label = "cf-${var.cf_landscape}"
29+
cf_org_name = local.project_subaccount_cf_org
30+
cf_org_managers = []
31+
cf_org_billing_managers = []
32+
cf_org_auditors = []
33+
}
34+
35+
36+
###
37+
# Creation of CF space
38+
###
39+
module "cloudfoundry_space" {
40+
count = var.create_cf_space ? 1 : 0
41+
source = "../../modules/environment/cloudfoundry/space_cf"
42+
cf_org_id = var.create_cf_org ? module.cloudfoundry_environment[0].cf_org_id : var.cf_org_id
43+
name = var.cf_space_name
44+
cf_space_managers = var.cf_space_managers
45+
cf_space_developers = var.cf_space_developers
46+
cf_space_auditors = []
47+
}
48+
49+
# Fetch the space data for having one source of the space ID
50+
data "cloudfoundry_space" "cf_space_data" {
51+
name = var.cf_space_name
52+
org = var.cf_org_id
53+
depends_on = [module.cloudfoundry_space]
54+
}
55+
56+
###
57+
# Artificial timeout for entitlement propagation to CF Marketplace
58+
###
59+
resource "time_sleep" "wait_a_few_seconds" {
60+
count = var.create_cf_space ? 1 : 0
61+
depends_on = [data.cloudfoundry_space.cf_space_data]
62+
create_duration = "30s"
63+
}
64+
65+
66+
###
67+
# Creation of service instance for ABAP
68+
###
69+
data "cloudfoundry_service" "abap_service_plans" {
70+
name = "abap"
71+
depends_on = [time_sleep.wait_a_few_seconds]
72+
}
73+
74+
75+
resource "cloudfoundry_service_instance" "abap_si" {
76+
name = local.abap_service_instance_name
77+
space = data.cloudfoundry_space.cf_space_data.id
78+
service_plan = data.cloudfoundry_service.abap_service_plans.service_plans[var.abap_si_plan]
79+
json_params = jsonencode({
80+
admin_email = "${var.abap_admin_email}"
81+
is_development_allowed = "${var.abap_is_development_allowed}"
82+
sapsystemname = "${var.abap_sid}"
83+
size_of_runtime = "${var.abap_compute_unit_quota}"
84+
size_of_persistence = "${var.hana_compute_unit_quota}"
85+
size_of_persistence_disk = "auto"
86+
login_attribute = "email"
87+
})
88+
timeouts {
89+
create = "2h"
90+
delete = "2h"
91+
update = "2h"
92+
}
93+
}
94+
95+
96+
###
97+
# Creation of service key for ABAP Development Tools (ADT)
98+
###
99+
resource "cloudfoundry_service_key" "abap_adtkey" {
100+
name = "${var.abap_sid}_adtkey"
101+
service_instance = cloudfoundry_service_instance.abap_si.id
102+
}
103+
104+
105+
###
106+
# Creation of service key for COMM Arrangement
107+
###
108+
resource "cloudfoundry_service_key" "abap_ipskey" {
109+
name = "${var.abap_sid}_ipskey"
110+
service_instance = cloudfoundry_service_instance.abap_si.id
111+
params_json = jsonencode({
112+
scenario_id = "SAP_COM_0193"
113+
type = "basic"
114+
})
115+
}
116+
117+
###
118+
# Setup Trust Configuration
119+
###
120+
#resource "btp_subaccount_trust_configuration" "subaccount_trust_abap" {
121+
# subaccount_id = btp_subaccount.abap-subaccount.id
122+
# identity_provider = var.custom_idp
123+
#}

Diff for: released/usecases/abap_env_in_subaccount/provider.tf

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
terraform {
3+
required_providers {
4+
btp = {
5+
source = "sap/btp"
6+
version = "1.3.0"
7+
}
8+
cloudfoundry = {
9+
source = "cloudfoundry-community/cloudfoundry"
10+
version = "0.53.1"
11+
}
12+
}
13+
14+
}
15+
16+
# Please checkout documentation on how best to authenticate against SAP BTP
17+
# via the Terraform provider for SAP BTP
18+
provider "btp" {
19+
globalaccount = var.globalaccount
20+
}
21+
22+
# This will only work if we know the region in advance
23+
provider "cloudfoundry" {
24+
api_url = "https://api.cf.${var.cf_landscape}.hana.ondemand.com"
25+
}
+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
variable "globalaccount" {
2+
type = string
3+
description = "The global account subdomain."
4+
}
5+
6+
variable "subaccount_id" {
7+
type = string
8+
description = "The ID of the subaccount."
9+
}
10+
11+
variable "cf_landscape" {
12+
type = string
13+
description = "The Cloud Foundry landscape (format example eu10-004)."
14+
default = "eu10-004"
15+
}
16+
17+
variable "abap_sid" {
18+
type = string
19+
description = "The system ID (SID) of the ABAP system."
20+
}
21+
22+
variable "abap_admin_email" {
23+
type = string
24+
description = "Email of the ABAP Administrator."
25+
}
26+
27+
variable "abap_si_plan" {
28+
type = string
29+
description = "Plan for the service instance of ABAP."
30+
default = "standard"
31+
}
32+
33+
variable "abap_compute_unit_quota" {
34+
type = number
35+
description = "The amount of ABAP compute units to be assigned to the subaccount."
36+
default = 1
37+
}
38+
39+
variable "hana_compute_unit_quota" {
40+
type = number
41+
description = "The amount of ABAP compute units to be assigned to the subaccount."
42+
default = 2
43+
}
44+
45+
variable "abap_is_development_allowed" {
46+
type = bool
47+
description = "Flag to define if development on the ABAP system is allowed."
48+
default = true
49+
}
50+
51+
###
52+
# Variable block relevant for the creation of a Cloud Foundry organization and space
53+
###
54+
variable "create_cf_org" {
55+
type = bool
56+
description = "Flag to define if a Cloud Foundry organization should be created."
57+
default = false
58+
}
59+
60+
variable "create_cf_space" {
61+
type = bool
62+
description = "Flag to define if a Cloud Foundry space should be created."
63+
default = false
64+
}
65+
66+
variable "project_name" {
67+
type = string
68+
description = "The name of the project. Used as part of the name for the Cloud Foundry Org"
69+
default = "my-abap-project"
70+
}
71+
72+
variable "cf_space_name" {
73+
type = string
74+
description = "The name of the Cloud Foundry space. Only relevant if the space is created."
75+
default = "dev"
76+
}
77+
78+
variable "cf_space_developers" {
79+
type = list(string)
80+
description = "List of developers for the Cloud Foundry space. Only relevant if the space is created."
81+
default = []
82+
}
83+
84+
variable "cf_space_managers" {
85+
type = list(string)
86+
description = "List of managers for the Cloud Foundry space. Only relevant if the space is created."
87+
default = []
88+
}
89+
90+
###
91+
# Variable block relevant for usage of existing CF organization and space
92+
###
93+
variable "cf_org_id" {
94+
type = string
95+
description = "The ID of the Cloud Foundry organization."
96+
default = ""
97+
}
98+
99+
#variable "custom_idp" {
100+
# type = string
101+
# description = "Name of custom IDP to be used for the subaccount"
102+
#}

Diff for: released/usecases/abap_env_setup/README.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22

33
## Overview
44

5-
tbd
6-
7-
## Content of setup
8-
9-
tbd
5+
This directory contains the setup of an ABAP environment from scratch namely a new subaccount including the relevant entitlements, a Cloud Foundry environment and a Cloud Foundry space.
106

117
## Deploying the resources
128

Diff for: released/usecases/abap_env_setup/provider.tf

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ terraform {
1717
# via the Terraform provider for SAP BTP
1818
provider "btp" {
1919
globalaccount = var.globalaccount
20-
#cli_server_url = "https://canary.cli.btp.int.sap"
2120
}
2221

2322
# This will only work if we know the region in advance

0 commit comments

Comments
 (0)