Skip to content

Commit 95cf622

Browse files
mahesh0431rui1610
andauthored
[NEW] dc misison 3945 (#255)
* [NEW] dc misison 3945 * default value fix --------- Co-authored-by: Rui Nogueira <[email protected]>
1 parent 197bd18 commit 95cf622

File tree

7 files changed

+308
-0
lines changed

7 files changed

+308
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Accelerate Financial Planning and Analysis (3945)
2+
3+
## Overview
4+
5+
This sample shows how to create a landscape for the Discovery Center Mission "Accelerate Financial Planning and Analysis" - [Discovery Center Mission](https://discovery-center.cloud.sap/missiondetail/3945/),
6+
7+
## Setup
8+
9+
To deploy the resources you must:
10+
11+
1. Set the environment variables BTP_USERNAME and BTP_PASSWORD to pass credentials to the BTP provider to authenticate and interact with your BTP environments.
12+
13+
```bash
14+
Mac & Linux
15+
export BTP_USERNAME=<your_username>
16+
export BTP_PASSWORD=<your_password>
17+
18+
Windows(PS)
19+
$env:BTP_USERNAME=<your_username>
20+
$env:BTP_PASSWORD=<your_password>
21+
```
22+
23+
2. Change the variables in the `samples.tfvars` file to meet your requirements
24+
25+
> ⚠ NOTE: You should pay attention **specifically** to the users defined in the samples.tfvars whether they already exist in your SAP BTP accounts. Otherwise you might get error messages like e.g. `Error: The user could not be found: [email protected]`.
26+
27+
28+
3. Initialize your workspace:
29+
30+
```bash
31+
terraform init
32+
```
33+
34+
4. You can check what Terraform plans to apply based on your configuration:
35+
36+
```bash
37+
terraform plan -var-file="samples.tfvars"
38+
```
39+
40+
5. Apply your configuration to provision the resources:
41+
42+
```bash
43+
terraform apply -var-file="samples.tfvars"
44+
```
45+
46+
## In the end
47+
48+
You probably want to remove the assets after trying them out to avoid unnecessary costs. To do so execute the following command:
49+
50+
```bash
51+
terraform destroy
52+
```
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
locals {
2+
service_name__sap_analytics_cloud = "analytics-planning-osb"
3+
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# ------------------------------------------------------------------------------------------------------
2+
# Setup of names in accordance to naming convention
3+
# ------------------------------------------------------------------------------------------------------
4+
resource "random_uuid" "uuid" {}
5+
6+
locals {
7+
random_uuid = random_uuid.uuid.result
8+
subaccount_domain = lower(replace("mission-3945-${local.random_uuid}", "_", "-"))
9+
}
10+
11+
# ------------------------------------------------------------------------------------------------------
12+
# Creation of subaccount
13+
# ------------------------------------------------------------------------------------------------------
14+
resource "btp_subaccount" "dc_mission" {
15+
count = var.subaccount_id == "" ? 1 : 0
16+
name = var.subaccount_name
17+
subdomain = local.subaccount_domain
18+
region = lower(var.region)
19+
usage = "USED_FOR_PRODUCTION"
20+
}
21+
22+
data "btp_subaccount" "dc_mission" {
23+
id = var.subaccount_id != "" ? var.subaccount_id : btp_subaccount.dc_mission[0].id
24+
}
25+
26+
# ------------------------------------------------------------------------------------------------------
27+
# Assign custom IDP to sub account (if custom_idp is set)
28+
# ------------------------------------------------------------------------------------------------------
29+
resource "btp_subaccount_trust_configuration" "fully_customized" {
30+
# Only create trust configuration if custom_idp has been set
31+
count = var.custom_idp == "" ? 0 : 1
32+
subaccount_id = data.btp_subaccount.dc_mission.id
33+
identity_provider = var.custom_idp
34+
}
35+
36+
37+
# ------------------------------------------------------------------------------------------------------
38+
# Assignment of users as sub account administrators
39+
# ------------------------------------------------------------------------------------------------------
40+
resource "btp_subaccount_role_collection_assignment" "subaccount-admins" {
41+
for_each = toset(var.subaccount_admins)
42+
subaccount_id = data.btp_subaccount.dc_mission.id
43+
role_collection_name = "Subaccount Administrator"
44+
user_name = each.value
45+
}
46+
47+
# ------------------------------------------------------------------------------------------------------
48+
# Assignment of users as sub account service administrators
49+
# ------------------------------------------------------------------------------------------------------
50+
resource "btp_subaccount_role_collection_assignment" "subaccount-service-admins" {
51+
for_each = toset(var.subaccount_service_admins)
52+
subaccount_id = data.btp_subaccount.dc_mission.id
53+
role_collection_name = "Subaccount Service Administrator"
54+
user_name = each.value
55+
}
56+
57+
# ------------------------------------------------------------------------------------------------------
58+
# Setup SAP Analytics Cloud (not running in CF environment)
59+
# ------------------------------------------------------------------------------------------------------
60+
# Entitle
61+
resource "btp_subaccount_entitlement" "sac" {
62+
subaccount_id = data.btp_subaccount.dc_mission.id
63+
service_name = local.service_name__sap_analytics_cloud
64+
plan_name = var.service_plan__sap_analytics_cloud
65+
}
66+
# Get serviceplan_id for data-analytics-osb with plan_name "standard"
67+
data "btp_subaccount_service_plan" "sac" {
68+
subaccount_id = data.btp_subaccount.dc_mission.id
69+
offering_name = local.service_name__sap_analytics_cloud
70+
name = var.service_plan__sap_analytics_cloud
71+
depends_on = [btp_subaccount_entitlement.sac]
72+
}
73+
74+
# Create service instance
75+
resource "btp_subaccount_service_instance" "sac" {
76+
subaccount_id = data.btp_subaccount.dc_mission.id
77+
serviceplan_id = data.btp_subaccount_service_plan.sac.id
78+
name = "sac_instance"
79+
parameters = jsonencode(
80+
{
81+
"first_name" : "${var.sac_admin_first_name}",
82+
"last_name" : "${var.sac_admin_last_name}",
83+
"email" : "${var.sac_admin_email}",
84+
"confirm_email" : "${var.sac_admin_email}",
85+
"host_name" : "${var.sac_admin_host_name}",
86+
"number_of_business_intelligence_licenses" : var.sac_number_of_business_intelligence_licenses,
87+
"number_of_planning_professional_licenses" : var.sac_number_of_professional_licenses,
88+
"number_of_planning_standard_licenses" : var.sac_number_of_business_standard_licenses
89+
}
90+
)
91+
timeouts = {
92+
create = "90m"
93+
update = "90m"
94+
delete = "90m"
95+
}
96+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "subaccount_id" {
2+
value = data.btp_subaccount.dc_mission.id
3+
description = "The ID of the subaccount."
4+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
terraform {
3+
required_providers {
4+
btp = {
5+
source = "sap/btp"
6+
version = "~> 1.4.0"
7+
}
8+
}
9+
}
10+
11+
# Please checkout documentation on how best to authenticate against SAP BTP
12+
# via the Terraform provider for SAP BTP
13+
provider "btp" {
14+
globalaccount = var.globalaccount
15+
cli_server_url = var.cli_server_url
16+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# ------------------------------------------------------------------------------------------------------
2+
# Provider configuration
3+
# ------------------------------------------------------------------------------------------------------
4+
# Your global account subdomain
5+
globalaccount = "youraccount"
6+
region = "us10"
7+
subaccount_name = "SAP Discovery Center Mission 3945"
8+
cf_environment_label = "cf-us10"
9+
cf_space_name = "dev"
10+
11+
# ------------------------------------------------------------------------------------------------------
12+
# Project specific configuration (please adapt!)
13+
# ------------------------------------------------------------------------------------------------------
14+
# Don't add the user, that is executing the TF script to subaccount_admins or subaccount_service_admins!
15+
16+
subaccount_admins = ["[email protected]", "[email protected]"]
17+
subaccount_service_admins = ["[email protected]", "[email protected]"]
18+
19+
sac_admin_first_name = "First Name"
20+
sac_admin_last_name = "Last Name"
21+
sac_admin_email = "[email protected]"
22+
23+
service_plan__sap_analytics_cloud = "production"
24+
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
######################################################################
2+
# Customer account setup
3+
######################################################################
4+
# subaccount
5+
variable "globalaccount" {
6+
type = string
7+
description = "The globalaccount subdomain."
8+
default = "yourglobalaccount"
9+
}
10+
# subaccount
11+
variable "subaccount_name" {
12+
type = string
13+
description = "The subaccount name."
14+
default = "DC Mission 3945"
15+
}
16+
17+
# subaccount id
18+
variable "subaccount_id" {
19+
type = string
20+
description = "The subaccount ID."
21+
default = ""
22+
}
23+
24+
# Region
25+
variable "region" {
26+
type = string
27+
description = "The region where the project account shall be created in."
28+
default = "us10"
29+
}
30+
31+
# CLI server
32+
variable "cli_server_url" {
33+
type = string
34+
description = "The BTP CLI server URL."
35+
default = "https://cli.btp.cloud.sap"
36+
}
37+
38+
variable "custom_idp" {
39+
type = string
40+
description = "Defines the custom IdP"
41+
default = ""
42+
}
43+
44+
variable "subaccount_admins" {
45+
type = list(string)
46+
description = "Defines the colleagues who are added to each subaccount as subaccount administrators."
47+
48+
}
49+
50+
variable "subaccount_service_admins" {
51+
type = list(string)
52+
description = "Defines the colleagues who are added to each subaccount as subaccount service administrators."
53+
54+
}
55+
56+
# service plan sap analytics cloud
57+
variable "service_plan__sap_analytics_cloud" {
58+
type = string
59+
description = "The service plan for the SAP Analytics Cloud."
60+
default = "free"
61+
validation {
62+
condition = contains(["free", "production"], var.service_plan__sap_analytics_cloud)
63+
error_message = "Invalid value for service_plan__sap_analytics_cloud. Only 'free' & 'production' are allowed."
64+
}
65+
}
66+
67+
# SAC User Info
68+
69+
# first name
70+
variable "sac_admin_first_name" {
71+
type = string
72+
description = "SAC Admin First Name"
73+
default = "first name"
74+
}
75+
76+
# last name
77+
variable "sac_admin_last_name" {
78+
type = string
79+
description = "SAC Admin Last Name"
80+
default = "last name"
81+
}
82+
83+
# email
84+
variable "sac_admin_email" {
85+
type = string
86+
description = "SAC Admin Email"
87+
}
88+
89+
# host_name
90+
variable "sac_admin_host_name" {
91+
type = string
92+
description = "SAC Admin Host Name"
93+
default = ""
94+
}
95+
96+
variable "sac_number_of_business_intelligence_licenses" {
97+
type = number
98+
description = "Number of business intelligence licenses"
99+
default = 25
100+
}
101+
102+
103+
variable "sac_number_of_professional_licenses" {
104+
type = number
105+
description = "Number of business professional licenses"
106+
default = 1
107+
}
108+
109+
variable "sac_number_of_business_standard_licenses" {
110+
type = number
111+
description = "Number of business standard licenses"
112+
default = 10
113+
}

0 commit comments

Comments
 (0)