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
123 changes: 69 additions & 54 deletions released/discovery_center/mission_4024/step1/main.tf
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
# ------------------------------------------------------------------------------------------------------
# Subaccount setup for DC mission 4024
# ------------------------------------------------------------------------------------------------------
# Setup subaccount domain (to ensure uniqueness in BTP global account)
resource "random_uuid" "uuid" {}

locals {
random_uuid = random_uuid.uuid.result
subaccount_domain = "dcmission4024${local.random_uuid}"

# used (mandatory) services
service_name__sap_build_apps = "sap-build-apps"
service_name__sap_launchpad = "SAPLaunchpad"
service_name__destination = "destination"
# optional, if custom idp is used
service_name__sap_identity_services_onboarding = "sap-identity-services-onboarding"
}

# ------------------------------------------------------------------------------------------------------
Expand All @@ -31,8 +28,66 @@ data "btp_subaccount" "subaccount" {
id = data.btp_subaccount.dc_mission.id
}
# ------------------------------------------------------------------------------------------------------
# SERVICES/SUBSCRIPTIONS
# SERVICES
# ------------------------------------------------------------------------------------------------------
#
locals {
service_name__destination = "destination"
}
# ------------------------------------------------------------------------------------------------------
# Setup destination (Destination Service)
# ------------------------------------------------------------------------------------------------------
# Entitle
resource "btp_subaccount_entitlement" "destination" {
subaccount_id = data.btp_subaccount.dc_mission.id
service_name = local.service_name__destination
plan_name = var.service_plan__destination
}

# Get plan for destination service
data "btp_subaccount_service_plan" "by_name" {
subaccount_id = data.btp_subaccount.dc_mission.id
name = var.service_plan__destination
offering_name = local.service_name__destination
depends_on = [btp_subaccount_subscription.sap_launchpad]
}

# Create destination for Visual Cloud Functions
resource "btp_subaccount_service_instance" "vcf_destination" {
subaccount_id = data.btp_subaccount.dc_mission.id
serviceplan_id = data.btp_subaccount_service_plan.by_name.id
name = "SAP-Build-Apps-Runtime"
parameters = jsonencode({
HTML5Runtime_enabled = true
init_data = {
subaccount = {
existing_destinations_policy = "update"
destinations = [
{
Name = "SAP-Build-Apps-Runtime"
Type = "HTTP"
Description = "Endpoint to SAP Build Apps runtime"
URL = "https://${data.btp_subaccount.subaccount.subdomain}.cr1.${data.btp_subaccount.subaccount.region}.apps.build.cloud.sap/"
ProxyType = "Internet"
Authentication = "NoAuthentication"
"HTML5.ForwardAuthToken" = true
}
]
}
}
})
}

