Skip to content

Commit

Permalink
Added option for multiple ASP in the template
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximeMahdavianSSC committed Dec 4, 2024
1 parent de66f6e commit acabdcf
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 22 deletions.
2 changes: 1 addition & 1 deletion ESLZ/appServiceTemplate.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ variable "appServiceTemplate" {


module "appServiceTemplate" {
source = "github.com/canada-ca-terraform-modules/terraform-azurerm-caf-app-service-blueprint.git?ref=v1.0.0"
source = "github.com/canada-ca-terraform-modules/terraform-azurerm-caf-app-service-blueprint.git?ref=v1.0.1"
# source = "/home/max/devops/modules/terraform-azurerm-caf-app-service-template"
for_each = var.appServiceTemplate

Expand Down
37 changes: 25 additions & 12 deletions L2_portal_app_service/config/appServiceTemplate.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,40 @@ appServiceTemplate = {
}

appServicePlan = {
resource_group = "portal_app_service"
os_type = "Linux"
sku_name = "I1v2"
# Optional: Uncomment if you want to set any of these parameters to values other than the defaults below.
# zone_balancing_enabled = false
# maximum_elastic_worker_count = null
# worker_count = 3
# per_site_scaling_enabled = false
linux = {
resource_group = "portal_app_service"
os_type = "Linux"
sku_name = "I1v2"
# Optional: Uncomment if you want to set any of these parameters to values other than the defaults below.
# zone_balancing_enabled = false
# maximum_elastic_worker_count = null
# worker_count = 3
# per_site_scaling_enabled = false
}
# windows = {
# resource_group = "portal_app_service"
# os_type = "Windows"
# sku_name = "I1v2"
# # Optional: Uncomment if you want to set any of these parameters to values other than the defaults below.
# # zone_balancing_enabled = false
# # maximum_elastic_worker_count = null
# # worker_count = 3
# # per_site_scaling_enabled = false
# }
}

appService = {
test = {
resource_group = "portal_app_service"
enabled = true
https_only = true
resource_group = "portal_app_service"
asp = "linux"
enabled = true
https_only = true
# public_network_access_enabled = true
# client_affinity_enabled = true
# client_certificated_enabled = false
# client_certificate_mode = "Required"
# client_certificate_exclusion_paths = ["/path1", "/path2"]
ftp_publish_basic_authentication_enabled = false
ftp_publish_basic_authentication_enabled = false
# key_vault_reference_identity_id = "Your Key Vault Identity ID"
# virtual_network_subnet_id = "Your VNet Subnet ID"
# webdeploy_publish_basic_authentication_enabled = true
Expand Down
2 changes: 1 addition & 1 deletion L2_portal_app_service/modules/appServiceTemplate.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ variable "appServiceTemplate" {


module "appServiceTemplate" {
source = "github.com/canada-ca-terraform-modules/terraform-azurerm-caf-app-service-blueprint.git?ref=v1.0.0"
source = "github.com/canada-ca-terraform-modules/terraform-azurerm-caf-app-service-blueprint.git?ref=v1.0.1"
# source = "/home/max/devops/modules/terraform-azurerm-caf-app-service-template"
for_each = var.appServiceTemplate

Expand Down
5 changes: 3 additions & 2 deletions locals.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
locals {
appServiceLinux = var.appServiceTemplate.appServicePlan.os_type == "Linux" ? var.appServiceTemplate.appService : {}
appServiceWindows = var.appServiceTemplate.appServicePlan.os_type == "Linux" ? {} : var.appServiceTemplate.appService
appServiceLinux = {for app, v in var.appServiceTemplate.appService : app => v if var.appServiceTemplate.appServicePlan[v.asp].os_type == "Linux"}
appServiceWindows = {for app, v in var.appServiceTemplate.appService : app => v if var.appServiceTemplate.appServicePlan[v.asp].os_type == "Windows"}
asp_id = {for name, param in try(var.appServiceTemplate.appServicePlan, {}): name => module.AppServicePlan[name].asp_id}
}
13 changes: 7 additions & 6 deletions module.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ module "AppServiceEnvironment" {

module "AppServicePlan" {
source = "github.com/canada-ca-terraform-modules/terraform-caf-azurerm-app_service_plan.git?ref=v1.0.3"
for_each = var.appServiceTemplate.appServicePlan

userDefinedString = var.userDefinedString
userDefinedString = "${var.userDefinedString}-${each.key}"
env = var.env
group = var.group
project = var.project
resource_groups = var.resource_groups
subnets = var.subnets
ase = module.AppServiceEnvironment.ase_id
appServicePlan = merge(var.appServiceTemplate.appServicePlan, {ase = module.AppServiceEnvironment.ase_id})
appServicePlan = merge(each.value, {ase = module.AppServiceEnvironment.ase_id})
tags = var.tags
}

Expand All @@ -35,8 +36,8 @@ module "appServiceLinux" {
project = var.project
resource_groups = var.resource_groups
subnets = var.subnets
appServiceLinux = merge(each.value, {asp = module.AppServicePlan.asp_id})
asp = module.AppServicePlan.asp_id
appServiceLinux = each.value
asp = local.asp_id
tags = var.tags
}

Expand All @@ -50,8 +51,8 @@ module "appServiceWindows" {
project = var.project
resource_groups = var.resource_groups
subnets = var.subnets
appServiceWindows = merge(each.value, {asp = module.AppServicePlan.asp_id})
asp = module.AppServicePlan.asp_id
appServiceWindows = each.value
asp = local.asp_id
tags = var.tags
}

Expand Down

0 comments on commit acabdcf

Please sign in to comment.