Resource: aws_eks_fargate_profile

Manages an EKS Fargate Profile.

Example Usage

resource "aws_eks_fargate_profile" "example" {
  cluster_name           = aws_eks_cluster.example.name
  fargate_profile_name   = "example"
  pod_execution_role_arn = aws_iam_role.example.arn
  subnet_ids             = aws_subnet.example[*].id

  selector {
    namespace = "example"
  }
}

Example IAM Role for EKS Fargate Profile

resource "aws_iam_role" "example" {
  name = "eks-fargate-profile-example"

  assume_role_policy = jsonencode({
    Statement = [{
      Action = "sts:AssumeRole"
      Effect = "Allow"
      Principal = {
        Service = "eks-fargate-pods.amazonaws.com"
      }
    }]
    Version = "2012-10-17"
  })
}

resource "aws_iam_role_policy_attachment" "example-AmazonEKSFargatePodExecutionRolePolicy" {
  policy_arn = "arn:aws:iam::aws:policy/AmazonEKSFargatePodExecutionRolePolicy"
  role       = aws_iam_role.example.name
}

Argument Reference

The following arguments are required:

The following arguments are optional:

selector Configuration Block

The following arguments are required:

The following arguments are optional:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Timeouts

Configuration options:

Import

In Terraform v1.5.0 and later, use an import block to import EKS Fargate Profiles using the cluster_name and fargate_profile_name separated by a colon (:). For example:

import {
  to = aws_eks_fargate_profile.my_fargate_profile
  id = "my_cluster:my_fargate_profile"
}

Using terraform import, import EKS Fargate Profiles using the cluster_name and fargate_profile_name separated by a colon (:). For example:

% terraform import aws_eks_fargate_profile.my_fargate_profile my_cluster:my_fargate_profile