locals { name = var.cluster_name cluster_version = "1.33" region = var.cluster_region serviceaccount_name = var.irsa_sa_name serviceaccount_namespace = var.irsa_sa_namespace } data "aws_caller_identity" "current" {} module "eks" { source = "terraform-aws-modules/eks/aws" version = "~> 21.0" name = local.name kubernetes_version = local.cluster_version compute_config = { enabled = true node_pools = ["general-purpose"] } vpc_id = module.vpc.vpc_id subnet_ids = module.vpc.private_subnets endpoint_private_access = true endpoint_public_access = true enable_irsa = true addons = { coredns = { most_recent = true } kube-proxy = { most_recent = true } vpc-cni = { most_recent = true } eks-pod-identity-agent = { most_recent = true } } access_entries = { tf-admin = { principal_arn = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/admin" policy_associations = { tf-admin = { policy_arn = "arn:aws:eks::aws:cluster-access-policy/AmazonEKSClusterAdminPolicy" access_scope = { type = "cluster" } } } } github-actions = { principal_arn = "arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/github-actions-external-secrets" policy_associations = { github-actions = { policy_arn = "arn:aws:eks::aws:cluster-access-policy/AmazonEKSClusterAdminPolicy" access_scope = { type = "cluster" } } } } } } ################################################################################ # Supporting resources ################################################################################ module "vpc" { source = "terraform-aws-modules/vpc/aws" version = "~> 6.0" name = local.name cidr = "10.0.0.0/16" azs = ["${local.region}a", "${local.region}b", "${local.region}c"] private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"] public_subnets = ["10.0.4.0/24", "10.0.5.0/24", "10.0.6.0/24"] enable_nat_gateway = true single_nat_gateway = true enable_dns_hostnames = true public_subnet_tags = { "kubernetes.io/cluster/${local.name}" = "shared" "kubernetes.io/role/elb" = 1 } private_subnet_tags = { "kubernetes.io/cluster/${local.name}" = "shared" "kubernetes.io/role/internal-elb" = 1 } }