Skip to content

[NEW] dc misison 3945 #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions released/discovery_center/mission_3945/README.md
Original file line number Diff line number Diff line change
@@ -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=<your_username>
export BTP_PASSWORD=<your_password>

Windows(PS)
$env:BTP_USERNAME=<your_username>
$env:BTP_PASSWORD=<your_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
```
3 changes: 3 additions & 0 deletions released/discovery_center/mission_3945/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
locals {
service_name__sap_analytics_cloud = "analytics-planning-osb"
}
96 changes: 96 additions & 0 deletions released/discovery_center/mission_3945/main.tf
Original file line number Diff line number Diff line change
@@ -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"
}
}
4 changes: 4 additions & 0 deletions released/discovery_center/mission_3945/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "subaccount_id" {
value = data.btp_subaccount.dc_mission.id
description = "The ID of the subaccount."
}
16 changes: 16 additions & 0 deletions released/discovery_center/mission_3945/provider.tf
Original file line number Diff line number Diff line change
@@ -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
}
24 changes: 24 additions & 0 deletions released/discovery_center/mission_3945/sample.tfvars
Original file line number Diff line number Diff line change
@@ -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"

113 changes: 113 additions & 0 deletions released/discovery_center/mission_3945/variables.tf
Original file line number Diff line number Diff line change
@@ -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 3945"
}

# 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
}