Created
May 13, 2026 17:20
-
-
Save lucianosmori/010edbad27388d1361be7293ec40aa44 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| locals { | |
| watchdog_tasks = { | |
| "basic-int" = { | |
| image_key = "sysops_watchdogtest-basiceventpublish" | |
| image_name = "watchdogtest-basiceventpublish" | |
| description = "Task to monitor basic internal mqtt services every 10 minutes" | |
| cron = "cron(0/10 * * * ? *)" | |
| sg_key = "internal" | |
| settings = "/WatchDog/BasicEventPublish/Int" | |
| extra_env = {} | |
| } | |
| "basic-ext" = { | |
| image_key = "sysops_watchdogtest-basiceventpublish" | |
| image_name = "watchdogtest-basiceventpublish" | |
| description = "Task to monitor basic external mqtt services every 10 minutes" | |
| cron = "cron(4/10 * * * ? *)" | |
| sg_key = "internal" | |
| settings = "/WatchDog/BasicEventPublish/Ext" | |
| extra_env = {} | |
| } | |
| "emqx-int-1883" = { | |
| image_key = "sysops_watchdogtest-basiceventpublish-emqx" | |
| image_name = "watchdogtest-basiceventpublish-emqx" | |
| description = "Task to monitor EMQX internal mqtt services every 10 minutes" | |
| cron = "cron(0/10 * * * ? *)" | |
| sg_key = "internal" | |
| settings = "/WatchDog/BasicEventPublish/Int" | |
| extra_env = { | |
| brokerA = "emqx1.${var.route53_internal_domain}" | |
| brokerB = "emqx2.${var.route53_internal_domain}" | |
| brokerPort = "1883" | |
| } | |
| } | |
| "emqx-int-8083" = { | |
| image_key = "sysops_watchdogtest-basiceventpublish-emqx" | |
| image_name = "watchdogtest-basiceventpublish-emqx" | |
| description = "Task to monitor EMQX internal mqtt services every 10 minutes" | |
| cron = "cron(3/10 * * * ? *)" | |
| sg_key = "internal" | |
| settings = "/WatchDog/BasicEventPublish/Int" | |
| extra_env = { | |
| brokerA = "emqx1.${var.route53_internal_domain}" | |
| brokerB = "emqx2.${var.route53_internal_domain}" | |
| brokerPort = "8083" | |
| } | |
| } | |
| "emqx-ext-443" = { | |
| image_key = "sysops_watchdogtest-basiceventpublish-emqx" | |
| image_name = "watchdogtest-basiceventpublish-emqx" | |
| description = "Task to monitor EMQX external mqtt services every 10 minutes" | |
| cron = "cron(5/10 * * * ? *)" | |
| sg_key = "external" | |
| settings = "/WatchDog/BasicEventPublish/Ext" | |
| extra_env = { | |
| brokerA = "wss://mqtt-ws.${var.public_domain}/mqtt" | |
| brokerB = "wss://mqtt-ws.${var.public_domain}/mqtt" | |
| brokerPort = "443" | |
| } | |
| } | |
| "emqx-ext-8883" = { | |
| image_key = "sysops_watchdogtest-basiceventpublish-emqx" | |
| image_name = "watchdogtest-basiceventpublish-emqx" | |
| description = "Task to monitor EMQX external mqtt services every 10 minutes" | |
| cron = "cron(8/10 * * * ? *)" | |
| sg_key = "external" | |
| settings = "/WatchDog/BasicEventPublish/Ext" | |
| extra_env = { | |
| brokerA = "mqtt.${var.public_domain}" | |
| brokerB = "mqtt.${var.public_domain}" | |
| brokerPort = "8883" | |
| } | |
| } | |
| } | |
| } | |
| module "sysops-watchdog" { | |
| source = "../../modules/ecs_scheduled_task" | |
| for_each = local.watchdog_tasks | |
| task_name = "sysops-watchdog-${each.key}" | |
| description = each.value.description | |
| company_prefix = var.company_prefix | |
| deploy_env = var.deploy_env | |
| region_tag = var.region_tag | |
| schedule_expression = each.value.cron | |
| schedule_timezone = var.ecs_schedule_timezone | |
| container_image = "${local.ecr_registry}/${each.value.image_name}:${var.ecs_image_tags[each.value.image_key]}" | |
| enabled = true | |
| cluster_arn = module.ecs_cluster_watchdog.cluster_arn | |
| subnets = module.network.vpc.private_subnets | |
| security_groups = [module.security_groups.web_service_sgs[each.value.sg_key].security_group_id] | |
| eventbridge_role_arn = aws_iam_role.eventbridge_scheduler.arn | |
| execution_role_arn = var.ecs_task_execution_role_arn | |
| task_role_arn = var.ecs_task_role_arn | |
| environment_variables = merge( | |
| { | |
| region = var.aws_region | |
| settingsPath = each.value.settings | |
| }, | |
| each.value.extra_env | |
| ) | |
| tags = { | |
| Project = "devops" | |
| Criticality = "core" | |
| PII = "false" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment