README.md

May 22, 2026 Β· View on GitHub

Project Banner

Latest ReleaseLast UpdatedSlack CommunityGet Support

Terraform module to provision an EKS cluster on AWS.

This Terraform module provisions a fully configured AWS EKS (Elastic Kubernetes Service) cluster. It's engineered to integrate smoothly with Karpenter and EKS addons, forming a critical part of Cloud Posse's reference architecture. Ideal for teams looking to deploy scalable and manageable Kubernetes clusters on AWS with minimal fuss.

Tip

πŸ‘½ Use Atmos with Terraform

Cloud Posse uses atmos to easily orchestrate multiple environments using Terraform.
Works with Github Actions, Atlantis, or Spacelift.

Watch demo of using Atmos with Terraform
Example of running atmos to manage infrastructure from our Quick Start tutorial.

Introduction

The module provisions the following resources:

  • EKS cluster of master nodes that can be used together with the terraform-aws-eks-node-group and terraform-aws-eks-fargate-profile modules to create a full-blown EKS/Kubernetes cluster. You can also use the terraform-aws-eks-workers module to provision worker nodes for the cluster, but it is now rare for that to be a better choice than to use terraform-aws-eks-node-group.
  • IAM Role to allow the cluster to access other AWS services
  • EKS access entries to allow IAM users to access and administer the cluster

Usage

For a complete example, see examples/complete.

For automated tests of the complete example using bats and Terratest (which tests and deploys the example on AWS), see test/src.

Other examples:

  provider "aws" {
    region = var.region
  }

  # Note: This example creates an explicit access entry for the current user,
  # but in practice, you should use a static map of IAM users or roles that should have access to the cluster.
  # Granting access to the current user in this way is not recommended for production use.
  data "aws_caller_identity" "current" {}

  # IAM session context converts an assumed role ARN into an IAM Role ARN.
  # Again, this is primarily to simplify the example, and in practice, you should use a static map of IAM users or roles.
  data "aws_iam_session_context" "current" {
    arn = data.aws_caller_identity.current.arn
  }

  locals {
    # The usage of the specific kubernetes.io/cluster/* resource tags below are required
    # for EKS and Kubernetes to discover and manage networking resources
    # https://aws.amazon.com/premiumsupport/knowledge-center/eks-vpc-subnet-discovery/
    # https://github.com/kubernetes-sigs/aws-load-balancer-controller/blob/main/docs/deploy/subnet_discovery.md
    tags = { "kubernetes.io/cluster/${module.label.id}" = "shared" }

    # required tags to make ALB ingress work https://docs.aws.amazon.com/eks/latest/userguide/alb-ingress.html
    public_subnets_additional_tags = {
      "kubernetes.io/role/elb" : 1
    }
    private_subnets_additional_tags = {
      "kubernetes.io/role/internal-elb" : 1
    }

    # Enable the IAM user creating the cluster to administer it,
    # without using the bootstrap_cluster_creator_admin_permissions option,
    # as an example of how to use the access_entry_map feature.
    # In practice, this should be replaced with a static map of IAM users or roles
    # that should have access to the cluster, but we use the current user
    # to simplify the example.
    access_entry_map = {
      (data.aws_iam_session_context.current.issuer_arn) = {
        access_policy_associations = {
          ClusterAdmin = {}
        }
      }
    }
  }

  module "label" {
    source = "cloudposse/label/null"
    # Cloud Posse recommends pinning every module to a specific version
    # version  = "x.x.x"

    namespace  = var.namespace
    name       = var.name
    stage      = var.stage
    delimiter  = var.delimiter
    tags       = var.tags
  }

  module "vpc" {
    source = "cloudposse/vpc/aws"
    # Cloud Posse recommends pinning every module to a specific version
    # version     = "x.x.x"

    ipv4_primary_cidr_block = "172.16.0.0/16"

    tags    = local.tags
    context = module.label.context
  }

  module "subnets" {
    source = "cloudposse/dynamic-subnets/aws"
    # Cloud Posse recommends pinning every module to a specific version
    # version     = "x.x.x"

    availability_zones   = var.availability_zones
    vpc_id               = module.vpc.vpc_id
    igw_id               = [module.vpc.igw_id]
    ipv4_cidr_block      = [module.vpc.vpc_cidr_block]
    nat_gateway_enabled  = true
    nat_instance_enabled = false

    public_subnets_additional_tags  = local.public_subnets_additional_tags
    private_subnets_additional_tags = local.private_subnets_additional_tags

    tags    = local.tags
    context = module.label.context
  }

  module "eks_node_group" {
    source = "cloudposse/eks-node-group/aws"
    # Cloud Posse recommends pinning every module to a specific version
    # version     = "x.x.x"

    instance_types    = [var.instance_type]
    subnet_ids        = module.subnets.private_subnet_ids
    health_check_type = var.health_check_type
    min_size          = var.min_size
    max_size          = var.max_size
    cluster_name      = module.eks_cluster.eks_cluster_id

    # Enable the Kubernetes cluster auto-scaler to find the auto-scaling group
    cluster_autoscaler_enabled = var.autoscaling_policies_enabled

    context = module.label.context
  }

  module "eks_cluster" {
    source = "cloudposse/eks-cluster/aws"
    # Cloud Posse recommends pinning every module to a specific version
    # version = "x.x.x"

    subnet_ids            = concat(module.subnets.private_subnet_ids, module.subnets.public_subnet_ids)
    kubernetes_version    = var.kubernetes_version
    oidc_provider_enabled = true

    addons = [
      # https://docs.aws.amazon.com/eks/latest/userguide/managing-vpc-cni.html#vpc-cni-latest-available-version
      {
        addon_name                  = "vpc-cni"
        addon_version               = var.vpc_cni_version
        resolve_conflicts_on_create = "OVERWRITE"
        resolve_conflicts_on_update = "OVERWRITE"
        service_account_role_arn    = var.vpc_cni_service_account_role_arn # Creating this role is outside the scope of this example
      },
      # https://docs.aws.amazon.com/eks/latest/userguide/managing-kube-proxy.html
      {
        addon_name                  = "kube-proxy"
        addon_version               = var.kube_proxy_version
        resolve_conflicts_on_create = "OVERWRITE"
        resolve_conflicts_on_update = "OVERWRITE"
        service_account_role_arn    = null
      },
      # https://docs.aws.amazon.com/eks/latest/userguide/managing-coredns.html
      {
        addon_name                  = "coredns"
        addon_version               = var.coredns_version
        resolve_conflicts_on_create = "OVERWRITE"
        resolve_conflicts_on_update = "OVERWRITE"
        service_account_role_arn    = null
      },
    ]
    addons_depends_on = [module.eks_node_group]

    context = module.label.context

    cluster_depends_on = [module.subnets]
  }