# ------------------------------------------------------------------------------------------------------
# APP SUBSCRIPTIONS
# ------------------------------------------------------------------------------------------------------
#
locals {
service_name__sap_build_apps = "sap-build-apps"
service_name__sap_launchpad = "SAPLaunchpad"
# optional, if custom idp is used
service_name__sap_identity_services_onboarding = "sap-identity-services-onboarding"
}
# ------------------------------------------------------------------------------------------------------
# Setup sap-identity-services-onboarding (Cloud Identity Services)
# ------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -69,7 +124,7 @@ resource "btp_subaccount_entitlement" "sap_build_apps" {
depends_on = [btp_subaccount_trust_configuration.fully_customized]
}
# Subscribe
resource "btp_subaccount_subscription" "sap-build-apps" {
resource "btp_subaccount_subscription" "sap_build_apps" {
subaccount_id = data.btp_subaccount.dc_mission.id
app_name = "sap-appgyver-ee"
plan_name = var.service_plan__sap_build_apps
Expand All @@ -95,58 +150,14 @@ resource "btp_subaccount_subscription" "sap_launchpad" {
depends_on = [btp_subaccount_entitlement.sap_launchpad]
}

# ------------------------------------------------------------------------------------------------------
# Setup destination (Destination Service)
# ------------------------------------------------------------------------------------------------------
# Entitle
resource "btp_subaccount_entitlement" "destination" {
subaccount_id = data.btp_subaccount.dc_mission.id
service_name = local.service_name__destination
plan_name = var.service_plan__destination
}

# Get plan for destination service
data "btp_subaccount_service_plan" "by_name" {
subaccount_id = data.btp_subaccount.dc_mission.id
name = var.service_plan__destination
offering_name = local.service_name__destination
depends_on = [btp_subaccount_subscription.sap_launchpad]
}

# Create destination for Visual Cloud Functions
resource "btp_subaccount_service_instance" "vcf_destination" {
subaccount_id = data.btp_subaccount.dc_mission.id
serviceplan_id = data.btp_subaccount_service_plan.by_name.id
name = "SAP-Build-Apps-Runtime"
parameters = jsonencode({
HTML5Runtime_enabled = true
init_data = {
subaccount = {
existing_destinations_policy = "update"
destinations = [
{
Name = "SAP-Build-Apps-Runtime"
Type = "HTTP"
Description = "Endpoint to SAP Build Apps runtime"
URL = "https://${data.btp_subaccount.subaccount.subdomain}.cr1.${data.btp_subaccount.subaccount.region}.apps.build.cloud.sap/"
ProxyType = "Internet"
Authentication = "NoAuthentication"
"HTML5.ForwardAuthToken" = true
}
]
}
}
})
}

# ------------------------------------------------------------------------------------------------------
# USERS AND ROLES
# ------------------------------------------------------------------------------------------------------
#
# Get all roles in the subaccount
data "btp_subaccount_roles" "all" {
subaccount_id = data.btp_subaccount.dc_mission.id
depends_on = [btp_subaccount_subscription.sap-build-apps]
depends_on = [btp_subaccount_subscription.sap_build_apps]
}
# ------------------------------------------------------------------------------------------------------
# Assign role collection "Subaccount Administrator"
Expand Down Expand Up @@ -263,12 +274,16 @@ resource "btp_subaccount_role_collection_assignment" "build_apps_registry_develo
depends_on = [btp_subaccount_role_collection.build_apps_registry_developer]
}

# ------------------------------------------------------------------------------------------------------
# Assign role collection "Launchpad_Admin"
# ------------------------------------------------------------------------------------------------------
# Assign users
resource "btp_subaccount_role_collection_assignment" "launchpad_admin" {
for_each = toset("${var.launchpad_admins}")
subaccount_id = data.btp_subaccount.dc_mission.id
role_collection_name = "Launchpad_Admin"
user_name = each.value
origin = btp_subaccount_trust_configuration.fully_customized.origin
depends_on = [btp_subaccount_subscription.sap_launchpad]
}

Expand Down
2 changes: 1 addition & 1 deletion released/discovery_center/mission_4024/step1/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ output "subaccount_id" {
}

output "sap_build_apps_subscription_url" {
value = btp_subaccount_subscription.sap-build-apps.subscription_url
value = btp_subaccount_subscription.sap_build_apps.subscription_url
description = "The subscription_url of build app."
}
2 changes: 1 addition & 1 deletion released/discovery_center/mission_4024/step1/sample.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ custom_idp = "<<tenant-id>>.accounts.ondemand.com"
# ------------------------------------------------------------------------------------------------------
# Account settings
# ------------------------------------------------------------------------------------------------------
globalaccount = "your-globalaccount-subdomain"
globalaccount = "<your-global-account-subdomain>"
region = "us10"

# ------------------------------------------------------------------------------------------------------
Expand Down
51 changes: 27 additions & 24 deletions released/discovery_center/mission_4024/step1/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ variable "globalaccount" {
variable "cli_server_url" {
type = string
description = "The BTP CLI server URL."
default = "https://cpcli.cf.eu10.hana.ondemand.com"
default = "https://cli.btp.cloud.sap"
}

variable "custom_idp" {
type = string
description = "Defines the custom IDP to be used for the subaccount"
description = "The custom identity provider for the subaccount."
default = ""
}

variable "region" {
type = string
description = "The region where the sub account shall be created in."
description = "The region where the subaccount shall be created in."
default = "us10"
}

variable "subaccount_name" {
type = string
description = "The subaccount name."
default = "My SAP Build Apps subaccount"
default = "My SAP DC mission subaccount."
}

variable "subaccount_id" {
Expand All @@ -39,26 +39,6 @@ variable "subaccount_id" {
# ------------------------------------------------------------------------------------------------------
# service plans
# ------------------------------------------------------------------------------------------------------
variable "service_plan__sap_build_apps" {
type = string
description = "The plan for SAP Build Apps subscription"
default = "free"
validation {
condition = contains(["free", "standard", "partner"], var.service_plan__sap_build_apps)
error_message = "Invalid value for service_plan__sap_build_apps. Only 'free', 'standard' and 'partner' are allowed."
}
}

variable "service_plan__sap_launchpad" {
type = string
description = "The plan for service 'SAP Build Work Zone, standard edition' with technical name 'SAPLaunchpad'"
default = "free"
validation {
condition = contains(["free", "standard"], var.service_plan__sap_launchpad)
error_message = "Invalid value for service_plan__sap_launchpad. Only 'free' and 'standard' are allowed."
}
}

variable "service_plan__destination" {
type = string
description = "The plan for service 'Destination Service' with technical name 'destination'"
Expand All @@ -69,6 +49,9 @@ variable "service_plan__destination" {
}
}

# ------------------------------------------------------------------------------------------------------
# app subscription plans
# ------------------------------------------------------------------------------------------------------
variable "service_plan__sap_identity_services_onboarding" {
type = string
description = "The plan for service 'Cloud Identity Services' with technical name 'sap-identity-services-onboarding'"
Expand All @@ -79,6 +62,26 @@ variable "service_plan__sap_identity_services_onboarding" {
}
}

variable "service_plan__sap_build_apps" {
type = string
description = "The plan for SAP Build Apps subscription"
default = "free"
validation {
condition = contains(["free", "standard", "partner"], var.service_plan__sap_build_apps)
error_message = "Invalid value for service_plan__sap_build_apps. Only 'free', 'standard' and 'partner' are allowed."
}
}

variable "service_plan__sap_launchpad" {
type = string
description = "The plan for service 'SAP Build Work Zone, standard edition' with technical name 'SAPLaunchpad'"
default = "free"
validation {
condition = contains(["free", "standard"], var.service_plan__sap_launchpad)
error_message = "Invalid value for service_plan__sap_launchpad. Only 'free' and 'standard' are allowed."
}
}

# ------------------------------------------------------------------------------------------------------
# User lists
# ------------------------------------------------------------------------------------------------------
Expand Down
5 changes: 3 additions & 2 deletions released/discovery_center/mission_4024/step2/sample.tfvars
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ------------------------------------------------------------------------------------------------------
# Account settings
# ------------------------------------------------------------------------------------------------------
globalaccount = "<<your-global-account-subdomain>>"
subaccount_id = "<<subaccount id from step 1>>"
globalaccount = "<your-global-account-subdomain>"

subaccount_id = "<subaccount id from step 1>>"