Skip to content

native-cube/terraform-aws-eks-node-group

Repository files navigation

GitHub release (latest by date)

terraform-aws-eks-node-group

Terraform module to provision EKS Managed Node Group

Usage

module "eks-node-group" {
  source = "native-cube/eks-node-group/aws"
  version = "~> 1.1.0"

  cluster_name = aws_eks_cluster.cluster.id

  node_group_name_prefix = "eks-cluster-"

  subnet_ids = ["subnet-1","subnet-2","subnet-3"]

  desired_size = 1
  min_size     = 1
  max_size     = 1

  instance_types = ["t3.large","t2.large"]
  capacity_type  = "SPOT"

  ec2_ssh_key = "eks-test"

  labels = {
    lifecycle = "Spot"
  }

  taints = [
    {
      key    = "test-1"
      value  = null
      effect = "NO_SCHEDULE"
    },
    {
      key    = "test-2"
      value  = "value-test"
      effect = "NO_EXECUTE"
    }
  ]

  force_update_version = true

  tags = {
    Environment = "test"
  }
}

Examples

Requirements

Name Version
terraform >= 1.0.0
aws >= 4.64.0

Providers

Name Version
aws >= 4.64.0

Modules

No modules.

Resources

Name Type
aws_eks_node_group.main resource
aws_eks_node_group.main_create_before_destroy resource
aws_iam_role.main resource

Inputs

Name Description Type Default Required
ami_release_version AMI version of the EKS Node Group. Defaults to latest version for Kubernetes version string null no
ami_type Type of Amazon Machine Image (AMI) associated with the EKS Node Group. Valid values: AL2_x86_64 | AL2_x86_64_GPU | AL2_ARM_64 | CUSTOM | BOTTLEROCKET_ARM_64 | BOTTLEROCKET_x86_64. Terraform will only perform drift detection if a configuration value is provided. string null no
capacity_type Type of capacity associated with the EKS Node Group. Defaults to ON_DEMAND. Valid values: ON_DEMAND, SPOT. string "ON_DEMAND" no
cluster_name The name of the EKS cluster. string n/a yes
create_before_destroy Create new node group before destroying an old one. To be used with node_group_name_prefix argument. bool false no
create_iam_role Create IAM role for node group. Set to false if pass node_role_arn as an argument bool true no
desired_size Desired number of worker nodes. number n/a yes
disk_size Disk size in GiB for worker nodes. Defaults to 20. Terraform will only perform drift detection if a configuration value is provided. number null no
ec2_ssh_key EC2 Key Pair name that provides access for SSH communication with the worker nodes in the EKS Node Group. If you specify this configuration, but do not specify source_security_group_ids when you create an EKS Node Group, port 22 on the worker nodes is opened to the Internet (0.0.0.0/0). string null no
enable_iam_role_ssm_policy Enable addition of managed policy called AmazonSSMManagedInstanceCore to enable SSM monitoring. bool true no
force_update_version Force version update if existing pods are unable to be drained due to a pod disruption budget issue. bool false no
instance_types List of instance types associated with the EKS Node Group. Terraform will only perform drift detection if a configuration value is provided list(string) null no
kubernetes_version Kubernetes version. Defaults to EKS Cluster Kubernetes version. Terraform will only perform drift detection if a configuration value is provided string null no
labels Key-value mapping of Kubernetes labels. Only labels that are applied with the EKS API are managed by this argument. Other Kubernetes labels applied to the EKS Node Group will not be managed map(string) {} no
launch_template Configuration block with Launch Template settings. name, id and version parameters are available. map(string) {} no
max_size Maximum number of worker nodes. number n/a yes
min_size Minimum number of worker nodes. number n/a yes
node_group_name The name of the cluster node group. Defaults to <cluster_name>- string null no
node_group_name_prefix Creates a unique name beginning with the specified prefix. Conflicts with node_group_name string null no
node_group_role_name The name of the cluster node group role. Defaults to <cluster_name>-managed-group-node string null no
node_role_arn IAM role arn that will be used by managed node group. string null no
source_security_group_ids Set of EC2 Security Group IDs to allow SSH access (port 22) from on the worker nodes. If you specify ec2_ssh_key, but do not specify this configuration when you create an EKS Node Group, port 22 on the worker nodes is opened to the Internet (0.0.0.0/0) list(string) null no
subnet_ids A list of subnet IDs to launch resources in. list(string) n/a yes
tags A map of tags (key-value pairs) passed to resources. map(string) {} no
taints List of objects containing Kubernetes taints which will be applied to the nodes in the node group. Maximum of 50 taints per node group. list(object({ key = string, value = any, effect = string })) [] no
timeouts Create, update, and delete timeout configurations for the node group map(string) {} no
update_config Update config configuration block which is a key-value map. Accepted argmuents are max_unavailable and max_unavailable_percentage. map(any) {} no

Outputs

Name Description
iam_role_arn IAM role ARN used by node group.
iam_role_id IAM role ID used by node group.
node_group Outputs from EKS node group. See aws_eks_node_group Terraform documentation for values

License

See LICENSE for full details.

Pre-commit hooks

Install dependencies

MacOS

brew install pre-commit terraform-docs tflint

brew tap git-chglog/git-chglog
brew install git-chglog