-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjobs.tf
More file actions
63 lines (54 loc) · 2.31 KB
/
jobs.tf
File metadata and controls
63 lines (54 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
module "db_setup" {
source = "../dtos-devops-templates/infrastructure/modules/container-app-job"
name = "${var.app_short_name}-dbm-${var.environment}"
container_app_environment_id = var.container_app_environment_id
resource_group_name = azurerm_resource_group.main.name
container_command = ["/bin/sh", "-c"]
container_args = [
"python manage.py migrate"
]
secret_variables = var.deploy_database_as_container ? { DATABASE_PASSWORD = resource.random_password.admin_password[0].result } : {}
docker_image = var.docker_image
user_assigned_identity_ids = flatten([
[module.azure_blob_storage_identity.id],
[module.azure_queue_storage_identity.id],
var.deploy_database_as_container ? [] : [module.db_connect_identity[0].id]
])
environment_variables = merge(
local.common_env,
var.deploy_database_as_container ? local.container_db_env : local.azure_db_env
)
depends_on = [
module.queue_storage_role_assignment,
module.blob_storage_role_assignment
]
}
module "flush_database" {
source = "../dtos-devops-templates/infrastructure/modules/container-app-job"
# We need to be able to flush the db on a daily basis in POC to ensure
# We can test the service in a clean state. DO NOT ADD THIS TO OTHER ENVIRONMENTS.
count = var.environment == "poc" ? 1 : 0
name = "${var.app_short_name}-flush-db-${var.environment}"
container_app_environment_id = var.container_app_environment_id
resource_group_name = azurerm_resource_group.main.name
container_command = ["/bin/sh", "-c"]
container_args = [
"python manage.py flush"
]
cron_expression = "0 6 * * *" # Run at 6am every day
secret_variables = var.deploy_database_as_container ? { DATABASE_PASSWORD = resource.random_password.admin_password[0].result } : {}
docker_image = var.docker_image
user_assigned_identity_ids = flatten([
[module.azure_blob_storage_identity.id],
[module.azure_queue_storage_identity.id],
var.deploy_database_as_container ? [] : [module.db_connect_identity[0].id]
])
environment_variables = merge(
local.common_env,
var.deploy_database_as_container ? local.container_db_env : local.azure_db_env
)
depends_on = [
module.queue_storage_role_assignment,
module.blob_storage_role_assignment
]
}