Skip to content

Commit 9fc94de

Browse files
committed
PPHA-369: Add db migration job on deploy
1 parent 8c5242d commit 9fc94de

File tree

1 file changed

+29
-0
lines changed
  • infrastructure/modules/container-apps

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module "db_setup" {
2+
source = "../dtos-devops-templates/infrastructure/modules/container-app-job"
3+
4+
name = "${var.app_short_name}-dbm-${var.environment}"
5+
container_app_environment_id = var.container_app_environment_id
6+
resource_group_name = azurerm_resource_group.main.name
7+
8+
container_command = ["/bin/sh", "-c"]
9+
10+
container_args = [
11+
"python manage.py migrate"
12+
]
13+
secret_variables = var.deploy_database_as_container ? { DATABASE_PASSWORD = resource.random_password.admin_password[0].result } : {}
14+
docker_image = var.docker_image
15+
user_assigned_identity_ids = flatten([
16+
[module.azure_blob_storage_identity.id],
17+
[module.azure_queue_storage_identity.id],
18+
var.deploy_database_as_container ? [] : [module.db_connect_identity[0].id]
19+
])
20+
environment_variables = merge(
21+
local.common_env,
22+
var.deploy_database_as_container ? local.container_db_env : local.azure_db_env
23+
)
24+
depends_on = [
25+
module.queue_storage_role_assignment,
26+
module.blob_storage_role_assignment
27+
]
28+
29+
}

0 commit comments

Comments
 (0)