Skip to content

Commit 0b64945

Browse files
committed
feat: add support for 2nd app in container
1 parent 34576ae commit 0b64945

6 files changed

Lines changed: 44 additions & 15 deletions

File tree

m365/image/run_container.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ Foreach ($tenantConfig in $(Get-ChildItem 'input\')) {
7373
Write-Output "Running ScubaGear for $($tenantConfig.BaseName)"
7474

7575
$params = @{
76-
CertificateThumbPrint = $CertificateThumbPrint; # Certificate Hash; Needed for SP auth
77-
AppID = $Env:APP_ID; # App ID; Needed for Service Principal Auth
78-
Organization = $org; # primary domain of the tenantConfig needed for Service Principal Auth
76+
CertificateThumbPrint = if ($null -ne $Env:SECONDARY_APP_ID -and $org.EndsWith($Env:SECONDARY_APP_TLD)) {$CertificateThumbPrintSecondary} else {$CertificateThumbPrint};
77+
AppID = if ($null -ne $Env:SECONDARY_APP_ID -and $org.EndsWith($Env:SECONDARY_APP_TLD)) {$Env:SECONDARY_APP_ID} else {$Env:APP_ID};
78+
Organization = $org;
7979
OutPath = ".\reports\$($org)"; # The folder path where the output will be stored
8080
OPAPath = "."
8181
ConfigFilePath = $tenantConfig.FullName
@@ -91,7 +91,7 @@ Foreach ($tenantConfig in $(Get-ChildItem 'input\')) {
9191

9292
Write-Output " Starting Upload"
9393
$OutPath = "$($Env:REPORT_OUTPUT)/$($ResultsFile.Name)"
94-
if ($Env:REPORT_SAS -ne $null -and $Env:REPORT_SAS -ne "") {
94+
if ($null -ne $Env:REPORT_SAS -and $Env:REPORT_SAS -ne "") {
9595
$OutPath += "?$($Env:REPORT_SAS)"
9696
}
9797
.\azcopy copy $ResultsFile.FullName $OutPath --output-level essential

m365/terraform/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,5 @@ module "container" {
7474
container_memory_gb = var.container_memory_gb
7575
cert_info = module.app.cert_info
7676
depends_on = [azurerm_resource_group_policy_assignment.tagging_assignments]
77+
secondary_app_info = var.secondary_app_info
7778
}

m365/terraform/modules/app/variables.tf

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,6 @@ variable "contact_emails" {
2323
type = list(string)
2424
}
2525

26-
variable "certificate_rotation_period_days" {
27-
type = number
28-
description = "How many days between when the certificate key should be rotated. Note: rotation requires running terraform"
29-
default = 30
30-
validation {
31-
condition = var.certificate_rotation_period_days <= 60 && var.certificate_rotation_period_days >= 3
32-
error_message = "Rotation period must be between 3 and 60 days"
33-
}
34-
}
35-
3626
variable "image_path" {
3727
type = string
3828
description = "Path to image used for app logo. Displayed in Azure console on installed tenants. Only needed when create_app=true"

m365/terraform/modules/container/main.tf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ resource "azurerm_container_group" "aci" {
6969
cpu = "1"
7070
memory = var.container_memory_gb
7171
environment_variables = {
72+
"DEBUG_LOG" = "false"
7273
"RUN_TYPE" = each.key
7374
"TENANT_ID" = data.azurerm_client_config.current.tenant_id
7475
"APP_ID" = var.application_client_id
@@ -78,8 +79,10 @@ resource "azurerm_container_group" "aci" {
7879
"IS_GOV" = local.is_us_gov
7980
"VAULT_NAME" = var.cert_info.vault_name
8081
"CERT_NAME" = var.cert_info.cert_name
81-
"DEBUG_LOG" = "false"
8282
"MI_PRINCIPAL_ID" = azurerm_user_assigned_identity.container_mi.principal_id
83+
84+
"SECONDARY_APP_ID" = var.secondary_app_info == null ? null : var.secondary_app_info.app_id
85+
"SECONDARY_APP_TLD" = var.secondary_app_info == null ? null : (var.secondary_app_info.environment_to_use == "commercial" ? "com" : "us")
8386
}
8487
secure_environment_variables = {
8588
"REPORT_SAS" = var.output_storage_container_sas != null ? var.output_storage_container_sas : ""

m365/terraform/modules/container/variables.tf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,27 @@ variable "container_memory_gb" {
107107
}
108108

109109
variable "cert_info" {
110+
description = "Information for obtaining to app certificate"
110111
type = object({
111112
vault_id = string
112113
vault_name = string
113114
cert_name = string
114115
})
115116
}
117+
118+
variable "secondary_app_info" {
119+
description = <<EOF
120+
Information for a secondary app. This can be used for one ScubaConnect instance to handle multiple environments (e.g., GCC and GCC High).
121+
To use, manually create an app in the other environment and add the certificate created for the primary app to it.
122+
Set `environment_to_use` to the environment the manual app is in, either "commericial" or "gcchigh"
123+
EOF
124+
type = object({
125+
app_id = string
126+
environment_to_use = string
127+
})
128+
default = null
129+
validation {
130+
condition = var.secondary_app_info == null ? true : contains(["commercial", "gcchigh"], var.secondary_app_info.environment_to_use)
131+
error_message = "Valid values for create_mode are (Default, PointInTimeRestore, Replica)"
132+
}
133+
}

m365/terraform/variables.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,21 @@ variable "container_memory_gb" {
142142
condition = var.container_memory_gb <= 16 && var.container_memory_gb >= 2
143143
error_message = "Container memory must be between 2GB and 16GB"
144144
}
145+
}
146+
147+
variable "secondary_app_info" {
148+
description = <<EOF
149+
Information for a secondary app. This can be used for one ScubaConnect instance to handle multiple environments (e.g., GCC and GCC High).
150+
To use, manually create an app in the other environment and add the certificate created for the primary app to it.
151+
Set `environment_to_use` to the environment the manual app is in, either "commericial" or "gcchigh"
152+
EOF
153+
type = object({
154+
app_id = string
155+
environment_to_use = string
156+
})
157+
default = null
158+
validation {
159+
condition = var.secondary_app_info == null ? true : contains(["commercial", "gcchigh"], var.secondary_app_info.environment_to_use)
160+
error_message = "Valid values for create_mode are (Default, PointInTimeRestore, Replica)"
161+
}
145162
}

0 commit comments

Comments
 (0)