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 7, 2023
1 parent 9f62be5 commit cfa2645
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 21 deletions.
19 changes: 14 additions & 5 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ 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
tikweb_rg_location = module.common.resource_group_location
tikweb_rg_name = module.common.resource_group_name
}

module "ilmo" {
Expand All @@ -154,7 +157,9 @@ 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
tikweb_rg_location = module.common.resource_group_location
tikweb_rg_name = module.common.resource_group_name
dns_resource_group_name = module.dns_prod.resource_group_name
root_zone_name = module.dns_prod.root_zone_name
subdomain = "ilmo"
Expand Down Expand Up @@ -182,7 +187,9 @@ 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
tikweb_app_plan_rg_location = module.common.resource_group_location
tikweb_app_plan_rg_name = module.common.resource_group_name
django_secret_key = module.keyvault.tenttiarkisto_django_secret_key
}

Expand All @@ -205,6 +212,9 @@ module "tikjob_app" {
env_name = "prod"
resource_group_name = module.tikjob_storage.resource_group_name
resource_group_location = module.tikjob_storage.resource_group_location
tikweb_app_plan_id = module.common.tikweb_app_plan_id
tikweb_rg_name = module.common.resource_group_name
tikweb_rg_location = module.common.resource_group_location
ghost_front_url = "https://rekry.tietokilta.fi"

mysql_db_name = module.tikjob_storage.mysql_db_name
Expand All @@ -226,9 +236,8 @@ 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"
dkim_selector = "mta"
dkim_key = "k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYQLHt0gzozEScD5nNockttK0D0r6MejAOgMBj0e++DtDev9OvTJru5ZtKFlLGXxf3b7GWvV10X5kCT0D2HD/vDfaokZ+EL58lRWg7qlz10XBN/7XDTgPDbDuCBC3mH9W8DeI38omNCT+8fgzVvCjHUfYlvf3dMOn4Ow7zeAZ5yQIDAQAB"
}

module "forum" {
Expand Down
6 changes: 3 additions & 3 deletions modules/cms/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ resource "azurerm_service_plan" "tikweb_plan" {

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
location = var.tikweb_rg_location
resource_group_name = var.tikweb_rg_name
service_plan_id = var.tikweb_app_plan_id

https_only = true

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

variable "tikweb_app_plan_id" {
type = string
}

variable "tikweb_rg_name" {
type = string
}

variable "tikweb_rg_location" {
type = string
}
15 changes: 11 additions & 4 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 Down Expand Up @@ -60,6 +57,16 @@ resource "azurerm_service_plan" "aux_plan" {
sku_name = "B1"
}

# 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 = "B2"
}

resource "tls_private_key" "acme_account_key" {
algorithm = "RSA"
rsa_bits = 4096
Expand Down
8 changes: 7 additions & 1 deletion modules/common/output.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
output "resource_group_name" {
value = azurerm_resource_group.tikweb_rg.name
}

output "resource_group_location" {
value = azurerm_resource_group.tikweb_rg.location
}
output "postgres_server_name" {
value = azurerm_postgresql_server.tikweb_pg.name
}
Expand All @@ -23,6 +25,10 @@ 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" {
value = acme_registration.acme_reg.account_key_pem
sensitive = true
Expand Down
6 changes: 3 additions & 3 deletions modules/ilmo/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ resource "azurerm_service_plan" "ilmo_backend_plan" {

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
location = var.tikweb_rg_location
resource_group_name = var.tikweb_rg_name
service_plan_id = var.tikweb_app_plan_id

https_only = true

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

variable "tikweb_app_plan_id" {
type = string
}

variable "tikweb_rg_name" {
type = string
}

variable "tikweb_rg_location" {
type = string
}
2 changes: 1 addition & 1 deletion modules/recruiting/ghost/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ 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
12 changes: 12 additions & 0 deletions modules/recruiting/ghost/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,15 @@ variable "dkim_selector" {
variable "dkim_key" {
type = string
}

variable "tikweb_app_plan_id" {
type = string
}

variable "tikweb_rg_name" {
type = string
}

variable "tikweb_rg_location" {
type = string
}
6 changes: 3 additions & 3 deletions modules/tenttiarkisto/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ resource "azurerm_storage_container" "tenttiarkisto_storage_container" {

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
location = var.tikweb_app_plan_rg_location
resource_group_name = var.tikweb_app_plan_rg_name
service_plan_id = var.tikweb_app_plan_id

https_only = true

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

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

variable "tikweb_app_plan_rg_name" {
type = string
}

variable "tikweb_app_plan_rg_location" {
type = string
}

Expand Down

0 comments on commit cfa2645

Please sign in to comment.