From 1f3dc215e0bf6237b24852e3ea601d1ee345b7d8 Mon Sep 17 00:00:00 2001
From: Mahesh kumar Palavalli
Date: Thu, 11 Jul 2024 21:02:30 +0530
Subject: [PATCH 1/2] [NEW] dc misison 3945
---
.../discovery_center/mission_3945/README.md | 52 ++++++++
.../discovery_center/mission_3945/locals.tf | 3 +
.../discovery_center/mission_3945/main.tf | 96 +++++++++++++++
.../discovery_center/mission_3945/outputs.tf | 4 +
.../discovery_center/mission_3945/provider.tf | 16 +++
.../mission_3945/sample.tfvars | 24 ++++
.../mission_3945/variables.tf | 113 ++++++++++++++++++
7 files changed, 308 insertions(+)
create mode 100644 released/discovery_center/mission_3945/README.md
create mode 100644 released/discovery_center/mission_3945/locals.tf
create mode 100644 released/discovery_center/mission_3945/main.tf
create mode 100644 released/discovery_center/mission_3945/outputs.tf
create mode 100644 released/discovery_center/mission_3945/provider.tf
create mode 100644 released/discovery_center/mission_3945/sample.tfvars
create mode 100644 released/discovery_center/mission_3945/variables.tf
diff --git a/released/discovery_center/mission_3945/README.md b/released/discovery_center/mission_3945/README.md
new file mode 100644
index 00000000..f934fded
--- /dev/null
+++ b/released/discovery_center/mission_3945/README.md
@@ -0,0 +1,52 @@
+# Accelerate Financial Planning and Analysis (3945)
+
+## Overview
+
+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/),
+
+## Setup
+
+To deploy the resources you must:
+
+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.
+
+ ```bash
+ Mac & Linux
+ export BTP_USERNAME=
+ export BTP_PASSWORD=
+
+ Windows(PS)
+ $env:BTP_USERNAME=
+ $env:BTP_PASSWORD=
+ ```
+
+2. Change the variables in the `samples.tfvars` file to meet your requirements
+
+ > ⚠ 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: jane.doe@test.com`.
+
+
+3. Initialize your workspace:
+
+ ```bash
+ terraform init
+ ```
+
+4. You can check what Terraform plans to apply based on your configuration:
+
+ ```bash
+ terraform plan -var-file="samples.tfvars"
+ ```
+
+5. Apply your configuration to provision the resources:
+
+ ```bash
+ terraform apply -var-file="samples.tfvars"
+ ```
+
+## In the end
+
+You probably want to remove the assets after trying them out to avoid unnecessary costs. To do so execute the following command:
+
+```bash
+terraform destroy
+```
diff --git a/released/discovery_center/mission_3945/locals.tf b/released/discovery_center/mission_3945/locals.tf
new file mode 100644
index 00000000..a1622f7d
--- /dev/null
+++ b/released/discovery_center/mission_3945/locals.tf
@@ -0,0 +1,3 @@
+locals {
+ service_name__sap_analytics_cloud = "analytics-planning-osb"
+}
\ No newline at end of file
diff --git a/released/discovery_center/mission_3945/main.tf b/released/discovery_center/mission_3945/main.tf
new file mode 100644
index 00000000..5f359621
--- /dev/null
+++ b/released/discovery_center/mission_3945/main.tf
@@ -0,0 +1,96 @@
+# ------------------------------------------------------------------------------------------------------
+# Setup of names in accordance to naming convention
+# ------------------------------------------------------------------------------------------------------
+resource "random_uuid" "uuid" {}
+
+locals {
+ random_uuid = random_uuid.uuid.result
+ subaccount_domain = lower(replace("mission-3945-${local.random_uuid}", "_", "-"))
+}
+
+# ------------------------------------------------------------------------------------------------------
+# Creation of subaccount
+# ------------------------------------------------------------------------------------------------------
+resource "btp_subaccount" "dc_mission" {
+ count = var.subaccount_id == "" ? 1 : 0
+ name = var.subaccount_name
+ subdomain = local.subaccount_domain
+ region = lower(var.region)
+ usage = "USED_FOR_PRODUCTION"
+}
+
+data "btp_subaccount" "dc_mission" {
+ id = var.subaccount_id != "" ? var.subaccount_id : btp_subaccount.dc_mission[0].id
+}
+
+# ------------------------------------------------------------------------------------------------------
+# Assign custom IDP to sub account (if custom_idp is set)
+# ------------------------------------------------------------------------------------------------------
+resource "btp_subaccount_trust_configuration" "fully_customized" {
+ # Only create trust configuration if custom_idp has been set
+ count = var.custom_idp == "" ? 0 : 1
+ subaccount_id = data.btp_subaccount.dc_mission.id
+ identity_provider = var.custom_idp
+}
+
+
+# ------------------------------------------------------------------------------------------------------
+# Assignment of users as sub account administrators
+# ------------------------------------------------------------------------------------------------------
+resource "btp_subaccount_role_collection_assignment" "subaccount-admins" {
+ for_each = toset(var.subaccount_admins)
+ subaccount_id = data.btp_subaccount.dc_mission.id
+ role_collection_name = "Subaccount Administrator"
+ user_name = each.value
+}
+
+# ------------------------------------------------------------------------------------------------------
+# Assignment of users as sub account service administrators
+# ------------------------------------------------------------------------------------------------------
+resource "btp_subaccount_role_collection_assignment" "subaccount-service-admins" {
+ for_each = toset(var.subaccount_service_admins)
+ subaccount_id = data.btp_subaccount.dc_mission.id
+ role_collection_name = "Subaccount Service Administrator"
+ user_name = each.value
+}
+
+# ------------------------------------------------------------------------------------------------------
+# Setup SAP Analytics Cloud (not running in CF environment)
+# ------------------------------------------------------------------------------------------------------
+# Entitle
+resource "btp_subaccount_entitlement" "sac" {
+ subaccount_id = data.btp_subaccount.dc_mission.id
+ service_name = local.service_name__sap_analytics_cloud
+ plan_name = var.service_plan__sap_analytics_cloud
+}
+# Get serviceplan_id for data-analytics-osb with plan_name "standard"
+data "btp_subaccount_service_plan" "sac" {
+ subaccount_id = data.btp_subaccount.dc_mission.id
+ offering_name = local.service_name__sap_analytics_cloud
+ name = var.service_plan__sap_analytics_cloud
+ depends_on = [btp_subaccount_entitlement.sac]
+}
+
+# Create service instance
+resource "btp_subaccount_service_instance" "sac" {
+ subaccount_id = data.btp_subaccount.dc_mission.id
+ serviceplan_id = data.btp_subaccount_service_plan.sac.id
+ name = "sac_instance"
+ parameters = jsonencode(
+ {
+ "first_name" : "${var.sac_admin_first_name}",
+ "last_name" : "${var.sac_admin_last_name}",
+ "email" : "${var.sac_admin_email}",
+ "confirm_email" : "${var.sac_admin_email}",
+ "host_name" : "${var.sac_admin_host_name}",
+ "number_of_business_intelligence_licenses" : var.sac_number_of_business_intelligence_licenses,
+ "number_of_planning_professional_licenses" : var.sac_number_of_professional_licenses,
+ "number_of_planning_standard_licenses" : var.sac_number_of_business_standard_licenses
+ }
+ )
+ timeouts = {
+ create = "90m"
+ update = "90m"
+ delete = "90m"
+ }
+}
\ No newline at end of file
diff --git a/released/discovery_center/mission_3945/outputs.tf b/released/discovery_center/mission_3945/outputs.tf
new file mode 100644
index 00000000..a7f92a50
--- /dev/null
+++ b/released/discovery_center/mission_3945/outputs.tf
@@ -0,0 +1,4 @@
+output "subaccount_id" {
+ value = data.btp_subaccount.dc_mission.id
+ description = "The ID of the subaccount."
+}
diff --git a/released/discovery_center/mission_3945/provider.tf b/released/discovery_center/mission_3945/provider.tf
new file mode 100644
index 00000000..7170b3fb
--- /dev/null
+++ b/released/discovery_center/mission_3945/provider.tf
@@ -0,0 +1,16 @@
+
+terraform {
+ required_providers {
+ btp = {
+ source = "sap/btp"
+ version = "~> 1.4.0"
+ }
+ }
+}
+
+# Please checkout documentation on how best to authenticate against SAP BTP
+# via the Terraform provider for SAP BTP
+provider "btp" {
+ globalaccount = var.globalaccount
+ cli_server_url = var.cli_server_url
+}
diff --git a/released/discovery_center/mission_3945/sample.tfvars b/released/discovery_center/mission_3945/sample.tfvars
new file mode 100644
index 00000000..bac52085
--- /dev/null
+++ b/released/discovery_center/mission_3945/sample.tfvars
@@ -0,0 +1,24 @@
+# ------------------------------------------------------------------------------------------------------
+# Provider configuration
+# ------------------------------------------------------------------------------------------------------
+# Your global account subdomain
+globalaccount = "youraccount"
+region = "us10"
+subaccount_name = "SAP Discovery Center Mission 3945"
+cf_environment_label = "cf-us10"
+cf_space_name = "dev"
+
+# ------------------------------------------------------------------------------------------------------
+# Project specific configuration (please adapt!)
+# ------------------------------------------------------------------------------------------------------
+# Don't add the user, that is executing the TF script to subaccount_admins or subaccount_service_admins!
+
+subaccount_admins = ["jane.doe@test.com", "john.doe@test.com"]
+subaccount_service_admins = ["jane.doe@test.com", "john.doe@test.com"]
+
+sac_admin_first_name = "First Name"
+sac_admin_last_name = "Last Name"
+sac_admin_email = "jane.doe@test.com"
+
+service_plan__sap_analytics_cloud = "production"
+
diff --git a/released/discovery_center/mission_3945/variables.tf b/released/discovery_center/mission_3945/variables.tf
new file mode 100644
index 00000000..54e4f946
--- /dev/null
+++ b/released/discovery_center/mission_3945/variables.tf
@@ -0,0 +1,113 @@
+######################################################################
+# Customer account setup
+######################################################################
+# subaccount
+variable "globalaccount" {
+ type = string
+ description = "The globalaccount subdomain."
+ default = "yourglobalaccount"
+}
+# subaccount
+variable "subaccount_name" {
+ type = string
+ description = "The subaccount name."
+ default = "DC Mission 43945"
+}
+
+# subaccount id
+variable "subaccount_id" {
+ type = string
+ description = "The subaccount ID."
+ default = ""
+}
+
+# Region
+variable "region" {
+ type = string
+ description = "The region where the project account shall be created in."
+ default = "us10"
+}
+
+# CLI server
+variable "cli_server_url" {
+ type = string
+ description = "The BTP CLI server URL."
+ default = "https://cli.btp.cloud.sap"
+}
+
+variable "custom_idp" {
+ type = string
+ description = "Defines the custom IdP"
+ default = ""
+}
+
+variable "subaccount_admins" {
+ type = list(string)
+ description = "Defines the colleagues who are added to each subaccount as subaccount administrators."
+ default = ["jane.doe@test.com", "john.doe@test.com"]
+}
+
+variable "subaccount_service_admins" {
+ type = list(string)
+ description = "Defines the colleagues who are added to each subaccount as subaccount service administrators."
+ default = ["jane.doe@test.com", "john.doe@test.com"]
+}
+
+# service plan sap analytics cloud
+variable "service_plan__sap_analytics_cloud" {
+ type = string
+ description = "The service plan for the SAP Analytics Cloud."
+ default = "free"
+ validation {
+ condition = contains(["free", "production"], var.service_plan__sap_analytics_cloud)
+ error_message = "Invalid value for service_plan__sap_analytics_cloud. Only 'free' & 'production' are allowed."
+ }
+}
+
+# SAC User Info
+
+# first name
+variable "sac_admin_first_name" {
+ type = string
+ description = "SAC Admin First Name"
+ default = "first name"
+}
+
+# last name
+variable "sac_admin_last_name" {
+ type = string
+ description = "SAC Admin Last Name"
+ default = "last name"
+}
+
+# email
+variable "sac_admin_email" {
+ type = string
+ description = "SAC Admin Email"
+}
+
+# host_name
+variable "sac_admin_host_name" {
+ type = string
+ description = "SAC Admin Host Name"
+ default = ""
+}
+
+variable "sac_number_of_business_intelligence_licenses" {
+ type = number
+ description = "Number of business intelligence licenses"
+ default = 25
+}
+
+
+variable "sac_number_of_professional_licenses" {
+ type = number
+ description = "Number of business professional licenses"
+ default = 1
+}
+
+variable "sac_number_of_business_standard_licenses" {
+ type = number
+ description = "Number of business standard licenses"
+ default = 10
+}
From d0b3287967bcc7049538805f6e926904a61802e7 Mon Sep 17 00:00:00 2001
From: Mahesh kumar Palavalli
Date: Thu, 11 Jul 2024 21:18:06 +0530
Subject: [PATCH 2/2] default value fix
---
released/discovery_center/mission_3945/variables.tf | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/released/discovery_center/mission_3945/variables.tf b/released/discovery_center/mission_3945/variables.tf
index 54e4f946..88dacd45 100644
--- a/released/discovery_center/mission_3945/variables.tf
+++ b/released/discovery_center/mission_3945/variables.tf
@@ -11,7 +11,7 @@ variable "globalaccount" {
variable "subaccount_name" {
type = string
description = "The subaccount name."
- default = "DC Mission 43945"
+ default = "DC Mission 3945"
}
# subaccount id