mirror of
https://github.com/terraform-aws-modules/terraform-aws-eks.git
synced 2025-09-09 19:32:58 +08:00
416515a0da
* feat!: Upgrade min AWS provider and Terraform versions to `6.0` and `1.5.7` respectively * fix: Remove deprecated arguments in AWS v6.0 provider, upgrade Helm provider to v3.0, bump VPC module to v6.0 * fix: Remove `aws-auth` sub-module * fix: Remove `platform` and `cluster_service_ipv4_cidr` variables from `user-data` sub-module * fix: Resolve all marked `todos` that have been accumulated * fix: Set default `http_put_response_hop_limit` to `1` * fix: Remove IRSA support from Karpenter sub-module * fix: Avoid making GET requests from data sources unless absolutely necessary * feat: Add variable optional attribute definitions * feat: Bump KMS key module version to latest, add remaining variable attribute definitions * fix: Remove `cluster_` prefix from variable names to better match the underlying API * fix: Move all EFA logic to the nodegroup itself * fix: Remove arguments that do not make sense in EKS * fix: Updates from plan validation * fix: Remove more self-managed node group attributes that are commonly not used in EKS clusters * fix: Remove data plane compute `*_defaults` variables that do not work with variable optional attributes * fix: Ignore changes to `bootstrap_self_managed_addons` to aid in upgrade * feat: Add support for `region` argument on relevant resources * feat: Initial pass on upgrade guide * fix: Updates from testing and validating EKS managed node group * fix: Updates from testing and validating self-managed node group * docs: Ensure addon ussage documented is aligned * feat: Switch to dualstack OIDC issuer URL * feat: Allow sourcing over overriding the Karpenter assume role policy * fix: Use `Bool` instead of `StringEquals` for DenyHTTP queue policy * fix: Correct use of `nullable` and default value propagation
166 lines
3.7 KiB
Terraform
166 lines
3.7 KiB
Terraform
provider "aws" {
|
|
region = local.region
|
|
}
|
|
|
|
data "aws_availability_zones" "available" {
|
|
# Exclude local zones
|
|
filter {
|
|
name = "opt-in-status"
|
|
values = ["opt-in-not-required"]
|
|
}
|
|
}
|
|
|
|
locals {
|
|
name = "ex-${basename(path.cwd)}"
|
|
kubernetes_version = "1.33"
|
|
region = "eu-west-1"
|
|
|
|
vpc_cidr = "10.0.0.0/16"
|
|
azs = slice(data.aws_availability_zones.available.names, 0, 3)
|
|
|
|
tags = {
|
|
Test = local.name
|
|
GithubRepo = "terraform-aws-eks"
|
|
GithubOrg = "terraform-aws-modules"
|
|
}
|
|
}
|
|
|
|
################################################################################
|
|
# EKS Module
|
|
################################################################################
|
|
|
|
module "eks" {
|
|
source = "../.."
|
|
|
|
name = local.name
|
|
kubernetes_version = local.kubernetes_version
|
|
endpoint_public_access = true
|
|
|
|
addons = {
|
|
kube-proxy = {}
|
|
vpc-cni = {}
|
|
coredns = {
|
|
configuration_values = jsonencode({
|
|
computeType = "fargate"
|
|
})
|
|
}
|
|
}
|
|
|
|
vpc_id = module.vpc.vpc_id
|
|
subnet_ids = module.vpc.private_subnets
|
|
control_plane_subnet_ids = module.vpc.intra_subnets
|
|
|
|
# Fargate profiles use the cluster primary security group so these are not utilized
|
|
create_security_group = false
|
|
create_node_security_group = false
|
|
|
|
fargate_profiles = {
|
|
example = {
|
|
name = "example"
|
|
selectors = [
|
|
{
|
|
namespace = "backend"
|
|
labels = {
|
|
Application = "backend"
|
|
}
|
|
},
|
|
{
|
|
namespace = "app-*"
|
|
labels = {
|
|
Application = "app-wildcard"
|
|
}
|
|
}
|
|
]
|
|
|
|
iam_role_additional_policies = {
|
|
additional = aws_iam_policy.additional.arn
|
|
}
|
|
|
|
# Using specific subnets instead of the subnets supplied for the cluster itself
|
|
subnet_ids = [module.vpc.private_subnets[1]]
|
|
|
|
tags = {
|
|
Owner = "secondary"
|
|
}
|
|
}
|
|
kube-system = {
|
|
selectors = [
|
|
{ namespace = "kube-system" }
|
|
]
|
|
}
|
|
}
|
|
|
|
tags = local.tags
|
|
}
|
|
|
|
################################################################################
|
|
# Sub-Module Usage on Existing/Separate Cluster
|
|
################################################################################
|
|
|
|
module "fargate_profile" {
|
|
source = "../../modules/fargate-profile"
|
|
|
|
name = "separate-fargate-profile"
|
|
cluster_name = module.eks.cluster_name
|
|
|
|
subnet_ids = module.vpc.private_subnets
|
|
selectors = [{
|
|
namespace = "kube-system"
|
|
}]
|
|
|
|
tags = merge(local.tags, { Separate = "fargate-profile" })
|
|
}
|
|
|
|
module "disabled_fargate_profile" {
|
|
source = "../../modules/fargate-profile"
|
|
|
|
create = false
|
|
}
|
|
|
|
################################################################################
|
|
# Supporting Resources
|
|
################################################################################
|
|
|
|
module "vpc" {
|
|
source = "terraform-aws-modules/vpc/aws"
|
|
version = "~> 6.0"
|
|
|
|
name = local.name
|
|
cidr = local.vpc_cidr
|
|
|
|
azs = local.azs
|
|
private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 4, k)]
|
|
public_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 48)]
|
|
intra_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 52)]
|
|
|
|
enable_nat_gateway = true
|
|
single_nat_gateway = true
|
|
|
|
public_subnet_tags = {
|
|
"kubernetes.io/role/elb" = 1
|
|
}
|
|
|
|
private_subnet_tags = {
|
|
"kubernetes.io/role/internal-elb" = 1
|
|
}
|
|
|
|
tags = local.tags
|
|
}
|
|
|
|
resource "aws_iam_policy" "additional" {
|
|
name = "${local.name}-additional"
|
|
|
|
policy = jsonencode({
|
|
Version = "2012-10-17"
|
|
Statement = [
|
|
{
|
|
Action = [
|
|
"ec2:Describe*",
|
|
]
|
|
Effect = "Allow"
|
|
Resource = "*"
|
|
},
|
|
]
|
|
})
|
|
}
|