Skip to content

3774 stc mission #180

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 27 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e87b20c
adding README.md
fabianleh May 30, 2024
ed22e76
adding tf scripts
fabianleh May 31, 2024
94a4b93
fix typo
fabianleh May 31, 2024
67ae8bb
updating stc mission step 1 tested succesful, step 2 missing docu
fabianleh Jun 26, 2024
ac12fe8
moving space creation in step 2
fabianleh Jun 26, 2024
1206485
update output
fabianleh Jun 26, 2024
26e4966
Merge branch 'main' into 3774_stc_mission
lechnerc77 Jun 26, 2024
8bdd235
removing cf provider
fabianleh Jun 26, 2024
58b66b0
Merge branch '3774_stc_mission' of https://github.com/fabianleh/btp-t…
fabianleh Jun 26, 2024
a06ba7f
update provider.tf step 2
fabianleh Jun 26, 2024
16d823a
Update in-development/mission_3774_sap_task_center/step_2/variables.tf
fabianleh Jun 26, 2024
3cc4820
update provider.tf step2
fabianleh Jun 26, 2024
f067355
removing sap.ids
fabianleh Jun 26, 2024
438bc43
updating cf api url
fabianleh Jun 26, 2024
a896d1f
update variables.tf
fabianleh Jun 26, 2024
6ba20fc
updateing step 1 and minor step 2 changes
fabianleh Jun 26, 2024
64427f6
updating sample.tfcars
fabianleh Jun 26, 2024
92da6ef
format fix
fabianleh Jun 26, 2024
0977c07
fix typo
fabianleh Jun 26, 2024
c532a44
removing duplicate space creation in main.tf
fabianleh Jun 26, 2024
918c9c7
updating step 2
fabianleh Jun 26, 2024
b85838d
fix space def.
fabianleh Jun 26, 2024
67b7af2
subacc id fix
fabianleh Jun 26, 2024
69bddc3
destination creation fix
fabianleh Jun 26, 2024
8ef41e7
fix: validation step2
lechnerc77 Jun 26, 2024
07ce54f
resolve merge
lechnerc77 Jun 26, 2024
0991996
validation fixes
lechnerc77 Jun 26, 2024
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
15 changes: 11 additions & 4 deletions in-development/mission_3774_sap_task_center/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## Overview

