Prerequisites
- AWS credentials with permissions to create EKS, IAM, and VPC resources
- Terraform >= 1.5.7
- AWS provider >= 6.28
- A VPC with private subnets (Fargate pods run in private subnets only)
Example code
Thefargate_profiles map is defined inline on the module "eks" block. The following example creates a cluster with Fargate profiles for the default and kube-system namespaces, which is a common pattern for fully serverless clusters.
Complete VPC setup
For a self-contained deployment that also provisions the VPC:Key concepts
Fargate profile selectors
Each entry in theselectors list can specify:
namespace(required) — pods in this namespace are eligible for Fargatelabels(optional) — additional label filters; all specified labels must match
IAM roles for Fargate
The module creates a dedicated IAM execution role for each Fargate profile by default. You can share a single role across profiles by providing aniam_role_arn and setting create_iam_role = false.
CoreDNS on Fargate
When running a fully Fargate cluster (no EC2 nodes), CoreDNS must also run on Fargate. This requires patching the CoreDNS deployment to remove theeks.amazonaws.com/compute-type: ec2 annotation:
Deploy
1
Initialize Terraform
2
Review the plan
3
Apply
4
Configure kubectl
5
Verify Fargate nodes
Pods scheduled on Fargate appear as nodes with the
fargate- prefix.Key outputs
Limitations
- No DaemonSets — Fargate does not support DaemonSet workloads
- No privileged containers — pods running on Fargate cannot use
privileged: true - No hostPath volumes — only
emptyDir,configMap,secret, and persistent volume claims via EFS are supported - No GPU — Fargate does not support GPU instance types
- Regional availability — not all AWS regions or Availability Zones support Fargate
