splitting out background tasks

This commit is contained in:
2022-09-18 06:51:17 -07:00
parent 8b271e9e2a
commit 5017d9bc67
6 changed files with 287 additions and 244 deletions

View File

@@ -324,42 +324,12 @@ resource "aws_service_discovery_service" "background_worker_service" {
}
}
resource "aws_cloudwatch_event_rule" "square_import_job_schedule" {
name = "square-import-job-schedule"
schedule_expression = "cron(45 * * * ? *)"
}
resource "aws_cloudwatch_event_target" "square_import_job_target" {
target_id = "square-import-job"
arn = var.ecs_cluster
rule = aws_cloudwatch_event_rule.square_import_job_schedule.name
role_arn = "arn:aws:iam::679918342773:role/service-role/Amazon_EventBridge_Invoke_ECS_1758992733"
ecs_target {
task_count = 1
launch_type = "FARGATE"
# capacity_provider_strategy = [{capacity_provider = "FARGATE_SPOT"}]
task_definition_arn = aws_ecs_task_definition.integreat_background_worker.arn
network_configuration {
assign_public_ip = true
security_groups = [ "sg-004e5855310c453a3", "sg-02d167406b1082698"]
subnets = [ "subnet-5e675761", "subnet-8519fde2", "subnet-89bab8d4" ]
}
}
input = <<DOC
{
"containerOverrides": [
{
"name": "integreat-app",
"environment": [{"name": "INTEGREAT_JOB", "value": "square-import-job"},
{"name": "DD_CONTAINER_ENV_AS_TAGS", "value":"{\"INTEGREAT_JOB\":\"background_job\"}"},
{"name": "DD_SERVICE", "value": "square-import-job"}]
}
]
}
DOC
module "square_import_job" {
source = "./background-job/"
ecs_cluster = var.ecs_cluster
task_role_arn = var.task_role_arn
stage = var.stage
schedule = "rate(4 hours)"
job_name = "square-import-job"
execution_role_arn = var.execution_role_arn
}