-
Notifications
You must be signed in to change notification settings - Fork 31
Add DC mission 3774 #218
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
Add DC mission 3774 #218
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
74558e8
initial commit
rui1610 ccfa603
add files from folder in_development
rui1610 d6ee249
fine tune step1
rui1610 50175e7
rename folders
rui1610 efb4545
update connection between step1 and step2
rui1610 a1936b9
code clean-up
rui1610 b9ddce9
update format
rui1610 ed94706
Merge branch 'main' into dcmission_3774
rui1610 0100433
Merge branch 'main' into dcmission_3774
rui1610 6ba78b8
update format
rui1610 cd8d227
fix issue with custom_idp and origin
rui1610 6f1143b
rename origin to origin_key
rui1610 d16c314
remove default for custom_idp
rui1610 c996d9d
add description to origin_key and update email address variables
rui1610 612b8af
update comments
rui1610 c0a4eec
Merge branch 'main' into dcmission_3774
lechnerc77 ec8ae10
udpate handling of custom_idp
rui1610 e7357b4
update format
rui1610 14509dd
remove mission in development
rui1610 d4e5f5c
adress review feedback
rui1610 a31f12f
remove unwanted change in different use case
rui1610 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
in-development/mission_3774_sap_task_center/step_1/outputs.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
# ------------------------------------------------------------------------------------------------------ | ||
# Setup of names in accordance to naming convention | ||
# ------------------------------------------------------------------------------------------------------ | ||
resource "random_uuid" "uuid" {} | ||
|
||
locals { | ||
random_uuid = random_uuid.uuid.result | ||
subaccount_domain = lower(replace("mission-3774-${local.random_uuid}", "_", "-")) | ||
subaccount_cf_org = substr(replace("${local.subaccount_domain}", "-", ""), 0, 32) | ||
} | ||
|
||
# ------------------------------------------------------------------------------------------------------ | ||
# Creation of subaccount | ||
# ------------------------------------------------------------------------------------------------------ | ||
resource "btp_subaccount" "dc_mission" { | ||
name = var.subaccount_name | ||
subdomain = local.subaccount_domain | ||
region = lower(var.region) | ||
} | ||
|
||
# ------------------------------------------------------------------------------------------------------ | ||
# 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 = 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 = 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 = btp_subaccount.dc_mission.id | ||
role_collection_name = "Subaccount Service Administrator" | ||
user_name = each.value | ||
} | ||
|
||
|
||
# ------------------------------------------------------------------------------------------------------ | ||
# CLOUDFOUNDRY PREPARATION | ||
# ------------------------------------------------------------------------------------------------------ | ||
# | ||
# Fetch all available environments for the subaccount | ||
data "btp_subaccount_environments" "all" { | ||
subaccount_id = btp_subaccount.dc_mission.id | ||
} | ||
# ------------------------------------------------------------------------------------------------------ | ||
# Take the landscape label from the first CF environment if no environment label is provided | ||
# (this replaces the previous null_resource) | ||
# ------------------------------------------------------------------------------------------------------ | ||
resource "terraform_data" "replacement" { | ||
input = length(var.cf_environment_label) > 0 ? var.cf_environment_label : [for env in data.btp_subaccount_environments.all.values : env if env.service_name == "cloudfoundry" && env.environment_type == "cloudfoundry"][0].landscape_label | ||
} | ||
# ------------------------------------------------------------------------------------------------------ | ||
# Creation of Cloud Foundry environment | ||
# ------------------------------------------------------------------------------------------------------ | ||
resource "btp_subaccount_environment_instance" "cloudfoundry" { | ||
subaccount_id = btp_subaccount.dc_mission.id | ||
name = local.subaccount_cf_org | ||
environment_type = "cloudfoundry" | ||
service_name = "cloudfoundry" | ||
plan_name = "standard" | ||
landscape_label = terraform_data.replacement.output | ||
parameters = jsonencode({ | ||
instance_name = local.subaccount_cf_org | ||
}) | ||
depends_on = [btp_subaccount_subscription.build_workzone] | ||
} | ||
|
||
############################################################################################### | ||
# 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.dc_mission.id | ||
service_name = "SAPLaunchpad" | ||
plan_name = var.qas_service_plan__build_workzone | ||
amount = var.qas_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.dc_mission.id | ||
app_name = "SAPLaunchpad" | ||
plan_name = var.qas_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.dc_mission.id | ||
service_name = "one-inbox-service" | ||
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.dc_mission.id | ||
role_collection_name = "Launchpad_Admin" | ||
user_name = each.value | ||
depends_on = [btp_subaccount_subscription.build_workzone] | ||
} | ||
|
||
# ------------------------------------------------------------------------------------------------------ | ||
# Create tfvars file for step 2 (if variable `create_tfvars_file_for_step2` is set to true) | ||
# ------------------------------------------------------------------------------------------------------ | ||
resource "local_file" "output_vars_step1" { | ||
count = var.create_tfvars_file_for_step2 ? 1 : 0 | ||
content = <<-EOT | ||
globalaccount = "${var.globalaccount}" | ||
cli_server_url = ${jsonencode(var.cli_server_url)} | ||
|
||
subaccount_id = "${btp_subaccount.dc_mission.id}" | ||
|
||
cf_api_endpoint = "${jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels)["API Endpoint"]}" | ||
|
||
cf_org_id = "${jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels)["Org ID"]}" | ||
cf_org_name = "${jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels)["Org Name"]}" | ||
|
||
origin_key = "${var.origin_key}" | ||
|
||
cf_space_name = "${var.cf_space_name}" | ||
|
||
cf_org_admins = ${jsonencode(var.cf_org_admins)} | ||
cf_space_developers = ${jsonencode(var.cf_space_developers)} | ||
cf_space_managers = ${jsonencode(var.cf_space_managers)} | ||
|
||
EOT | ||
filename = "../step2/terraform.tfvars" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
output "subaccount_id" { | ||
value = btp_subaccount.dc_mission.id | ||
description = "The ID of the subaccount." | ||
} | ||
|
||
output "cf_api_endpoint" { | ||
value = jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels)["API Endpoint"] | ||
description = "The Cloudfoundry API endpoint." | ||
} | ||
|
||
output "cf_org_id" { | ||
value = jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels)["Org ID"] | ||
description = "The Cloudfoundry org id." | ||
} | ||
|
||
output "cf_org_name" { | ||
value = jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels)["Org Name"] | ||
description = "The Cloudfoundry org name." | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
### | ||
# Define the required providers for this module | ||
### | ||
terraform { | ||
required_providers { | ||
btp = { | ||
source = "sap/btp" | ||
version = "~> 1.4.0" | ||
} | ||
} | ||
} | ||
provider "btp" { | ||
globalaccount = var.globalaccount | ||
cli_server_url = var.cli_server_url | ||
} |
23 changes: 23 additions & 0 deletions
23
released/discovery_center/mission_3774/step1/sample.tfvars
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# ------------------------------------------------------------------------------------------------------ | ||
# Provider configuration | ||
# ------------------------------------------------------------------------------------------------------ | ||
# Your global account subdomain | ||
globalaccount = "yourglobalaccount" | ||
region = "datacenter" | ||
subaccount_name = "subaccount_name" | ||
|
||
qas_service_plan__build_workzone = "free" | ||
|
||
# ------------------------------------------------------------------------------------------------------ | ||
# Project specific configuration (please adapt!) | ||
# ------------------------------------------------------------------------------------------------------ | ||
|
||
subaccount_admins = ["another.user@test.com"] | ||
subaccount_service_admins = ["another.user@test.com"] | ||
|
||
cf_org_admins = ["another.user@test.com"] | ||
cf_space_managers = ["another.user@test.com", "you@test.com"] | ||
cf_space_developers = ["another.user@test.com", "you@test.com"] | ||
|
||
custom_idp = "sap.ids" | ||
rui1610 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
launchpad_admins = ["another.user@test.com", "you@test.com"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.