Skip to content

review for QAS, remove unused vars #221

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
Jun 28, 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
3 changes: 3 additions & 0 deletions released/discovery_center/mission_3774/step1/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
locals {
service_name__build_workzone = "SAPLaunchpad"
}
14 changes: 7 additions & 7 deletions released/discovery_center/mission_3774/step1/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ data "btp_subaccount_environments" "all" {
# (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
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
}
# ------------------------------------------------------------------------------------------------------
# Creation of Cloud Foundry environment
Expand All @@ -85,15 +85,15 @@ resource "btp_subaccount_environment_instance" "cloudfoundry" {
# 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
service_name = local.service_name__build_workzone
plan_name = var.service_plan__build_workzone
amount = var.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
app_name = local.service_name__build_workzone
plan_name = var.service_plan__build_workzone
depends_on = [btp_subaccount_entitlement.build_workzone]
}
###############################################################################################
Expand Down Expand Up @@ -127,7 +127,7 @@ resource "local_file" "output_vars_step1" {

subaccount_id = "${btp_subaccount.dc_mission.id}"

cf_api_endpoint = "${jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels)["API Endpoint"]}"
cf_api_url = "${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"]}"
Expand Down
7 changes: 6 additions & 1 deletion released/discovery_center/mission_3774/step1/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ output "subaccount_id" {
description = "The ID of the subaccount."
}

output "cf_api_endpoint" {
output "cf_api_url" {
value = jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels)["API Endpoint"]
description = "The Cloudfoundry API endpoint."
}

output "cf_landscape_label" {
value = terraform_data.replacement.output
description = "The Cloudfoundry landscape label."
}

output "cf_org_id" {
value = jsondecode(btp_subaccount_environment_instance.cloudfoundry.labels)["Org ID"]
description = "The Cloudfoundry org id."
Expand Down
6 changes: 3 additions & 3 deletions released/discovery_center/mission_3774/step1/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ variable "origin_key" {
# but are normally set to "sap.ids", "sap.default" or "sap.custom"
}

variable "cf_environment_label" {
variable "cf_landscape_label" {
type = string
description = "In case there are multiple environments 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 = ""
Expand Down Expand Up @@ -143,12 +143,12 @@ variable "cf_space_developers" {
}
}

variable "qas_service_plan__build_workzone" {
variable "service_plan__build_workzone" {
type = string
description = "The plan for build_workzone subscription"
default = "free"
validation {
condition = contains(["free", "standard"], var.qas_service_plan__build_workzone)
condition = contains(["free", "standard"], var.service_plan__build_workzone)
error_message = "Invalid value for qas_service_plan__build_workzone. Only 'free' and 'standard' are allowed."
}
}
Expand Down
2 changes: 1 addition & 1 deletion released/discovery_center/mission_3774/step2/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ provider "btp" {
cli_server_url = var.cli_server_url
}
provider "cloudfoundry" {
api_url = var.cf_api_endpoint
api_url = var.cf_api_url
}
81 changes: 1 addition & 80 deletions released/discovery_center/mission_3774/step2/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ variable "cli_server_url" {
default = "https://cli.btp.cloud.sap"
}

variable "cf_api_endpoint" {
variable "cf_api_url" {
type = string
description = "The Cloud Foundry API endpoint from the Cloud Foundry environment instance."
}
Expand All @@ -30,64 +30,12 @@ variable "cf_space_name" {
}

# subaccount
variable "subaccount_name" {
type = string
description = "The subaccount name."
default = "UC - Establish a Central Inbox with SAP Task Center"
}
variable "subaccount_id" {
type = string
description = "The subaccount ID."
default = ""
}
# Region
variable "region" {
type = string
description = "The region where the project account shall be created in."
default = "us10"
}
# Cloudfoundry environment label
variable "cf_environment_label" {
type = string
description = "The Cloudfoundry environment label"
default = "cf-us10"
}

variable "subaccount_admins" {
type = list(string)
description = "Defines the colleagues who are added to each subaccount as subaccount administrators."
default = ["jane.doe@test.com", "john.doe@test.com"]

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

variable "subaccount_service_admins" {
type = list(string)
description = "Defines the colleagues who are added to each subaccount as subaccount service administrators."
default = ["jane.doe@test.com", "john.doe@test.com"]

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

variable "launchpad_admins" {
type = list(string)
description = "Defines the colleagues who are added to each subaccount as subaccount service administrators."
default = ["jane.doe@test.com", "john.doe@test.com"]

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

variable "origin_key" {
type = string
Expand All @@ -97,28 +45,11 @@ variable "origin_key" {
# but are normally set to "sap.ids", "sap.default" or "sap.custom"
}

variable "environment_label" {
type = string
description = "In case there are multiple environments 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 = "cf-us10"
}

variable "cf_org_id" {
type = string
description = "The Cloud Foundry Org ID from the Cloud Foundry environment instance."
}

variable "cf_org_name" {
type = string
description = "Name of the Cloud Foundry org."
default = "mission-3774-sap-task-center"

validation {
condition = can(regex("^.{1,255}$", var.cf_org_name))
error_message = "The Cloud Foundry org name must not be emtpy and not exceed 255 characters."
}
}

variable "cf_org_admins" {
type = list(string)
description = "List of users to set as Cloudfoundry org administrators."
Expand Down Expand Up @@ -151,13 +82,3 @@ variable "cf_space_developers" {
error_message = "Please enter a valid email address for the CF space developers."
}
}

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