Provision EKS master nodes

less than 1 minute read

List of AWS resources for EKS cluster

Many AWS resources are required for EKS cluster.

  • VPC resources
  • EC2 resources
  • IAM resources
  • EKS resources

Terraform module is the collection of many resources. Creating a module results the creation of its resources. We will use terraform modules here. https://registry.terraform.io/modules/terraform-aws-modules/eks/aws/7.0.0

provider "aws" {
  region = "ap-south-1"
  profile = "terraform-operator"
}

data "aws_availability_zones" "available" {

}

module "vpc" {
  source  = "terraform-aws-modules/vpc/aws"
  version = "2.6.0"
  name = "vpc-eks-test"
  cidr = "10.0.0.0/16"
  azs = data.aws_availability_zones.available.names
  public_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
  enable_dns_support = true # it will be used for Ingress
  enable_dns_hostnames = true
  tags = {
    "Name" = "vpc-eks-test"
  }
}

module "eks" {
  source  = "terraform-aws-modules/eks/aws"
  version = "7.0.0"
  # insert the 4 required variables here
  cluster_name = "eks-test"
  permissions_boundary = ""
  subnets = module.vpc.public_subnets
  vpc_id = module.vpc.vpc_id
}

Run following commands to Initialize the plugins, validate the terraform script, plan the deployment and then finally apply the changes.

$ terraform init
$ terraform validate
$ terraform plan
$ terraform apply

Next, we need to add worker node to EKS cluster..

Updated: