provider "aws" { region = var.region } data "aws_eks_cluster" "cluster" { name = module.eks.cluster_id } data "aws_eks_cluster_auth" "cluster" { name = module.eks.cluster_id } provider "kubernetes" { host = data.aws_eks_cluster.cluster.endpoint cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data) token = data.aws_eks_cluster_auth.cluster.token load_config_file = false } data "aws_availability_zones" "available" { } locals { cluster_name = "test-eks-lt-${random_string.suffix.result}" } resource "random_string" "suffix" { length = 8 special = false } module "vpc" { source = "terraform-aws-modules/vpc/aws" version = "~> 2.47" name = "test-vpc" cidr = "172.16.0.0/16" azs = data.aws_availability_zones.available.names private_subnets = ["172.16.1.0/24", "172.16.2.0/24", "172.16.3.0/24"] public_subnets = ["172.16.4.0/24", "172.16.5.0/24", "172.16.6.0/24"] enable_nat_gateway = true single_nat_gateway = true enable_dns_hostnames = true private_subnet_tags = { "kubernetes.io/cluster/${local.cluster_name}" = "shared" # EKS adds this and TF would want to remove then later } } module "eks" { source = "../.." cluster_name = local.cluster_name cluster_version = "1.20" subnets = module.vpc.private_subnets vpc_id = module.vpc.vpc_id node_groups = { example = { desired_capacity = 1 max_capacity = 15 min_capacity = 1 launch_template_id = aws_launch_template.default.id launch_template_version = aws_launch_template.default.default_version additional_tags = { CustomTag = "EKS example" } } } }