Module usage with two unmanaged worker groups:

  locals {
    # Unfortunately, the `aws_ami` data source attribute `most_recent` (https://github.com/cloudposse/terraform-aws-eks-workers/blob/34a43c25624a6efb3ba5d2770a601d7cb3c0d391/main.tf#L141)
    # does not work as you might expect. If you are not going to use a custom AMI you should
    # use the `eks_worker_ami_name_filter` variable to set the right kubernetes version for EKS workers,
    # otherwise the first version of Kubernetes supported by AWS (v1.11) for EKS workers will be selected, but the
    # EKS control plane will ignore it to use one that matches the version specified by the `kubernetes_version` variable.
    eks_worker_ami_name_filter = "amazon-eks-node-${var.kubernetes_version}*"
  }

  module "eks_workers" {
    source = "cloudposse/eks-workers/aws"
    # Cloud Posse recommends pinning every module to a specific version
    # version     = "x.x.x"

    attributes                         = ["small"]
    instance_type                      = "t3.small"
    eks_worker_ami_name_filter         = local.eks_worker_ami_name_filter
    vpc_id                             = module.vpc.vpc_id
    subnet_ids                         = module.subnets.public_subnet_ids
    health_check_type                  = var.health_check_type
    min_size                           = var.min_size
    max_size                           = var.max_size
    wait_for_capacity_timeout          = var.wait_for_capacity_timeout
    cluster_name                       = module.label.id
    cluster_endpoint                   = module.eks_cluster.eks_cluster_endpoint
    cluster_certificate_authority_data = module.eks_cluster.eks_cluster_certificate_authority_data
    cluster_security_group_id          = module.eks_cluster.eks_cluster_managed_security_group_id

    # Auto-scaling policies and CloudWatch metric alarms
    autoscaling_policies_enabled           = var.autoscaling_policies_enabled
    cpu_utilization_high_threshold_percent = var.cpu_utilization_high_threshold_percent
    cpu_utilization_low_threshold_percent  = var.cpu_utilization_low_threshold_percent

    context = module.label.context
  }

  module "eks_workers_2" {
    source = "cloudposse/eks-workers/aws"
    # Cloud Posse recommends pinning every module to a specific version
    # version     = "x.x.x"

    attributes                         = ["medium"]
    instance_type                      = "t3.medium"
    eks_worker_ami_name_filter         = local.eks_worker_ami_name_filter
    vpc_id                             = module.vpc.vpc_id
    subnet_ids                         = module.subnets.public_subnet_ids
    health_check_type                  = var.health_check_type
    min_size                           = var.min_size
    max_size                           = var.max_size
    wait_for_capacity_timeout          = var.wait_for_capacity_timeout
    cluster_name                       = module.label.id
    cluster_endpoint                   = module.eks_cluster.eks_cluster_endpoint
    cluster_certificate_authority_data = module.eks_cluster.eks_cluster_certificate_authority_data
    cluster_security_group_id          = module.eks_cluster.eks_cluster_managed_security_group_id

    # Auto-scaling policies and CloudWatch metric alarms
    autoscaling_policies_enabled           = var.autoscaling_policies_enabled
    cpu_utilization_high_threshold_percent = var.cpu_utilization_high_threshold_percent
    cpu_utilization_low_threshold_percent  = var.cpu_utilization_low_threshold_percent

    context = module.label.context
  }

  module "eks_cluster" {
    source = "cloudposse/eks-cluster/aws"
    # Cloud Posse recommends pinning every module to a specific version
    # version     = "x.x.x"

    subnet_ids            = concat(module.subnets.private_subnet_ids, module.subnets.public_subnet_ids)
    kubernetes_version    = var.kubernetes_version
    oidc_provider_enabled = true # needed for VPC CNI

    access_entries_for_nodes = {
      EC2_LINUX = [module.eks_workers.workers_role_arn, module.eks_workers_2.workers_role_arn]
    }

    context = module.label.context
  }

