Skip to content

Commit 1f3bf43

Browse files
authored
Ensure compliance for mission 4104 (#270)
1 parent f5ce5a5 commit 1f3bf43

File tree

5 files changed

+42
-22
lines changed

5 files changed

+42
-22
lines changed

released/discovery_center/mission_4104/main.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
resource "random_uuid" "subaccount_domain_suffix" {}
66

77
locals {
8-
random_uuid = random_uuid.subaccount_domain_suffix.result
9-
project_subaccount_domain = lower(replace("dcmission-4104-${local.random_uuid}", "_", "-"))
8+
random_uuid = random_uuid.subaccount_domain_suffix.result
9+
subaccount_subdomain = lower(replace("dcmission-4104-${local.random_uuid}", "_", "-"))
1010
}
1111

1212
# ------------------------------------------------------------------------------------------------------
1313
# Creation of subaccount
1414
# ------------------------------------------------------------------------------------------------------
1515
resource "btp_subaccount" "dc_mission" {
1616
name = var.subaccount_name
17-
subdomain = local.project_subaccount_domain
17+
subdomain = local.subaccount_subdomain
1818
region = lower(var.region)
1919
}
2020

@@ -46,10 +46,10 @@ resource "btp_subaccount_service_instance" "datasphere" {
4646
name = "standard_datasphere-service"
4747
parameters = jsonencode(
4848
{
49-
"first_name" : "${var.qas_datasphere_first_name}",
50-
"last_name" : "${var.qas_datasphere_last_name}",
51-
"email" : "${var.qas_datasphere_email}",
52-
"host_name" : "${var.qas_datasphere_host_name}",
49+
"first_name" : "${var.datasphere_first_name}",
50+
"last_name" : "${var.datasphere_last_name}",
51+
"email" : "${var.datasphere_email}",
52+
"host_name" : "${var.datasphere_host_name}",
5353
}
5454
)
5555
timeouts = {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "subaccount_id" {
2+
value = btp_subaccount.dc_mission.id
3+
description = "ID of the created subaccount"
4+
}

released/discovery_center/mission_4104/provider.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ terraform {
88
}
99

1010
provider "btp" {
11+
idp = var.custom_idp
1112
globalaccount = var.globalaccount
1213
cli_server_url = var.cli_server_url
1314
}

released/discovery_center/mission_4104/sample.tfvars

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,24 @@ globalaccount = "xxxxxxxx-xxxxxxx-xxxxxxx-xxxxxxxx-xxxxxx"
77
# The CLI server URL (needs to be set to null if you are using the default CLI server)
88
cli_server_url = null
99

10+
# Custom IdP (needs to be set to null if you are using the default platform IdP)
11+
custom_idp = null
12+
1013
# Region for your subaccount
1114
region = "us20"
1215

1316
# Name of your sub account
1417
subaccount_name = "SAP Discovery Center Mission 4104"
1518

1619
# ------------------------------------------------------------------------------------------------------
17-
# USER ROLES
20+
# User roles
1821
# ------------------------------------------------------------------------------------------------------
1922
subaccount_admins = ["[email protected]"]
2023

24+
# ------------------------------------------------------------------------------------------------------
25+
# Datasphere configuration
26+
# ------------------------------------------------------------------------------------------------------
27+
datasphere_email = "[email protected]"
28+
datasphere_first_name = "Your first name"
29+
datasphere_last_name = "Your last name"
30+
datasphere_host_name = "my-datasphere-tenant-123"

released/discovery_center/mission_4104/variables.tf

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@ variable "region" {
2424
variable "subaccount_admins" {
2525
type = list(string)
2626
description = "Defines the colleagues who are added to each subaccount as emergency administrators."
27-
28-
# add validation to check if admins contains a list of valid email addresses
29-
validation {
30-
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)
31-
error_message = "Please enter a valid email address for the subaccount admins."
32-
}
3327
}
3428

3529
variable "custom_idp" {
@@ -38,22 +32,33 @@ variable "custom_idp" {
3832
default = "sap.ids"
3933
}
4034

41-
variable "qas_datasphere_first_name" {
35+
variable "datasphere_first_name" {
4236
type = string
43-
description = "The first name of the QAS datasphere user."
37+
description = "The first name of the datasphere user."
4438
}
4539

46-
variable "qas_datasphere_last_name" {
40+
variable "datasphere_last_name" {
4741
type = string
48-
description = "The last name of the QAS datasphere user."
42+
description = "The last name of the datasphere user."
4943
}
5044

51-
variable "qas_datasphere_email" {
45+
variable "datasphere_email" {
5246
type = string
53-
description = "The email of the QAS datasphere user."
47+
description = "The email of the datasphere user."
48+
49+
validation {
50+
condition = can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", var.datasphere_email))
51+
error_message = "Please enter a valid email address for the Datasphere user."
52+
}
5453
}
5554

56-
variable "qas_datasphere_host_name" {
55+
variable "datasphere_host_name" {
5756
type = string
58-
description = "The host name for the SAP Datasphere service instance."
57+
description = "The host name for the SAP Datasphere service instance. The host name of the tenant can only contain numbers (0-9), lower case letters (a-z), and hyphens (-). The same host name can't be reused to create other instances."
58+
default = ""
59+
60+
validation {
61+
condition = length(var.datasphere_host_name) <= 100 && can(regex("^[a-z0-9-]*$", var.datasphere_host_name))
62+
error_message = "Please include only lower case letters, numbers and hyphens. White spaces are not allowed."
63+
}
5964
}

0 commit comments

Comments
 (0)