This sample shows how to setup your SAP BTP account for the Discovery Center Mission - [Keep the Core Clean Using SAP Build Apps with SAP S/4HANA](https://discovery-center.cloud.sap/index.html#/missiondetail/3774/)
This sample shows how to setup your SAP BTP account for the Discovery Center Mission - [Establish a Central Inbox with SAP Task Center](https://discovery-center.cloud.sap/index.html#/missiondetail/3774/)


## Content of setup

Expand All @@ -11,7 +12,7 @@ The setup comprises the following resources:
- Creation of the SAP BTP subaccount
- Entitlements of services
- Subscriptions to applications
- Creation of service instances
- Creation of service instance
- Role collection assignments to users

## Deploying the resources
Expand All @@ -27,11 +28,17 @@ To deploy the resources you must:
export BTP_PASSWORD=<your_password>
```

2. Change the variables in the `common_sample.tfvars` file to meet your requirements
2. Set the environment variables CF_USERNAME and CF_PASSWORD to pass credentials to the CF provider to authenticate and interact with your CF environment.

```bash
export CF_USER=<your_username>
export CF_PASSWORD=<your_password>
```

3. Change the variables in the `common_sample.tfvars` file to meet your requirements

> The minimal set of parameters you should specify (beside user_email and password) is globalaccount (i.e. its subdomain) and the used custom_idp.

3. Switch to the `1_main_config` folder

4. Change the variables in `sample.tfvars` file to meet your requirements

Expand Down
48 changes: 48 additions & 0 deletions in-development/mission_3774_sap_task_center/step_1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Sample Setup of an SAP Task Center on SAP BTP - Step 1

## Overview

This directory contains the setup of SAP Task Center from scratch namely a new subaccount including the relevant entitlements, a Cloud Foundry environment and a Cloud Foundry space.

This directory contains the configuration the first step of the setup namely:

- a new subaccount
- the entitlements for SAP Task Center
- the subscription for SAP Build Workzone, standard edition
- the Cloud Foundry environment
- The trust setup to the custom IdP
- Assignment of users to the role collections

## Deploying the resources

To deploy the resources of step 1 execute the following commands:

1. Initialize your workspace:

```bash
terraform init
```

1. Assign the variable values in a `*.tfvars` file e.g., the global account subdomain

1. You can check what Terraform plans to apply based on your configuration:

```bash
terraform plan -var-file="<name of your tfvars file>.tfvars"
```

1. Apply your configuration to provision the resources:

```bash
terraform apply -var-file="<name of your tfvars file>.tfvars"
```

> **Note** - Some variables of the output of the first step are needed as input for the second step.

## When finished

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 -var-file="<name of your tfvars file>.tfvars"
```
4 changes: 4 additions & 0 deletions in-development/mission_3774_sap_task_center/step_1/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
locals {
service_name__sap_task_center = "one-inbox-service"
service_name__build_workzone = "SAPLaunchpad"
}
86 changes: 86 additions & 0 deletions in-development/mission_3774_sap_task_center/step_1/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
###############################################################################################
# Setup of names in accordance to naming convention
###############################################################################################
resource "random_uuid" "uuid" {}

locals {
random_uuid = random_uuid.uuid.result
project_subaccount_domain = lower(replace("mission-3774-${local.random_uuid}", "_", "-"))
project_subaccount_cf_org = substr(replace("${local.project_subaccount_domain}", "-", ""), 0, 32)
}
###############################################################################################
# Creation of subaccount
###############################################################################################
resource "btp_subaccount" "project" {
name = var.subaccount_name
subdomain = local.project_subaccount_domain
region = lower(var.region)
}
# ------------------------------------------------------------------------------------------------------
# Assignment of users as sub account administrators
# ------------------------------------------------------------------------------------------------------
resource "btp_subaccount_role_collection_assignment" "subaccount-admins" {
for_each = toset("${var.subaccount_admins}")
subaccount_id = btp_subaccount.project.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 = btp_subaccount.project.id
role_collection_name = "Subaccount Service Administrator"
user_name = each.value
}
######################################################################
# Creation of Cloud Foundry environment
######################################################################
resource "btp_subaccount_environment_instance" "cloudfoundry" {
subaccount_id = btp_subaccount.project.id
name = local.project_subaccount_cf_org
environment_type = "cloudfoundry"
service_name = "cloudfoundry"
plan_name = "standard"
landscape_label = var.cf_environment_label
parameters = jsonencode({
instance_name = local.project_subaccount_cf_org
})
}
###############################################################################################
# Prepare and setup app: SAP Build Workzone, standard edition
###############################################################################################
# Entitle subaccount for usage of app destination SAP Build Workzone, standard edition
resource "btp_subaccount_entitlement" "build_workzone" {
subaccount_id = btp_subaccount.project.id
service_name = local.service_name__build_workzone
plan_name = var.service_plan__build_workzone
amount = var.service_plan__build_workzone == "free" ? 1 : null
}
# Create app subscription to SAP Build Workzone, standard edition (depends on entitlement)
resource "btp_subaccount_subscription" "build_workzone" {
subaccount_id = btp_subaccount.project.id
app_name = local.service_name__build_workzone
plan_name = var.service_plan__build_workzone
depends_on = [btp_subaccount_entitlement.build_workzone]
}
###############################################################################################
# Prepare and setup app: SAP Task Center
###############################################################################################
# Entitle subaccount for usage of app destination SAP Task Center
resource "btp_subaccount_entitlement" "taskcenter" {
subaccount_id = btp_subaccount.project.id
service_name = local.service_name__sap_task_center
plan_name = "standard"
}
# ------------------------------------------------------------------------------------------------------
# Assignment of users as launchpad administrators
# ------------------------------------------------------------------------------------------------------
resource "btp_subaccount_role_collection_assignment" "launchpad-admins" {
for_each = toset("${var.launchpad_admins}")
subaccount_id = btp_subaccount.project.id
role_collection_name = "Launchpad_Admin"
user_name = each.value
depends_on = [btp_subaccount_subscription.build_workzone]
}
24 changes: 24 additions & 0 deletions in-development/mission_3774_sap_task_center/step_1/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
output "subaccount_id" {
value = btp_subaccount.project.id
description = "The ID of the project subaccount."
}

output "cf_org_name" {
value = local.project_subaccount_cf_org
description = "The name of the project subaccount."
}

output "cf_org_id" {
value = btp_subaccount_environment_instance.cloudfoundry.landscape_label
description = "The ID of the Cloud Foundry environment."
}

output "cf_api_endpoint" {
value = jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels)["API Endpoint"]
description = "API endpoint of the Cloud Foundry environment."
}

output "cf_landscape_label" {
value = btp_subaccount_environment_instance.cloudfoundry.platform_id
description = "The landscape label of the Cloud Foundry environment."
}
14 changes: 14 additions & 0 deletions in-development/mission_3774_sap_task_center/step_1/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
###
# Define the required providers for this module
###
terraform {
required_providers {
btp = {
source = "sap/btp"
}
}
}
provider "btp" {
globalaccount = var.globalaccount
cli_server_url = var.cli_server_url
}
17 changes: 17 additions & 0 deletions in-development/mission_3774_sap_task_center/step_1/sample.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# ------------------------------------------------------------------------------------------------------
# Provider configuration
# ------------------------------------------------------------------------------------------------------
# Your global account subdomain
globalaccount = "yourglobalaccount"
region = "datacenter"
subaccount_name = "subaccount_name"
cf_environment_label = "cf_environment_label"

# ------------------------------------------------------------------------------------------------------
# Project specific configuration (please adapt!)
# ------------------------------------------------------------------------------------------------------

subaccount_admins = ["jane.doe@test.com", "john.doe@test.com"]
subaccount_service_admins = ["jane.doe@test.com", "john.doe@test.com"]
custom_idp = "your custom idp"
launchpad_admins = ["jane.doe@test.com", "john.doe@test.com"]
89 changes: 89 additions & 0 deletions in-development/mission_3774_sap_task_center/step_1/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
######################################################################
# Customer account setup
######################################################################
variable "globalaccount" {
type = string
description = "Defines the global account"
default = "yourglobalaccount"
}

variable "cli_server_url" {
type = string
description = "Defines the CLI server URL"
default = "https://cli.btp.cloud.sap"
}

# subaccount
variable "subaccount_name" {
type = string
description = "The subaccount name."
default = "UC - Establish a Central Inbox with SAP Task Center"
}
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"
}
# Cloudfoundry environment label
variable "cf_environment_label" {
type = string
description = "The Cloudfoundry environment label"
default = "cf-us10"
}

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"]
}