Warning

Release 4.0.0 contains major breaking changes that will require you to update your existing EKS cluster and configuration to use this module. Please see the v3 to v4 migration path for more information. Release 2.0.0 (previously released as version 0.45.0) contains some changes that, if applied to a cluster created with an earlier version of this module, could result in your existing EKS cluster being replaced (destroyed and recreated). To prevent this, follow the instructions in the v1 to v2 migration path.

Note

Prior to v4 of this module, AWS did not provide an API to manage access to the EKS cluster, causing numerous challenges. With v4 of this module, it exclusively uses the AWS API, resolving many issues you may read about that had affected prior versions. See the version 2 README and release notes for more information on the challenges and workarounds that were required prior to v3.

EKS Auto Mode

This module supports EKS Auto Mode (GA December 2024), which delegates compute, networking, and storage management to AWS. Enable it using the auto_mode_compute_config, auto_mode_storage_config, and auto_mode_elastic_load_balancing variables.

Enabling Auto Mode

module "eks_cluster" {
  source  = "cloudposse/eks-cluster/aws"
  # version = "..."

  auto_mode_compute_config = {
    enabled       = true
    node_pools    = ["general-purpose", "system"]
    node_role_arn = aws_iam_role.auto_mode_node.arn
  }

  auto_mode_storage_config = {
    block_storage = {
      enabled = true
    }
  }

  auto_mode_elastic_load_balancing = {
    enabled = true
  }

  # ... other configuration
}

When Auto Mode is enabled, this module automatically:

  • Sets bootstrap_self_managed_addons = false (unless explicitly overridden)
  • Adds sts:TagSession to the cluster IAM role trust policy
  • Attaches 4 additional IAM policies to the cluster role: AmazonEKSComputePolicy, AmazonEKSBlockStoragePolicy, AmazonEKSLoadBalancingPolicy, and AmazonEKSNetworkingPolicy

Auto Mode Managed Add-ons

When Auto Mode is enabled, AWS manages the following add-ons automatically:

Add-onVariableWhat AWS Manages
Computeauto_mode_compute_configNode provisioning via managed Karpenter
Storageauto_mode_storage_configEBS volumes via ebs.csi.eks.amazonaws.com
Networkingauto_mode_elastic_load_balancingALB/NLB for Services and Ingress

Important Notes

  • Requires AWS provider >= 5.79.0 and Kubernetes >= 1.29
  • Auto Mode manages vpc-cni, kube-proxy, coredns, and aws-ebs-csi-driver add-ons automatically. Do not include these in the addons variable when Auto Mode is enabled.
  • Auto Mode nodes are Bottlerocket-only, immutable, with no SSH/IMDS access
  • Nodes have a 21-day maximum lifetime and are automatically rotated
  • The node_role_arn in auto_mode_compute_config must be an IAM role with AmazonEKSWorkerNodeMinimalPolicy and AmazonEC2ContainerRegistryPullOnly attached

Cluster Version Upgrades

