diff --git a/terraform/environments/example.tfvars b/terraform/environments/example.tfvars index 1d52be3..8d1a54e 100644 --- a/terraform/environments/example.tfvars +++ b/terraform/environments/example.tfvars @@ -50,22 +50,31 @@ meilisearch_master_key = "CHANGE_ME_MEILISEARCH_KEY" # Container Configuration # ======================================== -# ECS Fargate container resources -# CPU units (1024 = 1 vCPU). Options: 256, 512, 1024, 2048, 4096 -container_cpu = 1024 - -# Memory in MB. Valid combinations with CPU: +# Valid CPU/Memory combinations for Fargate: # CPU 256: 512, 1024, 2048 # CPU 512: 1024, 2048, 3072, 4096 # CPU 1024: 2048, 3072, 4096, 5120, 6144, 7168, 8192 # CPU 2048: 4096 to 16384 (1GB increments) # CPU 4096: 8192 to 30720 (1GB increments) -container_memory = 2048 -# ECS Service scaling configuration -desired_count = 2 # Number of tasks to run -min_capacity = 1 # Minimum tasks for auto-scaling -max_capacity = 10 # Maximum tasks for auto-scaling +# Web Service (handles HTTP requests) +container_cpu = 1024 # CPU units (1024 = 1 vCPU) +container_memory = 2048 # Memory in MB + +# Web service scaling configuration +desired_count = 2 # Number of tasks to run +min_capacity = 1 # Minimum tasks for auto-scaling +max_capacity = 10 # Maximum tasks for auto-scaling + +# Queue Worker (processes background jobs) +queue_worker_cpu = 512 # CPU units (512 = 0.5 vCPU) +queue_worker_memory = 1024 # Memory in MB +queue_worker_desired_count = 1 # Number of queue worker tasks + +# Scheduler (runs Laravel's cron/scheduled tasks) +scheduler_cpu = 256 # CPU units (256 = 0.25 vCPU) +scheduler_memory = 512 # Memory in MB +scheduler_desired_count = 1 # Number of scheduler tasks (typically 1) # ======================================== # Database Configuration diff --git a/terraform/main.tf b/terraform/main.tf index 907baf9..0664b33 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -232,11 +232,24 @@ module "compute" { s3_filesystem_bucket_name = module.storage.app_filesystem_bucket_name sqs_queue_name = module.messaging.queue_name caller_identity_account_id = data.aws_caller_identity.current.account_id - container_cpu = var.container_cpu - container_memory = var.container_memory - desired_count = var.desired_count - min_capacity = var.min_capacity - max_capacity = var.max_capacity + + # Web service configuration + container_cpu = var.container_cpu + container_memory = var.container_memory + desired_count = var.desired_count + min_capacity = var.min_capacity + max_capacity = var.max_capacity + + # Queue worker configuration + queue_worker_cpu = var.queue_worker_cpu + queue_worker_memory = var.queue_worker_memory + queue_worker_desired_count = var.queue_worker_desired_count + + # Scheduler configuration + scheduler_cpu = var.scheduler_cpu + scheduler_memory = var.scheduler_memory + scheduler_desired_count = var.scheduler_desired_count + meilisearch_host = var.enable_meilisearch ? module.meilisearch[0].meilisearch_host : "" meilisearch_master_key = var.enable_meilisearch ? var.meilisearch_master_key : "" redis_endpoint = module.cache.redis_endpoint diff --git a/terraform/modules/compute/main.tf b/terraform/modules/compute/main.tf index 3d05dce..80b7e74 100644 --- a/terraform/modules/compute/main.tf +++ b/terraform/modules/compute/main.tf @@ -120,9 +120,9 @@ locals { queue-worker = { enabled = var.enable_queue_worker container_role = "queue-worker" - cpu = var.container_cpu - memory = var.container_memory - desired_count = 1 + cpu = var.queue_worker_cpu + memory = var.queue_worker_memory + desired_count = var.queue_worker_desired_count port_mappings = [] health_check_grace = null deployment_config = {} @@ -131,9 +131,9 @@ locals { scheduler = { enabled = var.enable_scheduler container_role = "scheduler" - cpu = 256 - memory = 512 - desired_count = 1 + cpu = var.scheduler_cpu + memory = var.scheduler_memory + desired_count = var.scheduler_desired_count port_mappings = [] health_check_grace = null deployment_config = {} diff --git a/terraform/modules/compute/variables.tf b/terraform/modules/compute/variables.tf index 30238a2..3da3490 100644 --- a/terraform/modules/compute/variables.tf +++ b/terraform/modules/compute/variables.tf @@ -73,36 +73,84 @@ variable "caller_identity_account_id" { type = string } +# ======================================== +# Web Service Configuration +# ======================================== + variable "container_cpu" { - description = "CPU units for the container" + description = "CPU units for the web service container (256 = 0.25 vCPU, 512 = 0.5 vCPU, 1024 = 1 vCPU)" type = number default = 512 } variable "container_memory" { - description = "Memory for the container" + description = "Memory (MB) for the web service container" type = number default = 1024 } variable "desired_count" { - description = "Desired number of tasks" + description = "Desired number of web service tasks" type = number default = 2 } variable "min_capacity" { - description = "Minimum capacity for auto scaling" + description = "Minimum capacity for web service auto scaling" type = number default = 1 } variable "max_capacity" { - description = "Maximum capacity for auto scaling" + description = "Maximum capacity for web service auto scaling" type = number default = 10 } +# ======================================== +# Queue Worker Configuration +# ======================================== + +variable "queue_worker_cpu" { + description = "CPU units for the queue worker container (256 = 0.25 vCPU, 512 = 0.5 vCPU, 1024 = 1 vCPU)" + type = number + default = 512 +} + +variable "queue_worker_memory" { + description = "Memory (MB) for the queue worker container" + type = number + default = 1024 +} + +variable "queue_worker_desired_count" { + description = "Desired number of queue worker tasks" + type = number + default = 1 +} + +# ======================================== +# Scheduler Configuration +# ======================================== + +variable "scheduler_cpu" { + description = "CPU units for the scheduler container (256 = 0.25 vCPU, 512 = 0.5 vCPU)" + type = number + default = 256 +} + +variable "scheduler_memory" { + description = "Memory (MB) for the scheduler container" + type = number + default = 512 +} + +variable "scheduler_desired_count" { + description = "Desired number of scheduler tasks (typically 1)" + type = number + default = 1 +} + variable "meilisearch_host" { description = "Meilisearch host" type = string diff --git a/terraform/variables.tf b/terraform/variables.tf index 82b0ef8..88a30af 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -71,36 +71,75 @@ variable "meilisearch_master_key" { # Container Configuration # ======================================== +# Web Service (handles HTTP requests) variable "container_cpu" { - description = "CPU units for the container (1024 = 1 vCPU)" + description = "CPU units for the web service container (256 = 0.25 vCPU, 512 = 0.5 vCPU, 1024 = 1 vCPU)" type = number default = 512 } variable "container_memory" { - description = "Memory for the container in MB" + description = "Memory for the web service container in MB" type = number default = 1024 } variable "desired_count" { - description = "Desired number of tasks" + description = "Desired number of web service tasks" type = number default = 2 } variable "min_capacity" { - description = "Minimum number of tasks" + description = "Minimum number of web service tasks for auto scaling" type = number default = 1 } variable "max_capacity" { - description = "Maximum number of tasks" + description = "Maximum number of web service tasks for auto scaling" type = number default = 10 } +# Queue Worker (processes background jobs) +variable "queue_worker_cpu" { + description = "CPU units for the queue worker container (256 = 0.25 vCPU, 512 = 0.5 vCPU, 1024 = 1 vCPU)" + type = number + default = 512 +} + +variable "queue_worker_memory" { + description = "Memory for the queue worker container in MB" + type = number + default = 1024 +} + +variable "queue_worker_desired_count" { + description = "Desired number of queue worker tasks" + type = number + default = 1 +} + +# Scheduler (runs Laravel's cron/scheduled tasks) +variable "scheduler_cpu" { + description = "CPU units for the scheduler container (256 = 0.25 vCPU, 512 = 0.5 vCPU)" + type = number + default = 256 +} + +variable "scheduler_memory" { + description = "Memory for the scheduler container in MB" + type = number + default = 512 +} + +variable "scheduler_desired_count" { + description = "Desired number of scheduler tasks (typically 1)" + type = number + default = 1 +} + # ======================================== # Database Configuration # ========================================