Skip to content
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
64 changes: 21 additions & 43 deletions released/discovery_center/mission_4327/step1/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -63,54 +63,14 @@ resource "btp_subaccount_role_collection_assignment" "subaccount-admins" {
user_name = each.value
}
######################################################################
# Add entitlement for BAS, Subscribe BAS and add roles
######################################################################
resource "btp_subaccount_entitlement" "bas" {
subaccount_id = btp_subaccount.project.id
service_name = "sapappstudio"
plan_name = var.service_plan__bas
}
resource "btp_subaccount_subscription" "bas-subscribe" {
subaccount_id = btp_subaccount.project.id
app_name = "sapappstudio"
plan_name = var.service_plan__bas
depends_on = [btp_subaccount_entitlement.bas]
}
resource "btp_subaccount_role_collection_assignment" "Business_Application_Studio_Administrator" {
subaccount_id = btp_subaccount.project.id
role_collection_name = "Business_Application_Studio_Administrator"
user_name = data.btp_whoami.me.email
depends_on = [btp_subaccount_subscription.bas-subscribe]
}


resource "btp_subaccount_role_collection_assignment" "Business_Application_Studio_Developer" {
subaccount_id = btp_subaccount.project.id
role_collection_name = "Business_Application_Studio_Developer"
user_name = data.btp_whoami.me.email
depends_on = [btp_subaccount_subscription.bas-subscribe]
}
######################################################################
# Add Build Workzone entitlement subscription and role Assignment
# Add Build Workzone entitlement
######################################################################
resource "btp_subaccount_entitlement" "build_workzone" {
subaccount_id = btp_subaccount.project.id
service_name = "SAPLaunchpad"
plan_name = var.service_plan__build_workzone
amount = var.service_plan__build_workzone == "free" ? 1 : null
}
resource "btp_subaccount_subscription" "build_workzone_subscribe" {
subaccount_id = btp_subaccount.project.id
app_name = "SAPLaunchpad"
plan_name = var.service_plan__build_workzone
depends_on = [btp_subaccount_entitlement.build_workzone]
}
resource "btp_subaccount_role_collection_assignment" "launchpad_admin" {
subaccount_id = btp_subaccount.project.id
role_collection_name = "Launchpad_Admin"
user_name = data.btp_whoami.me.email
depends_on = [btp_subaccount_subscription.build_workzone_subscribe]
}
######################################################################
# Create HANA entitlement subscription
######################################################################
Expand All @@ -131,12 +91,30 @@ resource "btp_subaccount_subscription" "hana-cloud-tools" {
plan_name = "tools"
depends_on = [btp_subaccount_entitlement.hana-cloud-tools]
}
# Assign users to Role Collection: SAP HANA Cloud Administrator
resource "btp_subaccount_role_collection_assignment" "hana-cloud-admin" {
for_each = toset(var.hana_cloud_admins)
subaccount_id = btp_subaccount.project.id
role_collection_name = "SAP HANA Cloud Administrator"
user_name = each.value
depends_on = [btp_subaccount_subscription.hana-cloud-tools]
}
resource "btp_subaccount_entitlement" "hana-hdi-shared" {
subaccount_id = btp_subaccount.project.id
service_name = "hana"
plan_name = "hdi-shared"
}

###############################################################################################
# Prepare and setup app: Continuous Integration & Delivery
###############################################################################################
# Entitle subaccount for usage of app Continuous Integration & Delivery
resource "btp_subaccount_entitlement" "cicd_app" {
subaccount_id = btp_subaccount.project.id
service_name = "cicd-app"
plan_name = var.cicd_service_plan
}

locals {
cf_org_users = setsubtract(toset(var.cf_org_users), [data.btp_whoami.me.email])
cf_org_admins = setsubtract(toset(var.cf_org_admins), [data.btp_whoami.me.email])
Expand All @@ -147,12 +125,12 @@ resource "local_file" "output_vars_step1" {
content = <<-EOT
cf_api_url = "${jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels)["API Endpoint"]}"
cf_org_id = "${btp_subaccount_environment_instance.cloudfoundry.platform_id}"

cf_org_users = ${jsonencode(local.cf_org_users)}
cf_org_admins = ${jsonencode(local.cf_org_admins)}
cf_space_developers = ${jsonencode(var.cf_space_developers)}
cf_space_managers = ${jsonencode(var.cf_space_managers)}

EOT
filename = "../step2_cf/terraform.tfvars"
}
}
10 changes: 1 addition & 9 deletions released/discovery_center/mission_4327/step1/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ output "cf_org_admins" {
value = local.cf_org_admins
}

output "bas_subscription_url" {
value = btp_subaccount_subscription.bas-subscribe.subscription_url
}

output "build_workzone_subscription_url" {
value = btp_subaccount_subscription.build_workzone_subscribe.subscription_url
}

output "hana_cloud_tools_subscription_url" {
value = btp_subaccount_subscription.hana-cloud-tools.subscription_url
}
}
8 changes: 6 additions & 2 deletions released/discovery_center/mission_4327/step1/samples.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,22 @@ subaccount_admins = ["[email protected]", "[email protected]"]
# Entitlements plan update
#------------------------------------------------------------------------------------------------------
# For production use of Business Application Studio, upgrade the plan from the `free-tier` to the appropriate plan e.g standard-edition
service_plan__bas = "standard-edition"
# service_plan__bas = "standard-edition"
#-------------------------------------------------------------------------------------------------------
# For production use of Build Workzone, upgrade the plan from the `free-tier` to the appropriate plan e.g standard
service_plan__build_workzone = "standard"
#--------------------------------------------------------------------------------------------------------
# For production use of HANA, upgrade the plan from the `free-tier` to the appropriate plan e.g hana
service_plan__hana_cloud = "hana"
# cicd service plan
cicd_service_plan = "default"
#------------------------------------------------------------------------------------------------------
# Cloud Foundry
#------------------------------------------------------------------------------------------------------
# Choose a unique organization name e.g., based on the global account subdomain and subaccount name
cf_org_name = "<unique_org_name>"
cf_org_name = "<unique org name>"
# hana cloud admin users
hana_cloud_admins = ["[email protected]"]
# Additional Cloud Foundry users
cf_space_developers = ["[email protected]"]
cf_space_managers = ["[email protected]"]
Expand Down
21 changes: 15 additions & 6 deletions released/discovery_center/mission_4327/step1/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ variable "subaccount_admins" {
###

# Plan_name update
variable "service_plan__bas" {
description = "BAS plan"
type = string
default = "free"
}

variable "service_plan__build_workzone" {
description = "Build Workzone plan"
Expand All @@ -61,6 +56,20 @@ variable "service_plan__hana_cloud" {
default = "hana-free"
}

variable "hana_cloud_admins" {
type = list(string)
description = "Defines the colleagues who are added as admins to access the instance of SAP HANA Cloud."
}
# CICD service plan
variable "cicd_service_plan" {
type = string
description = "The plan for Continous Integration & Delivery subscription"
default = "free"
validation {
condition = contains(["free", "default"], var.cicd_service_plan)
error_message = "Invalid value for Continous Integraion & Delivery. Only 'free' and 'default' are allowed."
}
}
###
# Cloud Foundry
###
Expand Down Expand Up @@ -105,4 +114,4 @@ variable "create_tfvars_file_for_next_stage" {
description = "Switch to enable the creation of the tfvars file for the next stage."
type = bool
default = false
}
}