With Auto Mode, Kubernetes version upgrades are simplified:

  1. Bump kubernetes_version and apply -- control plane upgrades in place
  2. Managed Karpenter detects version drift and automatically replaces nodes
  3. Auto Mode-managed add-ons are automatically upgraded to compatible versions

Important

In Cloud Posse's examples, we avoid pinning modules to specific versions to prevent discrepancies between the documentation and the latest released versions. However, for your own projects, we strongly advise pinning each module to the exact version you're using. This practice ensures the stability of your infrastructure. Additionally, we recommend implementing a systematic approach for updating versions to avoid unexpected changes.

Requirements

NameVersion
terraform>= 1.3.0
aws>= 6.25.0
tls>= 3.1.0, != 4.0.0

Providers

NameVersion
aws>= 6.25.0
tls>= 3.1.0, != 4.0.0

Modules

NameSourceVersion
capability_labelcloudposse/label/null0.25.0
labelcloudposse/label/null0.25.0
thiscloudposse/label/null0.25.0

Resources

NameType
aws_cloudwatch_log_group.defaultresource
aws_eks_access_entry.linuxresource
aws_eks_access_entry.mapresource
aws_eks_access_entry.standardresource
aws_eks_access_entry.windowsresource
aws_eks_access_policy_association.listresource
aws_eks_access_policy_association.mapresource
aws_eks_addon.clusterresource
aws_eks_capability.defaultresource
aws_eks_cluster.defaultresource
aws_iam_openid_connect_provider.defaultresource
aws_iam_policy.cluster_elb_service_roleresource
aws_iam_role.capabilityresource
aws_iam_role.defaultresource
aws_iam_role_policy_attachment.amazon_eks_cluster_policyresource
aws_iam_role_policy_attachment.amazon_eks_service_policyresource
aws_iam_role_policy_attachment.auto_moderesource
aws_iam_role_policy_attachment.cluster_elb_service_roleresource
aws_kms_alias.clusterresource
aws_kms_key.clusterresource
aws_vpc_security_group_ingress_rule.custom_ingress_rulesresource
aws_vpc_security_group_ingress_rule.managed_ingress_cidr_blocksresource
aws_vpc_security_group_ingress_rule.managed_ingress_security_groupsresource
aws_iam_policy_document.assume_roledata source
aws_iam_policy_document.capability_assume_roledata source
aws_iam_policy_document.cluster_elb_service_roledata source
aws_partition.currentdata source
tls_certificate.clusterdata source

Inputs

