Skip to content

Remove cf for mission 3585 #236

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 2 commits into from
Jul 4, 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
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Discovery Center mission - Get Started on SAP BTP with SAPUI5/Fiori - Create a Hello World App (Step 1)
# Discovery Center mission - Get Started on SAP BTP with SAPUI5/Fiori - Create a Hello World App

## Overview

Step 1 of 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/)
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

Expand Down Expand Up @@ -32,19 +32,18 @@ To deploy the resources you must:

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
> 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. The outputs of this `step1` will be needed for the `step2` of this use case. In case you want to create a file with the content of the variables, you should set the variable `create_tfvars_file_for_next_step` to `true`. This will create a `terraform.tfvars` file in the `step2` folder.

4. Initialize your workspace:
3. Initialize your workspace:

```bash
terraform init
```

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

```bash
terraform plan -var-file="sample.tfvars"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,17 @@
# Subaccount setup for DC mission 3585
# ------------------------------------------------------------------------------------------------------
# Setup subaccount domain (to ensure uniqueness in BTP global account)
resource "random_id" "subaccount_domain_suffix" {
byte_length = 12
}
resource "random_uuid" "uuid" {}

# ------------------------------------------------------------------------------------------------------
# Creation of subaccount
# ------------------------------------------------------------------------------------------------------
resource "btp_subaccount" "dc_mission" {
name = var.subaccount_name
subdomain = join("-", ["dc-mission-3585", random_id.subaccount_domain_suffix.hex])
subdomain = join("-", ["dc-mission-3585", random_uuid.uuid.result])
region = lower(var.region)
}

# ------------------------------------------------------------------------------------------------------
# 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_landscape_label) > 0 ? var.cf_landscape_label : [for env in data.btp_subaccount_environments.all.values : env if env.service_name == "cloudfoundry" && env.environment_type == "cloudfoundry"][0].landscape_label
}
# ------------------------------------------------------------------------------------------------------
# Create the Cloud Foundry environment instance
# ------------------------------------------------------------------------------------------------------
resource "btp_subaccount_environment_instance" "cf" {
subaccount_id = btp_subaccount.dc_mission.id
name = "cf-${random_id.subaccount_domain_suffix.hex}"
environment_type = "cloudfoundry"
service_name = "cloudfoundry"
plan_name = "standard"
landscape_label = terraform_data.replacement.output

parameters = jsonencode({
instance_name = "cf-${random_id.subaccount_domain_suffix.hex}"
})
}

###############################################################################################
# Prepare CF
###############################################################################################
# Entitle subaccount for usage of cf runtime

resource "btp_subaccount_entitlement" "cf_runtime" {
subaccount_id = btp_subaccount.dc_mission.id
service_name = "APPLICATION_RUNTIME"
plan_name = "MEMORY"
amount = 1
}

# ------------------------------------------------------------------------------------------------------
# SERVICES
# ------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -218,24 +174,3 @@ resource "btp_subaccount_role_collection_assignment" "cicd_developers" {
user_name = each.value
depends_on = [btp_subaccount_subscription.cicd_app]
}


# ------------------------------------------------------------------------------------------------------
# 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_next_step ? 1 : 0
content = <<-EOT
cf_api_url = "${jsondecode(btp_subaccount_environment_instance.cf.labels)["API Endpoint"]}"

cf_org_id = "${jsondecode(btp_subaccount_environment_instance.cf.labels)["Org ID"]}"

cf_origin = "${var.cf_origin}"

cf_space_name = "${var.cf_space_name}"

cf_org_admins = ${jsonencode(var.cf_org_admins)}

EOT
filename = "../step2/terraform.tfvars"
}
19 changes: 19 additions & 0 deletions released/discovery_center/mission_3585/outputs.tf
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 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
description = "SAP Build Work Zone, standard edition subscription URL."
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ subaccount_name = "SAP Discovery Center Mission 3585"
# USER ROLES
# ------------------------------------------------------------------------------------------------------
subaccount_admins = ["another.user@test.com"]
cf_org_admins = ["another.user@test.com"]

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

Expand All @@ -26,6 +25,3 @@ 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"]

# Create variables file for step 2 (disabled by default)
create_tfvars_file_for_next_step = true
39 changes: 0 additions & 39 deletions released/discovery_center/mission_3585/step1/outputs.tf

This file was deleted.

58 changes: 0 additions & 58 deletions released/discovery_center/mission_3585/step2/README.md

This file was deleted.

32 changes: 0 additions & 32 deletions released/discovery_center/mission_3585/step2/main.tf

This file was deleted.

15 changes: 0 additions & 15 deletions released/discovery_center/mission_3585/step2/provider.tf

This file was deleted.

8 changes: 0 additions & 8 deletions released/discovery_center/mission_3585/step2/sample.tfvars

This file was deleted.

34 changes: 0 additions & 34 deletions released/discovery_center/mission_3585/step2/variables.tf

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -87,45 +87,8 @@ variable "cicd_admins" {
}
}

variable "cf_org_admins" {
type = list(string)
description = "List of users to set as Cloudfoundry org administrators."

# add validation to check if admins contains a list of valid email addresses
validation {
condition = length([for email in var.cf_org_admins : can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", email))]) == length(var.cf_org_admins)
error_message = "Please enter a valid email address for the CF Org admins."
}
}

variable "cf_origin" {
type = string
description = "Defines the origin key of the identity provider"
default = "sap.ids"
# The value for the cf_origin can be defined
# but are normally set to "sap.ids", "sap.default" or "sap.custom"
}

variable "cf_landscape_label" {
type = string
description = "In case there are multiple landscapes 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 = ""
}

variable "cf_space_name" {
type = string
description = "The Cloud Foundry space name to use"
default = "dev"
}

variable "custom_idp" {
type = string
description = "The custom identity provider for the subaccount."
default = "sap.ids"
}

variable "create_tfvars_file_for_next_step" {
type = bool
description = "Switch to enable the creation of the tfvars file for step 2."
default = false
}
Loading