Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions infrastructure/modules/container-apps/jobs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,37 @@ module "db_setup" {
]

}

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"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably need --noinput

]
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
]

}