Skip to content

Mission 3585 (enterprise and trial) enabled for quick account setup #301

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 1 commit into from
Sep 3, 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
127 changes: 63 additions & 64 deletions released/discovery_center/mission_3585/README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,63 @@
# Discovery Center mission - Get Started on SAP BTP with SAPUI5/Fiori - Create a Hello World App

## Overview

This sample shows how to set up your SAP BTP account for the Discovery Center Mission - [Get Started on SAP BTP with SAPUI5/Fiori - Create a Hello World App](https://discovery-center.cloud.sap/missiondetail/3585/)

## Content of setup

The setup comprises the following resources:

- Creation of the SAP BTP subaccount
- Enablement of Cloudfoundry Environment - [see available regions and endpoints](https://help.sap.com/docs/btp/sap-business-technology-platform/regions-and-api-endpoints-available-for-cloud-foundry-environment)
- Entitlements of services
* SAP Business Application Studio
* SAP Build Work Zone, standard edition
* Continous Integration & Delivery - Optional
- Subscriptions to applications
- Role collection assignments to users

## Deploying the resources

Make sure that you are familiar with SAP BTP and know both the [Get Started with btp-terraform-samples](https://github.com/SAP-samples/btp-terraform-samples/blob/main/GET_STARTED.md) and the [Get Started with the Terraform Provider for BTP](https://developers.sap.com/tutorials/btp-terraform-get-started.html)

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
export BTP_USERNAME=<your_username>
export BTP_PASSWORD=<your_password>
```

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

> The minimal set of parameters you should specify (besides user_email and password) is global account (i.e. its subdomain) and the used custom_idp and all user assignments

> ⚠ 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="sample.tfvars"
```

6. Apply your configuration to provision the resources:

```bash
terraform apply -var-file="sample.tfvars"
```

## 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="sample.tfvars"
```
# Discovery Center Mission: Get Started on SAP BTP with SAPUI5/Fiori - Create a Hello World App

## Overview

This sample shows how to setup your SAP BTP account for the Discovery Center Mission - [Get Started on SAP BTP with SAPUI5/Fiori - Create a Hello World App](https://discovery-center.cloud.sap/protected/index.html#/missiondetail/3585) for your Enterprise BTP Account.

The respective setup of a trial account is described in [SAP-samples/btp-terraform-samples/tree/main/released/discovery_center/mission_3585_trial/README.md](https://github.com/SAP-samples/btp-terraform-samples/tree/main/released/discovery_center/mission_3585_trial/README.md)

## Content of setup

The setup comprises the following resources:

- Creation of the SAP BTP subaccount
- Entitlements of services
- Subscriptions to applications
- Role collection assignments to users

## Deploying the resources

Make sure that you are familiar with SAP BTP and know both the [Get Started with btp-terraform-samples](https://github.com/SAP-samples/btp-terraform-samples/blob/main/GET_STARTED.md) and the [Get Started with the Terraform Provider for BTP](https://developers.sap.com/tutorials/btp-terraform-get-started.html)

To deploy the resources you must:

1. Set your credentials as environment variables

```bash
export BTP_USERNAME ='<Email address of your BTP user>'
export BTP_PASSWORD ='<Password of your BTP user>'
```

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

> The minimal set of parameters you should specify (besides user_email and password) is global account (i.e. its subdomain) and all user assignments

3. Then initialize your workspace:

```bash
terraform init
```

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

```bash
terraform plan -var-file="sample.tfvars"
```

5. Apply your configuration to provision the resources:

```bash
terraform apply -var-file="sample.tfvars"
```

6. Verify e.g., in [BTP Cockpit](https://cockpit.btp.cloud.sap) that a new subaccount with a SAP Business Application Studio subscription has been created and respective users were assigned to role collections

With this you have completed the quick account setup as described in the Discovery Center Mission - [Get Started on SAP BTP with SAPUI5/Fiori - Create a Hello World App](https://discovery-center.cloud.sap/protected/index.html#/missiondetail/3585).

## 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 -var-file="sample.tfvars"
```
105 changes: 59 additions & 46 deletions released/discovery_center/mission_3585/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,33 @@ resource "btp_subaccount" "dc_mission" {
# SERVICES
# ------------------------------------------------------------------------------------------------------
#
locals {
# optional
service_name__cicd_service = "cicd-service"
}
# ------------------------------------------------------------------------------------------------------
# Setup cicd-service (not running in CF environment)
# Setup cicd-service (SAP Continuous Integration and Delivery), (not running in CF environment)
# ------------------------------------------------------------------------------------------------------
# Entitle
resource "btp_subaccount_entitlement" "cicd_service" {
count = var.use_optional_resources ? 1 : 0
subaccount_id = btp_subaccount.dc_mission.id
service_name = "cicd-service"
plan_name = "default"
service_name = local.service_name__cicd_service
plan_name = var.service_plan__cicd_service
}
# Get serviceplan_id for cicd-service with plan_name "default"
data "btp_subaccount_service_plan" "cicd_service" {
count = var.use_optional_resources ? 1 : 0
subaccount_id = btp_subaccount.dc_mission.id
offering_name = "cicd-service"
name = "default"
offering_name = local.service_name__cicd_service
name = var.service_plan__cicd_service
depends_on = [btp_subaccount_entitlement.cicd_service]
}
# Create service instance
resource "btp_subaccount_service_instance" "cicd_service" {
count = var.use_optional_resources ? 1 : 0
subaccount_id = btp_subaccount.dc_mission.id
serviceplan_id = data.btp_subaccount_service_plan.cicd_service.id
serviceplan_id = data.btp_subaccount_service_plan.cicd_service[0].id
name = "default_cicd-service"
# Subscription to the cicd-app subscription is required for creating the service instance
# See as well https://help.sap.com/docs/continuous-integration-and-delivery/sap-continuous-integration-and-delivery/optional-enabling-api-usage?language=en-US
Expand All @@ -47,20 +54,27 @@ resource "btp_subaccount_service_instance" "cicd_service" {
# APP SUBSCRIPTIONS
# ------------------------------------------------------------------------------------------------------
#
locals {
service_name__sapappstudio = "sapappstudio"
# optional
service_name__sap_launchpad = "SAPLaunchpad"
service_name__cicd_app = "cicd-app"

}
# ------------------------------------------------------------------------------------------------------
# Setup sapappstudio
# Setup sapappstudio (SAP Business Application Studio)
# ------------------------------------------------------------------------------------------------------
# Entitle
resource "btp_subaccount_entitlement" "sapappstudio" {
subaccount_id = btp_subaccount.dc_mission.id
service_name = "sapappstudio"
plan_name = "standard-edition"
service_name = local.service_name__sapappstudio
plan_name = var.service_plan__sapappstudio
}
# Subscribe (depends on subscription of standard-edition)
resource "btp_subaccount_subscription" "sapappstudio" {
subaccount_id = btp_subaccount.dc_mission.id
app_name = "sapappstudio"
plan_name = "standard-edition"
app_name = local.service_name__sapappstudio
plan_name = var.service_plan__sapappstudio
depends_on = [btp_subaccount_entitlement.sapappstudio]
}

Expand All @@ -69,15 +83,18 @@ resource "btp_subaccount_subscription" "sapappstudio" {
# ------------------------------------------------------------------------------------------------------
# Entitle
resource "btp_subaccount_entitlement" "sap_launchpad" {
count = var.use_optional_resources ? 1 : 0
subaccount_id = btp_subaccount.dc_mission.id
service_name = "SAPLaunchpad"
plan_name = "standard"
service_name = local.service_name__sap_launchpad
plan_name = var.service_plan__sap_launchpad
amount = var.service_plan__sap_launchpad == "free" ? 1 : null
}
# Subscribe
resource "btp_subaccount_subscription" "sap_launchpad" {
count = var.use_optional_resources ? 1 : 0
subaccount_id = btp_subaccount.dc_mission.id
app_name = "SAPLaunchpad"
plan_name = "standard"
app_name = local.service_name__sap_launchpad
plan_name = var.service_plan__sap_launchpad
depends_on = [btp_subaccount_entitlement.sap_launchpad]
}

Expand All @@ -86,45 +103,26 @@ resource "btp_subaccount_subscription" "sap_launchpad" {
# ------------------------------------------------------------------------------------------------------
# Entitle
resource "btp_subaccount_entitlement" "cicd_app" {
count = var.use_optional_resources ? 1 : 0
subaccount_id = btp_subaccount.dc_mission.id
service_name = "cicd-app"
plan_name = "default"
service_name = local.service_name__cicd_app
plan_name = var.service_plan__cicd_app
amount = var.service_plan__cicd_app == "free" ? 1 : null
}
# Subscribe
resource "btp_subaccount_subscription" "cicd_app" {
count = var.use_optional_resources ? 1 : 0
subaccount_id = btp_subaccount.dc_mission.id
app_name = "cicd-app"
plan_name = "default"
app_name = local.service_name__cicd_app
plan_name = var.service_plan__cicd_app
depends_on = [btp_subaccount_entitlement.cicd_app]
}

# ------------------------------------------------------------------------------------------------------
# USERS AND ROLES
# ------------------------------------------------------------------------------------------------------
#
# Get all available subaccount roles
data "btp_subaccount_roles" "all" {
subaccount_id = btp_subaccount.dc_mission.id
depends_on = [btp_subaccount_subscription.sap_launchpad, btp_subaccount_subscription.sapappstudio, btp_subaccount_subscription.cicd_app]
}

# ------------------------------------------------------------------------------------------------------
# Assign role collection "Launchpad_Admin"
# ------------------------------------------------------------------------------------------------------
resource "btp_subaccount_role_collection_assignment" "launchpad_admin" {
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.sap_launchpad]
}


# ------------------------------------------------------------------------------------------------------
# Assign role collection "Subaccount Administrator"
# ------------------------------------------------------------------------------------------------------
resource "btp_subaccount_role_collection_assignment" "subaccount_admin" {
for_each = toset("${var.subaccount_admins}")
for_each = toset(var.subaccount_admins)
subaccount_id = btp_subaccount.dc_mission.id
role_collection_name = "Subaccount Administrator"
user_name = each.value
Expand All @@ -135,7 +133,7 @@ resource "btp_subaccount_role_collection_assignment" "subaccount_admin" {
# Assign role collection "Business_Application_Studio_Administrator"
# ------------------------------------------------------------------------------------------------------
resource "btp_subaccount_role_collection_assignment" "bas_admins" {
for_each = toset("${var.bas_admins}")
for_each = toset(var.bas_admins)
subaccount_id = btp_subaccount.dc_mission.id
role_collection_name = "Business_Application_Studio_Administrator"
user_name = each.value
Expand All @@ -146,18 +144,32 @@ resource "btp_subaccount_role_collection_assignment" "bas_admins" {
# Assign role collection "Business_Application_Studio_Developer"
# ------------------------------------------------------------------------------------------------------
resource "btp_subaccount_role_collection_assignment" "bas_developer" {
for_each = toset("${var.bas_developers}")
for_each = toset(var.bas_developers)
subaccount_id = btp_subaccount.dc_mission.id
role_collection_name = "Business_Application_Studio_Developer"
user_name = each.value
depends_on = [btp_subaccount_subscription.sapappstudio]
}

# ------------------------------------------------------------------------------------------------------
# Assign role collection "Launchpad_Admin"
# ------------------------------------------------------------------------------------------------------
# optional app subscription
resource "btp_subaccount_role_collection_assignment" "launchpad_admin" {
for_each = toset(var.use_optional_resources == true ? var.launchpad_admins : [])
subaccount_id = btp_subaccount.dc_mission.id
role_collection_name = "Launchpad_Admin"
user_name = each.value
depends_on = [btp_subaccount_subscription.sap_launchpad]
}

# ------------------------------------------------------------------------------------------------------
# Assign role collection "CICD Service Administrator"
# ------------------------------------------------------------------------------------------------------
# optional app subscription

resource "btp_subaccount_role_collection_assignment" "cicd_admins" {
for_each = toset("${var.cicd_admins}")
for_each = toset(var.use_optional_resources == true ? var.cicd_admins : [])
subaccount_id = btp_subaccount.dc_mission.id
role_collection_name = "CICD Service Administrator"
user_name = each.value
Expand All @@ -167,8 +179,9 @@ resource "btp_subaccount_role_collection_assignment" "cicd_admins" {
# ------------------------------------------------------------------------------------------------------
# Assign role collection "CICD Service Developer"
# ------------------------------------------------------------------------------------------------------
# optional app subscription
resource "btp_subaccount_role_collection_assignment" "cicd_developers" {
for_each = toset("${var.cicd_developers}")
for_each = toset(var.use_optional_resources == true ? var.cicd_developers : [])
subaccount_id = btp_subaccount.dc_mission.id
role_collection_name = "CICD Service Developer"
user_name = each.value
Expand Down
16 changes: 10 additions & 6 deletions released/discovery_center/mission_3585/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@ output "subaccount_id" {
description = "The Global Account subdomain id."
}

output "cicd_app_subscription_url" {
value = btp_subaccount_subscription.cicd_app.subscription_url
description = "Continuous Integration & Delivery subscription URL."
}

output "sapappstudio_subscription_url" {
value = btp_subaccount_subscription.sapappstudio.subscription_url
description = "SAP Business Application Studio subscription URL."
}

output "sap_launchpad_subscription_url" {
value = btp_subaccount_subscription.sap_launchpad.subscription_url
value = var.use_optional_resources ? btp_subaccount_subscription.sap_launchpad[0].subscription_url : null
description = "SAP Build Work Zone, standard edition subscription URL."
}

output "cicd_service_id" {
value = var.use_optional_resources ? btp_subaccount_service_instance.cicd_service[0].id : null
}

output "cicd_app_subscription_url" {
value = var.use_optional_resources ? btp_subaccount_subscription.cicd_app[0].subscription_url : null
description = "Continuous Integration & Delivery subscription URL."
}
3 changes: 0 additions & 3 deletions released/discovery_center/mission_3585/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ terraform {
}

provider "btp" {
# Comment out the idp in case you need it to connect to your global account
# -------------------------------------------------------------------------
# idp = var.custom_idp
globalaccount = var.globalaccount
cli_server_url = var.cli_server_url
}
11 changes: 4 additions & 7 deletions released/discovery_center/mission_3585/sample.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
# Your global account subdomain
globalaccount = "xxxxxxxx-xxxxxxx-xxxxxxx-xxxxxxxx-xxxxxx"

# The CLI server URL (needs to be set to null if you are using the default CLI server)
cli_server_url = null

# Region for your subaccount
region = "us10"

Expand All @@ -18,10 +15,10 @@ subaccount_name = "SAP Discovery Center Mission 3585"
# ------------------------------------------------------------------------------------------------------
subaccount_admins = ["another.user@test.com"]

bas_admins = ["another.user@test.com", "you@test.com"]
bas_developers = ["another.user@test.com", "you@test.com"]

launchpad_admins = ["another.user@test.com", "you@test.com"]

cicd_admins = ["another.user@test.com", "you@test.com"]
cicd_developers = ["another.user@test.com", "you@test.com"]

bas_admins = ["another.user@test.com", "you@test.com"]
bas_developers = ["another.user@test.com", "you@test.com"]
cicd_developers = ["another.user@test.com", "you@test.com"]
Loading