NameDescriptionTypeDefaultRequired
access_configAccess configuration for the EKS cluster.
object({
authentication_mode = optional(string, "API")
bootstrap_cluster_creator_admin_permissions = optional(bool, false)
})
{}no
access_entriesList of IAM principles to allow to access the EKS cluster.
It is recommended to use the default user_name because the default includes
the IAM role or user name and the session name for assumed roles.
Use when Principal ARN is not known at plan time.
list(object({
principal_arn = string
user_name = optional(string, null)
kubernetes_groups = optional(list(string), null)
}))
[]no
access_entries_for_nodesMap of list of IAM roles for the EKS non-managed worker nodes.
The map key is the node type, either EC2_LINUX or EC2_WINDOWS,
and the list contains the IAM roles of the nodes of that type.
There is no need for or utility in creating Fargate access entries, as those
are always created automatically by AWS, just as with managed nodes.
Use when Principal ARN is not known at plan time.
map(list(string)){}no
access_entry_mapMap of IAM Principal ARNs to access configuration.
Preferred over other inputs as this configuration remains stable
when elements are added or removed, but it requires that the Principal ARNs
and Policy ARNs are known at plan time.
Can be used along with other access_* inputs, but do not duplicate entries.
Map access_policy_associations keys are policy ARNs, policy
full name (AmazonEKSViewPolicy), or short name (View).
It is recommended to use the default user_name because the default includes
IAM role or user name and the session name for assumed roles.
As a special case in support of backwards compatibility, membership in the
system:masters group is is translated to an association with the ClusterAdmin policy.
In all other cases, including any system:* group in kubernetes_groups is prohibited.
map(object({
# key is principal_arn
user_name = optional(string)
# Cannot assign "system:*" groups to IAM users, use ClusterAdmin and Admin instead
kubernetes_groups = optional(list(string), [])
type = optional(string, "STANDARD")
access_policy_associations = optional(map(object({
# key is policy_arn or policy_name
access_scope = optional(object({
type = optional(string, "cluster")
namespaces = optional(list(string))
}), {}) # access_scope
})), {}) # access_policy_associations
}))
{}no
access_policy_associationsList of AWS managed EKS access policies to associate with IAM principles.
Use when Principal ARN or Policy ARN is not known at plan time.
policy_arn can be the full ARN, the full name (AmazonEKSViewPolicy) or short name (View).
list(object({
principal_arn = string
policy_arn = string
access_scope = optional(object({
type = optional(string, "cluster")
namespaces = optional(list(string))
}), {})
}))
[]no
additional_tag_mapAdditional key-value pairs to add to each map in tags_as_list_of_maps. Not added to tags or id.
This is for some rare cases where resources want additional configuration of tags
and therefore take a list of maps with tag key, value, and additional configuration.
map(string){}no
addonsManages aws_eks_addon resources.
Note: resolve_conflicts is deprecated. If resolve_conflicts is set and
resolve_conflicts_on_create or resolve_conflicts_on_update is not set,
resolve_conflicts will be used instead. If resolve_conflicts_on_create is
not set and resolve_conflicts is PRESERVE, resolve_conflicts_on_create
will be set to NONE.
If additional_tags are specified, they are added to the standard resource tags.
list(object({
addon_name = string
addon_version = optional(string, null)
configuration_values = optional(string, null)
# resolve_conflicts is deprecated, but we keep it for backwards compatibility
# and because if not declared, Terraform will silently ignore it.
resolve_conflicts = optional(string, null)
resolve_conflicts_on_create = optional(string, null)
resolve_conflicts_on_update = optional(string, null)
service_account_role_arn = optional(string, null)
pod_identity_association = optional(map(string), {})
create_timeout = optional(string, null)
update_timeout = optional(string, null)
delete_timeout = optional(string, null)
additional_tags = optional(map(string), {})
}))
[]no
addons_depends_onIf provided, all addons will depend on this object, and therefore not be installed until this object is finalized.
This is useful if you want to ensure that addons are not applied before some other condition is met, e.g. node groups are created.
See issue #170 for more details.
anynullno
allowed_cidr_blocksA list of IPv4 CIDRs to allow access to the cluster.
The length of this list must be known at "plan" time.
list(string)[]no
allowed_security_group_idsA list of IDs of Security Groups to allow access to the cluster.list(string)[]no
associated_security_group_idsA list of IDs of Security Groups to associate the cluster with.
These security groups will not be modified.
list(string)[]no
attributesID element. Additional attributes (e.g. workers or cluster) to add to id,
in the order they appear in the list. New attributes are appended to the
end of the list. The elements of the list are joined by the delimiter
and treated as a single ID element.
list(string)[]no
auto_mode_compute_configEKS Auto Mode compute configuration. When enabled, AWS manages node
provisioning via managed Karpenter.
object({
enabled = optional(bool, false)
node_pools = optional(set(string), ["general-purpose", "system"])
node_role_arn = optional(string, null)
})
{}no
auto_mode_elastic_load_balancingEKS Auto Mode elastic load balancing configuration. When enabled,
AWS manages ALB/NLB creation for Services and Ingress resources.
object({
enabled = optional(bool, false)
})
{}no
auto_mode_storage_configEKS Auto Mode storage configuration. When block_storage is enabled,
AWS manages EBS volumes via the ebs.csi.eks.amazonaws.com provisioner.
object({
block_storage = optional(object({
enabled = optional(bool, false)
}), {})
})
{}no
bootstrap_self_managed_addons_enabledManages bootstrap of default networking addons after cluster has been created. Must be false when Auto Mode is enabled. Changing this forces cluster recreation.boolnullno
capabilitiesMap of EKS Capabilities to enable on the cluster. Each key is the capability
name (must be unique within the cluster). Supported types: ACK, ARGOCD, KRO.

When create_iam_role is true (default) and role_arn is null, an IAM
role with a trust policy for capabilities.eks.amazonaws.com is
automatically created. Set create_iam_role = false and provide role_arn
when the calling module creates its own IAM roles (avoids plan-time unknowns).

