fargate-profile sub-module creates an aws_eks_fargate_profile resource plus the pod execution IAM role that Fargate requires. Selectors determine which pods EKS schedules on Fargate based on namespace and optional label matching.
Fargate profiles do not use EC2 instances. Every pod matched by a selector runs in its own isolated compute environment managed by AWS. There is no launch template, Auto Scaling Group, or node IAM role.
Usage
- Via root module (recommended)
- Standalone
- Multiple namespaces
Key inputs
Profile configuration
Name of the EKS Fargate Profile.
Name of the EKS cluster to attach the profile to.
Private subnet IDs for the Fargate profile. Fargate requires private subnets — pods must be able to reach the internet via NAT if outbound access is needed.
One or more selectors that define which pods run on Fargate. Each selector requires a
namespace and optionally a map of labels for further filtering. A pod must match all labels in a selector to be scheduled on Fargate.Terraform operation timeouts for profile creation and deletion.
IAM role
Create a new pod execution IAM role. Set to
false and provide iam_role_arn to use an existing role.ARN of an existing Fargate pod execution IAM role. Required when
create_iam_role = false.Name (or prefix) for the created IAM role.
Attach
AmazonEKS_CNI_Policy (IPv4) or AmazonEKS_CNI_IPv6_Policy (IPv6) to the pod execution role. Only disable if CNI permissions are granted by another method.Additional managed policies to attach to the pod execution role.
ARN of a permissions boundary policy to attach to the pod execution IAM role.
IP family of the cluster (
ipv4 or ipv6). Determines which CNI policy is attached.Tags applied to all resources created by this module.
Key outputs
| Output | Description |
|---|---|
fargate_profile_arn | ARN of the EKS Fargate Profile |
fargate_profile_id | Cluster name and Fargate profile name joined by : |
fargate_profile_status | Current status of the Fargate Profile |
fargate_profile_pod_execution_role_arn | ARN of the pod execution IAM role — same as iam_role_arn |
iam_role_arn | ARN of the pod execution IAM role |
iam_role_name | Name of the pod execution IAM role |
iam_role_unique_id | Stable unique ID of the IAM role |
Resources created
aws_eks_fargate_profile.this— the EKS Fargate Profileaws_iam_role.this— pod execution IAM role (Fargate service trust policy)aws_iam_role_policy.this— optional inline policy for custom permissionsaws_iam_role_policy_attachment.this— standard Fargate pod execution policiesaws_iam_role_policy_attachment.additional— any additional policies
Selector matching rules
How EKS evaluates selectors
How EKS evaluates selectors
When a pod is scheduled, EKS checks it against all Fargate profiles associated with the cluster:
- A pod is eligible for a profile if it matches at least one selector in the profile.
- A pod matches a selector when its namespace equals the selector’s
namespaceand its labels contain all key-value pairs in the selector’slabelsmap. - If a pod matches multiple profiles, EKS selects one non-deterministically.
- If no profile matches, the pod is scheduled on an EC2 node group (or remains pending if no node group exists).
