Skip to main content
Type: rvn-ecs-cluster / Latest version: 2.5.1

Dependencies and consumers

Every dependency input can be specified manually to reference existing external infrastructure rather than a Ravion module. Set the dependency input to null and set its mapped inputs directly; see Use existing infrastructure instead of a module reference.

Readme

Production-ready AWS ECS cluster with Fargate, Fargate Spot, optional EC2 capacity, and shared load balancers.

Overview

Amazon ECS (Elastic Container Service) runs containerized workloads on AWS. This module creates an ECS cluster inside your selected VPC and configures the capacity providers and shared load balancers that services can use. The ECS cluster module provides:
  • Fargate and Fargate Spot capacity providers for serverless containers
  • Optional EC2 capacity with an Auto Scaling Group and managed ECS capacity provider
  • Public and private Application Load Balancers for HTTP and HTTPS services
  • Public and private Network Load Balancers for TCP/UDP and static IP use cases
  • CloudWatch Container Insights dashboard metrics for production visibility
Terraform source: ravionhq/modules/compute/ecs_cluster

Use cases

Capacity providers

Fargate

Fargate runs containers without managing EC2 instances. It is the simplest option for most web apps, APIs, workers, and scheduled tasks.

Fargate Spot

Fargate Spot uses spare AWS capacity at a lower cost. It is best for interruptible workloads such as queues, batch jobs, background workers, and services that can tolerate replacement tasks.

EC2 capacity

EC2 capacity creates an Auto Scaling Group and ECS capacity provider for tasks that need host-level control, custom AMIs, SSH access, special networking, or lower long-running compute costs. Select an EC2 instance type to enable EC2 capacity. Leave it blank for a Fargate-only cluster.

Load balancers

Public application load balancer

Creates an internet-facing Application Load Balancer for services that should receive public HTTP or HTTPS traffic, such as websites, public APIs, and webhook endpoints. Use the public ALB for:
  • Websites and browser apps
  • Public APIs
  • Webhooks
  • HTTP/HTTPS traffic with host or path routing

Private application load balancer

Creates an internal Application Load Balancer for services reachable only inside the VPC or private network, such as internal APIs, admin tools, and service-to-service traffic. Use the private ALB for:
  • Internal APIs
  • Admin dashboards
  • Backend services
  • Private HTTP/HTTPS routing
For either ALB, the selected Certificate is the default HTTPS certificate. Use Additional certificate ARNs to attach more ACM certificates to the same listener through SNI.

Network load balancers

Use Network Load Balancers for TCP/UDP workloads, static IP requirements, very high-throughput connections, or protocols that do not need HTTP routing. For normal web apps and HTTP APIs, prefer an Application Load Balancer.

Observability

Container Insights collects ECS cluster, service, and task CPU, memory, network, and storage metrics in CloudWatch. The module dashboard includes:
  • CPU and memory used
  • Running task and service counts
  • Network received and sent
  • Storage read and write
  • EC2 container instance count
  • EC2 instance CPU, memory, running task, and reserved capacity metrics
Metrics appear only after tasks are running in the cluster. EC2-specific charts appear only when EC2 capacity exists and the required Container Insights instance metrics are available. Container Insights also feeds the service running-task alarms, which use the RunningTaskCount metric, so keep it enabled when services alarm on task count. Default log retention (days) is exposed as a stack output. Every ECS service that references this cluster inherits it as its log group retention unless the service sets its own value in its Compliance section.

Compliance

CloudWatch alarms for load balancer 5xx, target 5xx, and target response time are enabled by default on both ALBs. Thresholds, evaluation periods, and SNS actions are shared by both. Load balancer alarms cover the ALB-level metrics only. Per-service health, such as unhealthy targets and per-service error rates, is alarmed from each ECS service’s own Compliance section. Network Load Balancers have no alarms in this module.

Configuration

EC2 capacity settings

Design decisions

This ECS cluster follows AWS ECS production patterns:
  • Fargate-first defaults: Fargate and Fargate Spot are enabled so services can start without managing instances
  • EC2 opt-in: EC2 capacity is created only when an instance type is selected
  • Shared load balancers: Cluster-level ALBs and NLBs can be reused by services in the environment
  • Private subnet placement: ECS tasks and EC2 capacity use private subnets from the selected VPC
  • Public ingress by default: Public ALBs use Terraform’s default internet ingress unless overridden in Terraform
  • Private ingress by default: Private ALBs use Terraform’s default RFC1918 private CIDR ranges and no IPv6 ingress unless overridden
  • Enhanced Container Insights: Enhanced production metrics are collected by default for operational visibility

Learn more

Amazon ECS Load balancing and observability

Inputs reference

All inputs for rvn-ecs-cluster version 2.5.1. Use the name shown for each field as the input key in module config.
  • Inputs — Inputs, ECS cluster, Managed domains, Capacity providers, EC2 capacity, EC2 volume, Public application load balancer, Private application load balancer, Network load balancers, Compliance, Misc, Terraform settings