The configuration block is only applicable to ARGOCD capabilities.
ACK and KRO do not currently support configuration.
map(object({
enabled = optional(bool, true)
type = string # ACK, ARGOCD, KRO
create_iam_role = optional(bool, true)
role_arn = optional(string, null)
delete_propagation_policy = optional(string, "RETAIN")
configuration = optional(object({
argo_cd = optional(object({
namespace = optional(string, "argocd")
aws_idc = optional(object({
idc_instance_arn = string
idc_region = optional(string, null)
}), null)
network_access = optional(object({
vpce_ids = optional(list(string), [])
}), null)
rbac_role_mapping = optional(list(object({
role = string # ADMIN, EDITOR, VIEWER
identity = list(object({
id = string
type = string # SSO_USER, SSO_GROUP
}))
})), [])
}), null)
}), null)
create_timeout = optional(string, null)
update_timeout = optional(string, null)
delete_timeout = optional(string, null)
}))
{}no
cloudwatch_log_group_classSpecified the log class of the log group. Possible values are: STANDARD or INFREQUENT_ACCESSstringnullno
cloudwatch_log_group_kms_key_idIf provided, the KMS Key ID to use to encrypt AWS CloudWatch logsstringnullno
cluster_attributesOverride label module default cluster attributeslist(string)
[
"cluster"
]
no
cluster_depends_onIf provided, the EKS will depend on this object, and therefore not be created until this object is finalized.
This is useful if you want to ensure that the cluster is not created before some other condition is met, e.g. VPNs into the subnet are created.
anynullno
cluster_encryption_config_enabledSet to true to enable Cluster Encryption Configurationbooltrueno
cluster_encryption_config_kms_key_deletion_window_in_daysCluster Encryption Config KMS Key Resource argument - key deletion windows in days post destructionnumber10no
cluster_encryption_config_kms_key_enable_key_rotationCluster Encryption Config KMS Key Resource argument - enable kms key rotationbooltrueno
cluster_encryption_config_kms_key_idKMS Key ID to use for cluster encryption configstring""no
cluster_encryption_config_kms_key_policyCluster Encryption Config KMS Key Resource argument - key policystringnullno
cluster_encryption_config_resourcesCluster Encryption Config Resources to encrypt, e.g. ['secrets']list(any)
[
"secrets"
]
no
cluster_log_retention_periodNumber of days to retain cluster logs. Requires enabled_cluster_log_types to be set. See https://docs.aws.amazon.com/en_us/eks/latest/userguide/control-plane-logs.html.number0no
contextSingle object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as null to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional_tag_map, which are merged.
any
{
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"descriptor_formats": {},
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"labels_as_tags": [
"unset"
],
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {},
"tenant": null
}
no
create_eks_service_roleSet false to use existing eks_cluster_service_role_arn instead of creating onebooltrueno
custom_ingress_rulesA List of Objects, which are custom security group rules that
list(object({
description = string
from_port = number
to_port = number
protocol = string
source_security_group_id = string
}))
[]no
deletion_protection_enabledWhether to enable deletion protection for the cluster. When enabled, the cluster cannot be deleted unless deletion protection is first disabled.boolfalseno
delimiterDelimiter to be used between ID elements.
Defaults to - (hyphen). Set to "" to use no delimiter at all.
stringnullno
descriptor_formatsDescribe additional descriptors to be output in the descriptors output map.
Map of maps. Keys are names of descriptors. Values are maps of the form
{<br/> format = string<br/> labels = list(string)<br/>}
(Type is any so the map values can later be enhanced to provide additional options.)
format is a Terraform format string to be passed to the format() function.
labels is a list of labels, in order, to pass to format() function.
Label values will be normalized before being passed to format() so they will be
identical to how they appear in id.
Default is {} (descriptors output will be empty).
any{}no
eks_cluster_service_role_arnThe ARN of an IAM role for the EKS cluster to use that provides permissions
for the Kubernetes control plane to perform needed AWS API operations.
Required if create_eks_service_role is false, ignored otherwise.
stringnullno
enabledSet to false to prevent the module from creating any resourcesboolnullno
enabled_cluster_log_typesA list of the desired control plane logging to enable. For more information, see https://docs.aws.amazon.com/en_us/eks/latest/userguide/control-plane-logs.html. Possible values [api, audit, authenticator, controllerManager, scheduler]list(string)[]no
endpoint_private_accessIndicates whether or not the Amazon EKS private API server endpoint is enabled. Default to AWS EKS resource and it is falseboolfalseno
endpoint_public_accessIndicates whether or not the Amazon EKS public API server endpoint is enabled. Default to AWS EKS resource and it is truebooltrueno
environmentID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT'stringnullno
id_length_limitLimit id to this many characters (minimum 6).
Set to 0 for unlimited length.
Set to null for keep the existing setting, which defaults to 0.
Does not affect id_full.
numbernullno
kubernetes_network_ipv6_enabledSet true to use IPv6 addresses for Kubernetes pods and servicesboolfalseno
kubernetes_versionDesired Kubernetes master version. If you do not specify a value, the latest available version is usedstring"1.21"no
label_key_caseControls the letter case of the tags keys (label names) for tags generated by this module.
Does not affect keys of tags passed in via the tags input.
Possible values: lower, title, upper.
Default value: title.
stringnullno
label_orderThe order in which the labels (ID elements) appear in the id.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present.
list(string)nullno
label_value_caseControls the letter case of ID elements (labels) as included in id,
set as tag values, and output by this module individually.
Does not affect values of tags passed in via the tags input.
Possible values: lower, title, upper and none (no transformation).
Set this to title and set delimiter to "" to yield Pascal Case IDs.
Default value: lower.
stringnullno
labels_as_tagsSet of labels (ID elements) to include as tags in the tags output.
Default is to include all labels.
Tags with empty values will not be included in the tags output.
Set to [] to suppress all generated tags.
Notes:
The value of the name tag, if included, will be the id, not the name.
Unlike other null-label inputs, the initial setting of labels_as_tags cannot be
changed in later chained modules. Attempts to change it will be silently ignored.
set(string)
[
"default"
]
no
managed_security_group_rules_enabledFlag to enable/disable the ingress and egress rules for the EKS managed Security Groupbooltrueno
nameID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
This is the only ID element not also included as a tag.
The "name" tag is set to the full id string. There is no tag with the value of the name input.
stringnullno
namespaceID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally uniquestringnullno
oidc_provider_enabledCreate an IAM OIDC identity provider for the cluster, then you can create IAM roles to associate with a
service account in the cluster, instead of using kiam or kube2iam. For more information,
see EKS User Guide.
boolfalseno
permissions_boundaryIf provided, all IAM roles will be created with this permissions boundary attachedstringnullno
public_access_cidrsIndicates which CIDR blocks can access the Amazon EKS public API server endpoint when enabled. EKS defaults this to a list with 0.0.0.0/0.list(string)
[
"0.0.0.0/0"
]
no
regex_replace_charsTerraform regular expression (regex) string.
Characters matching the regex will be removed from the ID elements.
If not set, "/[^a-zA-Z0-9-]/" is used to remove all characters other than hyphens, letters and digits.
stringnullno
regionOBSOLETE (not needed): AWS Regionstringnullno
remote_network_configConfiguration block for the cluster remote network configuration
object({
remote_node_networks_cidrs = list(string)
remote_pod_networks_cidrs = optional(list(string))
})
nullno
service_ipv4_cidrThe CIDR block to assign Kubernetes service IP addresses from.
You can only specify a custom CIDR block when you create a cluster, changing this value will force a new cluster to be created.
stringnullno
stageID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release'stringnullno
subnet_idsA list of subnet IDs to launch the cluster inlist(string)n/ayes
tagsAdditional tags (e.g. {'BusinessUnit': 'XYZ'}).
Neither the tag keys nor the tag values will be modified by this module.
map(string){}no
tenantID element _(Rarely used, not included by default)_. A customer identifier, indicating who this instance of a resource is forstringnullno
upgrade_policyConfiguration block for the support policy to use for the cluster
object({
support_type = optional(string, null)
})
nullno
zonal_shift_configConfiguration block with zonal shift configuration for the cluster
object({
enabled = optional(bool, null)
})
nullno