variable "launchpad_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"]
}

variable "custom_idp" {
type = string
description = "Defines the custom IdP"
default = ""
}

variable "environment_label" {
type = string
description = "In case there are multiple environments available for a subaccount, you can use this label to choose with which one you want to go. If nothing is given, we take by default the first available."
default = "cf-us10"
}

variable "cf_org_name" {
type = string
description = "Name of the Cloud Foundry org."
default = "mission-3774-sap-task-center"

validation {
condition = can(regex("^.{1,255}$", var.cf_org_name))
error_message = "The Cloud Foundry org name must not be emtpy and not exceed 255 characters."
}
}

variable "service_plan__build_workzone" {
type = string
description = "The plan for build_workzone subscription"
default = "free"
validation {
condition = contains(["free", "standard"], var.service_plan__build_workzone)
error_message = "Invalid value for service_plan__build_workzone. Only 'free' and 'standard' are allowed."
}
}
44 changes: 44 additions & 0 deletions in-development/mission_3774_sap_task_center/step_2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Sample Setup of an SAP Task Center on SAP BTP - Step 2

## Overview

This directory contains the setup of SAP Task Center from scratch namely a new subaccount including the relevant entitlements, a Cloud Foundry environment and a Cloud Foundry space.

This directory contains the configuration the first step of the setup namely:

- Creation of service instance for SAP Task Center
- Creation of the service key for the service instance

## Deploying the resources

To deploy the resources of step 1 execute the following commands:

1. Initialize your workspace:

```bash
terraform init
```

1. Assign the variable values in a `*.tfvars` file e.g., the global account subdomain

1. You can check what Terraform plans to apply based on your configuration:

```bash
terraform plan -var-file="<name of your tfvars file>.tfvars"
```

1. Apply your configuration to provision the resources:

```bash
terraform apply -var-file="<name of your tfvars file>.tfvars"
```

> **Note** - Some variables of the output of the first step are needed as input for the second step.

## When finished

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 -var-file="<name of your tfvars file>.tfvars"
```
Loading