Amruth VVKP
12/20/2022, 8:08 PMMason Menges
12/21/2022, 6:51 PMAmruth VVKP
12/21/2022, 8:59 PMMason Menges
12/21/2022, 9:12 PMAmruth VVKP
12/21/2022, 10:02 PM# ECS Task Definition for Prefect's Orchestrator task
resource "aws_ecs_task_definition" "prefect_orchestrator_task" {
family = var.prefect_orchestrator_name
cpu = var.agent_cpu
memory = var.agent_memory
requires_compatibilities = ["FARGATE"]
network_mode = "awsvpc"
// Execution role allows ECS to create tasks and services
execution_role_arn = data.aws_iam_role.ecs_task_execution_role.arn
// Task role allows tasks and services to access other AWS resources
task_role_arn = data.aws_iam_role.prefect_orchestrator_role.arn
container_definitions = jsonencode([
{
name = "${var.prefect_orchestrator_name}-task-definition"
image = "${var.orchestrator_image}" # var.orchestrator_image = prefecthq/prefect:2-latest
command = ["prefect", "orion", "start", "--host", "0.0.0.0", "--log-level", "WARNING"]
essential = true
cpu = "${var.agent_cpu}"
memory = "${var.agent_memory}"
portMappings = [
{
name = var.orchestrator_service_port_name
containerPort = var.prefect_port # var.prefect_port = 4200
hostPort = var.prefect_port
appProtocol = "http"
}
]
environment = [
{
name = "PREFECT_API_URL "
value = "<http://0.0.0.0>:${var.prefect_port}/api"
},
{
name = "PREFECT_ORION_API_HOST "
value = "0.0.0.0"
},
{
name = "PREFECT_ORION_API_PORT "
value = tostring("${var.prefect_port}")
}
]
secrets = [
{
name = "PREFECT_ORION_DATABASE_CONNECTION_URL"
valueFrom = "${aws_secretsmanager_secret.prefect_postgres_db_connection.arn}"
}
]
logConfiguration = {
logDriver = "awslogs"
options = {
awslogs-group = "${aws_cloudwatch_log_group.prefect_orchestrator_log_group.name}"
awslogs-region = "${data.aws_region.current.name}"
awslogs-stream-prefix = "${var.prefect_orchestrator_name}"
}
}
}
])
}
The environment variables from the ECS task looks as set (refer screenshot)
Orion startup logs attached as screenshot