Outputs

NameDescription
auto_mode_enabledWhether EKS Auto Mode is enabled (all three capabilities: compute, storage, networking)
capabilitiesMap of enabled EKS Capabilities with their ARNs and types
capability_role_arnsMap of auto-created capability IAM role ARNs
cloudwatch_log_group_kms_key_idKMS Key ID to encrypt AWS CloudWatch logs
cloudwatch_log_group_nameThe name of the log group created in cloudwatch where cluster logs are forwarded to if enabled
cluster_encryption_config_enabledIf true, Cluster Encryption Configuration is enabled
cluster_encryption_config_provider_key_aliasCluster Encryption Config KMS Key Alias ARN
cluster_encryption_config_provider_key_arnCluster Encryption Config KMS Key ARN
cluster_encryption_config_resourcesCluster Encryption Config Resources
eks_addons_versionsMap of enabled EKS Addons names and versions
eks_cluster_arnThe Amazon Resource Name (ARN) of the cluster
eks_cluster_certificate_authority_dataThe Kubernetes cluster certificate authority data
eks_cluster_endpointThe endpoint for the Kubernetes API server
eks_cluster_idThe name of the cluster
eks_cluster_identity_oidc_issuerThe OIDC Identity issuer for the cluster
eks_cluster_identity_oidc_issuer_arnThe OIDC Identity issuer ARN for the cluster that can be used to associate IAM roles with a service account
eks_cluster_ipv4_service_cidrThe IPv4 CIDR block that Kubernetes pod and service IP addresses are assigned from
if kubernetes_network_ipv6_enabled is set to false. If set to true this output will be null.
eks_cluster_ipv6_service_cidrThe IPv6 CIDR block that Kubernetes pod and service IP addresses are assigned from
if kubernetes_network_ipv6_enabled is set to true. If set to false this output will be null.
eks_cluster_managed_security_group_idSecurity Group ID that was created by EKS for the cluster.
EKS creates a Security Group and applies it to the ENI that are attached to EKS Control Plane master nodes and to any managed workloads.
eks_cluster_role_arnARN of the EKS cluster IAM role
eks_cluster_versionThe Kubernetes server version of the cluster

