Terraform module to schedule a task on an existing container instance in ECS
This is meant to be called from the same terraform that deploys your service container to ECS.
The command you call must be available in the container, this scheduled task is basically launching the container with an alternate entrypoint.
Containers run this way can only log to datadog via firelens. No splunk logging is possible. The "add_datadog_feed = false" bit is referencing IONA's legacy datadog logging system, the "firelens_configuration" bit is the part that logs to datadog for us.
Sample call:
module "scheduled_task" {
source = "ION-Analytics/ecs-scheduled-task/iona"
providers = {
aws = aws.cluster_provider
}
task_role_arn = module.ecs_service.task_role_arn
command = ["/bin/sh","-c","ls", "/"]
schedule_expression = "cron(*/3 * * * ? *)"
name_suffix = "task_001"
image_build_details = var.docker
env = terraform.workspace
ecs_cluster = local.ecs_cluster
release = var.release
image_id = var.docker["image"]
platform_config = module.platform_config.config
add_datadog_feed = false
allow_overnight_scaledown = false
common_application_environment = var.common_application_environment
application_environment = var.application_environment
application_secrets = var.application_secrets
port = var.port
cpu = var.cpu
memory = var.memory
deployment_circuit_breaker = {
enable = true
rollback = false
}
firelens_configuration = module.log-config.firelens_config
log_configuration = module.log-config.log_config
task_role_policy = jsonencode({
Version = "2012-10-17",
Statement = [
{
Effect = "Allow",
Resource = "*",
Action = "ec2:DescribeAvailabilityZones"
}
]
})
}