Skip to content

Commit

Permalink
use shared app service plan for all app services
Browse files Browse the repository at this point in the history
  • Loading branch information
kahlstrm committed Nov 6, 2023
1 parent 9f62be5 commit d575771
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 45 deletions.
10 changes: 6 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ module "cms" {
uploads_storage_account_name = module.frontend.storage_account_name
uploads_storage_account_key = module.frontend.storage_account_key
uploads_container_name = module.frontend.uploads_container_name
tikweb_app_plan_id = module.common.tikweb_app_plan_id
}

module "ilmo" {
Expand All @@ -154,6 +155,7 @@ module "ilmo" {
mailgun_api_key = module.keyvault.ilmo_mailgun_api_key
mailgun_domain = module.keyvault.ilmo_mailgun_domain
website_events_url = "https://${module.frontend.fqdn}/tapahtumat"
tikweb_app_plan_id = module.common.tikweb_app_plan_id

dns_resource_group_name = module.dns_prod.resource_group_name
root_zone_name = module.dns_prod.root_zone_name
Expand Down Expand Up @@ -182,7 +184,7 @@ module "tenttiarkisto" {
postgres_server_fqdn = module.common.postgres_server_fqdn
postgres_server_host = module.common.postgres_server_host
postgres_admin_password = module.common.postgres_admin_password
aux_app_plan_id = module.common.aux_app_plan_id
tikweb_app_plan_id = module.common.tikweb_app_plan_id
django_secret_key = module.keyvault.tenttiarkisto_django_secret_key
}

Expand Down Expand Up @@ -226,9 +228,9 @@ module "tikjob_app" {
dns_resource_group_name = module.dns_prod.resource_group_name
root_zone_name = module.dns_prod.root_zone_name
subdomain = "rekry"

dkim_selector = "mta"
dkim_key = "k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYQLHt0gzozEScD5nNockttK0D0r6MejAOgMBj0e++DtDev9OvTJru5ZtKFlLGXxf3b7GWvV10X5kCT0D2HD/vDfaokZ+EL58lRWg7qlz10XBN/7XDTgPDbDuCBC3mH9W8DeI38omNCT+8fgzVvCjHUfYlvf3dMOn4Ow7zeAZ5yQIDAQAB"
tikweb_app_plan_id = module.common.tikweb_app_plan_id
dkim_selector = "mta"
dkim_key = "k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYQLHt0gzozEScD5nNockttK0D0r6MejAOgMBj0e++DtDev9OvTJru5ZtKFlLGXxf3b7GWvV10X5kCT0D2HD/vDfaokZ+EL58lRWg7qlz10XBN/7XDTgPDbDuCBC3mH9W8DeI38omNCT+8fgzVvCjHUfYlvf3dMOn4Ow7zeAZ5yQIDAQAB"
}

module "forum" {
Expand Down
11 changes: 1 addition & 10 deletions modules/cms/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,11 @@ resource "azurerm_postgresql_database" "tikweb_cms_db" {
collation = "fi-FI"
}

resource "azurerm_service_plan" "tikweb_plan" {
name = "tikweb-${var.env_name}-plan"
location = var.resource_group_location
resource_group_name = var.resource_group_name

os_type = "Linux"
sku_name = "B1"
}

resource "azurerm_linux_web_app" "tikweb_cms" {
name = "tikweb-${var.env_name}-app-cms"
location = var.resource_group_location
resource_group_name = var.resource_group_name
service_plan_id = azurerm_service_plan.tikweb_plan.id
service_plan_id = var.tikweb_app_plan_id

https_only = true

Expand Down
4 changes: 4 additions & 0 deletions modules/cms/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,7 @@ variable "uploads_storage_account_key" {
variable "uploads_container_name" {
type = string
}

variable "tikweb_app_plan_id" {
type = string
}
13 changes: 5 additions & 8 deletions modules/common/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ terraform {
}
}

locals {
pg_server_name = "tikweb-${var.env_name}-pg-server"
}

resource "azurerm_resource_group" "tikweb_rg" {
name = "tikweb-${var.env_name}-rg"
Expand All @@ -24,7 +21,7 @@ resource "random_password" "db_password" {

# Shared Postgres server
resource "azurerm_postgresql_server" "tikweb_pg" {
name = local.pg_server_name
name = "tikweb-${var.env_name}-pg-server"
location = azurerm_resource_group.tikweb_rg.location
resource_group_name = azurerm_resource_group.tikweb_rg.name

Expand All @@ -50,14 +47,14 @@ resource "azurerm_postgresql_firewall_rule" "tikweb_pg_internal_access" {
end_ip_address = "0.0.0.0"
}

# Shared App Service Plan for auxiliary services
resource "azurerm_service_plan" "aux_plan" {
name = "tik-aux-${var.env_name}-plan"
# Shared App Service Plan
resource "azurerm_service_plan" "tikweb_plan" {
name = "tik-${var.env_name}-app-service-plan"
location = azurerm_resource_group.tikweb_rg.location
resource_group_name = azurerm_resource_group.tikweb_rg.name

os_type = "Linux"
sku_name = "B1"
sku_name = "B2"
}

resource "tls_private_key" "acme_account_key" {
Expand Down
4 changes: 2 additions & 2 deletions modules/common/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ output "postgres_admin_password" {
sensitive = true
}

output "aux_app_plan_id" {
value = azurerm_service_plan.aux_plan.id
output "tikweb_app_plan_id" {
value = azurerm_service_plan.tikweb_plan.id
}

output "acme_account_key" {
Expand Down
10 changes: 1 addition & 9 deletions modules/ilmo/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,12 @@ resource "azurerm_postgresql_database" "ilmo_db" {
collation = "fi-FI"
}

resource "azurerm_service_plan" "ilmo_backend_plan" {
name = "tik-ilmo-${var.env_name}-plan"
location = var.resource_group_location
resource_group_name = var.resource_group_name

os_type = "Linux"
sku_name = "B1"
}

resource "azurerm_linux_web_app" "ilmo_backend" {
name = "tik-ilmo-${var.env_name}-app"
location = var.resource_group_location
resource_group_name = var.resource_group_name
service_plan_id = azurerm_service_plan.ilmo_backend_plan.id
service_plan_id = var.tikweb_app_plan_id

https_only = true

Expand Down
4 changes: 4 additions & 0 deletions modules/ilmo/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ variable "dkim_selector" {
variable "dkim_key" {
type = string
}

variable "tikweb_app_plan_id" {
type = string
}
11 changes: 1 addition & 10 deletions modules/recruiting/ghost/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,11 @@ locals {
fqdn = "${var.subdomain}.${var.root_zone_name}"
}

resource "azurerm_service_plan" "tikjob_plan" {
name = "tikjob-${var.env_name}-plan"
location = var.resource_group_location
resource_group_name = var.resource_group_name

os_type = "Linux"
sku_name = "B1"
}

resource "azurerm_linux_web_app" "tikjob_ghost" {
name = "tikjob-${var.env_name}-app-ghost"
location = var.resource_group_location
resource_group_name = var.resource_group_name
service_plan_id = azurerm_service_plan.tikjob_plan.id
service_plan_id = var.tikweb_app_plan_id

https_only = true

Expand Down
4 changes: 4 additions & 0 deletions modules/recruiting/ghost/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,7 @@ variable "dkim_selector" {
variable "dkim_key" {
type = string
}

variable "tikweb_app_plan_id" {
type = string
}
2 changes: 1 addition & 1 deletion modules/tenttiarkisto/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ resource "azurerm_linux_web_app" "tenttiarkisto" {
name = "tenttiarkisto-${var.env_name}-app"
location = var.resource_group_location
resource_group_name = azurerm_resource_group.tenttiarkisto_rg.name
service_plan_id = var.aux_app_plan_id
service_plan_id = var.tikweb_app_plan_id

https_only = true

Expand Down
2 changes: 1 addition & 1 deletion modules/tenttiarkisto/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ variable "postgres_server_host" {
type = string
}

variable "aux_app_plan_id" {
variable "tikweb_app_plan_id" {
type = string
}

Expand Down

0 comments on commit d575771

Please sign in to comment.