Check out these related projects.

Tip

Use Terraform Reference Architectures for AWS

Use Cloud Posse's ready-to-go terraform architecture blueprints for AWS to get up and running quickly.

βœ… We build it together with your team.
βœ… Your team owns everything.
βœ… 100% Open Source and backed by fanatical support.

Request Quote

πŸ“š Learn More

Cloud Posse is the leading DevOps Accelerator for funded startups and enterprises.

Your team can operate like a pro today.

Ensure that your team succeeds by using Cloud Posse's proven process and turnkey blueprints. Plus, we stick around until you succeed.

Day-0: Your Foundation for Success

  • Reference Architecture. You'll get everything you need from the ground up built using 100% infrastructure as code.
  • Deployment Strategy. Adopt a proven deployment strategy with GitHub Actions, enabling automated, repeatable, and reliable software releases.
  • Site Reliability Engineering. Gain total visibility into your applications and services with Datadog, ensuring high availability and performance.
  • Security Baseline. Establish a secure environment from the start, with built-in governance, accountability, and comprehensive audit logs, safeguarding your operations.
  • GitOps. Empower your team to manage infrastructure changes confidently and efficiently through Pull Requests, leveraging the full power of GitHub Actions.

Request Quote

Day-2: Your Operational Mastery

  • Training. Equip your team with the knowledge and skills to confidently manage the infrastructure, ensuring long-term success and self-sufficiency.
  • Support. Benefit from a seamless communication over Slack with our experts, ensuring you have the support you need, whenever you need it.
  • Troubleshooting. Access expert assistance to quickly resolve any operational challenges, minimizing downtime and maintaining business continuity.
  • Code Reviews. Enhance your team’s code quality with our expert feedback, fostering continuous improvement and collaboration.
  • Bug Fixes. Rely on our team to troubleshoot and resolve any issues, ensuring your systems run smoothly.
  • Migration Assistance. Accelerate your migration process with our dedicated support, minimizing disruption and speeding up time-to-value.
  • Customer Workshops. Engage with our team in weekly workshops, gaining insights and strategies to continuously improve and innovate.

Request Quote

✨ Contributing

This project is under active development, and we encourage contributions from our community.

Many thanks to our outstanding contributors:

For πŸ› bug reports & feature requests, please use the issue tracker.

In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.

  1. Review our Code of Conduct and Contributor Guidelines.
  2. Fork the repo on GitHub
  3. Clone the project to your own machine
  4. Commit changes to your own branch
  5. Push your work back up to your fork
  6. Submit a Pull Request so that we can review your changes

NOTE: Be sure to merge the latest changes from "upstream" before making a pull request!

Running Terraform Tests

We use Atmos to streamline how Terraform tests are run. It centralizes configuration and wraps common test workflows with easy-to-use commands.

All tests are located in the test/ folder.

Under the hood, tests are powered by Terratest together with our internal Test Helpers library, providing robust infrastructure validation.

Setup dependencies:

To run tests:

  • Run all tests:
    atmos test run
    
  • Clean up test artifacts:
    atmos test clean
    
  • Explore additional test options:
    atmos test --help
    

The configuration for test commands is centrally managed. To review what's being imported, see the atmos.yaml file.

Learn more about our automated testing in our documentation or implementing custom commands with atmos.

🌎 Slack Community

Join our Open Source Community on Slack. It's FREE for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally sweet infrastructure.

πŸ“° Newsletter

Sign up for our newsletter and join 3,000+ DevOps engineers, CTOs, and founders who get insider access to the latest DevOps trends, so you can always stay in the know. Dropped straight into your Inbox every week β€” and usually a 5-minute read.

πŸ“† Office Hours

Join us every Wednesday via Zoom for your weekly dose of insider DevOps trends, AWS news and Terraform insights, all sourced from our SweetOps community, plus a live Q&A that you can’t find anywhere else. It's FREE for everyone!

License

License

Preamble to the Apache License, Version 2.0

Complete license is available in the LICENSE file.

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

  https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.

Trademarks

All other trademarks referenced herein are the property of their respective owners.


Copyright Β© 2017-2026 Cloud Posse, LLC

README footer

Beacon