Skip to content

Commit

Permalink
fix: Update EKS module min version to fix race condition during destr…
Browse files Browse the repository at this point in the history
…oy (#1926)
  • Loading branch information
bryantbiggs authored Apr 22, 2024
1 parent bdbf6e3 commit 2630956
Show file tree
Hide file tree
Showing 27 changed files with 104 additions and 112 deletions.
5 changes: 0 additions & 5 deletions docs/_partials/destroy.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
```sh
# Necessary to avoid removing Terraform's permissions too soon before its finished
# cleaning up the resources it deployed inside the cluster
terraform state rm 'module.eks.aws_eks_access_entry.this["cluster_creator"]' || true
terraform state rm 'module.eks.aws_eks_access_policy_association.this["cluster_creator_admin"]' || true

terraform destroy -target="module.eks_blueprints_addons" -auto-approve
terraform destroy -target="module.eks" -auto-approve
terraform destroy -auto-approve
Expand Down
3 changes: 3 additions & 0 deletions docs/cSpell_dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ nics
nodegroup
nodeport
nvme
odcr
oidc
persistentvolume
pkce
Expand All @@ -125,6 +126,7 @@ readyz
reclaimpolicy
redop
replicaset
resourcegroups
rdmap
rolearn
rollouts
Expand All @@ -144,6 +146,7 @@ tcpdump
templatefile
tfstate
tfvars
timeadd
tolerations
tolist
toset
Expand Down
4 changes: 2 additions & 2 deletions patterns/agones-game-controller/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ locals {

module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 20.0"
version = "~> 20.8"

cluster_name = local.name
cluster_version = local.cluster_version
Expand Down Expand Up @@ -128,7 +128,7 @@ module "eks" {

module "eks_blueprints_addons" {
source = "aws-ia/eks-blueprints-addons/aws"
version = "~> 1.7"
version = "~> 1.16"

cluster_name = module.eks.cluster_name
cluster_endpoint = module.eks.cluster_endpoint
Expand Down
63 changes: 32 additions & 31 deletions patterns/aws-vpc-cni-network-policy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ locals {

module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 20.0"
version = "~> 20.8"

cluster_name = local.name
cluster_version = "1.29" # Must be 1.25 or higher
Expand All @@ -75,42 +75,13 @@ module "eks" {
tags = local.tags
}

################################################################################
# Supporting Resources
################################################################################

module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 5.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)]

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
}

################################################################################
# EKS Addons (demo application)
################################################################################

module "addons" {
source = "aws-ia/eks-blueprints-addons/aws"
version = "~> 1.0"
version = "~> 1.16"

cluster_name = module.eks.cluster_name
cluster_endpoint = module.eks.cluster_endpoint
Expand Down Expand Up @@ -288,5 +259,35 @@ resource "kubernetes_network_policy_v1" "allow_client_to_backend" {
}
}
}

depends_on = [module.addons]
}

################################################################################
# Supporting Resources
################################################################################

module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 5.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)]

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
}
4 changes: 2 additions & 2 deletions patterns/elastic-fabric-adapter/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ locals {

module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 20.4"
version = "~> 20.8"

cluster_name = local.name
cluster_version = "1.29"
Expand Down Expand Up @@ -134,7 +134,7 @@ module "eks" {

module "eks_blueprints_addons" {
source = "aws-ia/eks-blueprints-addons/aws"
version = "~> 1.14"
version = "~> 1.16"

cluster_name = module.eks.cluster_name
cluster_endpoint = module.eks.cluster_endpoint
Expand Down
4 changes: 2 additions & 2 deletions patterns/external-secrets/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ locals {

module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 20.0"
version = "~> 20.8"

cluster_name = local.name
cluster_version = "1.29"
Expand Down Expand Up @@ -90,7 +90,7 @@ module "eks" {

module "eks_blueprints_addons" {
source = "aws-ia/eks-blueprints-addons/aws"
version = "~> 1.14"
version = "~> 1.16"

cluster_name = module.eks.cluster_name
cluster_endpoint = module.eks.cluster_endpoint
Expand Down
4 changes: 2 additions & 2 deletions patterns/fargate-serverless/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ locals {

module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 20.0"
version = "~> 20.8"

cluster_name = local.name
cluster_version = "1.29"
Expand Down Expand Up @@ -96,7 +96,7 @@ module "eks" {

module "eks_blueprints_addons" {
source = "aws-ia/eks-blueprints-addons/aws"
version = "~> 1.14"
version = "~> 1.16"

cluster_name = module.eks.cluster_name
cluster_endpoint = module.eks.cluster_endpoint
Expand Down
2 changes: 1 addition & 1 deletion patterns/fully-private-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ locals {

module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 20.0"
version = "~> 20.8"

cluster_name = local.name
cluster_version = "1.29"
Expand Down
12 changes: 6 additions & 6 deletions patterns/gitops/multi-cluster-hub-spoke-argocd/hub/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ locals {
gitops_addons_revision = var.gitops_addons_revision

authentication_mode = var.authentication_mode

argocd_namespace = "argocd"

aws_addons = {
Expand Down Expand Up @@ -109,7 +109,7 @@ locals {
aws_vpc_id = module.vpc.vpc_id
},
{
argocd_namespace = local.argocd_namespace
argocd_namespace = local.argocd_namespace
},
{
addons_repo_url = local.gitops_addons_url
Expand Down Expand Up @@ -153,7 +153,7 @@ data "aws_iam_policy_document" "eks_assume" {
type = "Service"
identifiers = ["pods.eks.amazonaws.com"]
}
actions = ["sts:AssumeRole","sts:TagSession"]
actions = ["sts:AssumeRole", "sts:TagSession"]
}
}
resource "aws_iam_role" "argocd_hub" {
Expand All @@ -164,7 +164,7 @@ data "aws_iam_policy_document" "aws_assume_policy" {
statement {
effect = "Allow"
resources = ["*"]
actions = ["sts:AssumeRole","sts:TagSession"]
actions = ["sts:AssumeRole", "sts:TagSession"]
}
}
resource "aws_iam_policy" "aws_assume_policy" {
Expand Down Expand Up @@ -244,9 +244,9 @@ module "eks" {
subnet_ids = module.vpc.private_subnets

authentication_mode = local.authentication_mode

enable_cluster_creator_admin_permissions = true

eks_managed_node_groups = {
initial = {
instance_types = ["t3.medium"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ variable "addons" {
default = {
enable_aws_load_balancer_controller = true
enable_metrics_server = true
enable_argocd = true
enable_argocd = true
}
}

Expand Down
14 changes: 7 additions & 7 deletions patterns/gitops/multi-cluster-hub-spoke-argocd/spokes/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ locals {
gitops_workload_revision = var.gitops_workload_revision
gitops_workload_url = "${local.gitops_workload_org}/${local.gitops_workload_repo}"

authentication_mode = var.authentication_mode
authentication_mode = var.authentication_mode

aws_addons = {
enable_cert_manager = try(var.addons.enable_cert_manager, false)
enable_aws_efs_csi_driver = try(var.addons.enable_aws_efs_csi_driver, false)
Expand Down Expand Up @@ -194,7 +194,7 @@ resource "aws_iam_role" "spoke" {

data "aws_iam_policy_document" "assume_role_policy" {
statement {
actions = ["sts:AssumeRole","sts:TagSession"]
actions = ["sts:AssumeRole", "sts:TagSession"]
principals {
type = "AWS"
identifiers = [data.terraform_remote_state.cluster_hub.outputs.argocd_iam_role_arn]
Expand Down Expand Up @@ -254,7 +254,7 @@ module "eks" {

vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_subnets

authentication_mode = local.authentication_mode

# Cluster access entry
Expand All @@ -264,13 +264,13 @@ module "eks" {
access_entries = {
# One access entry with a policy associated
example = {
principal_arn = aws_iam_role.spoke.arn
principal_arn = aws_iam_role.spoke.arn

policy_associations = {
argocd = {
policy_arn = "arn:aws:eks::aws:cluster-access-policy/AmazonEKSClusterAdminPolicy"
access_scope = {
type = "cluster"
type = "cluster"
}
}
}
Expand All @@ -290,7 +290,7 @@ module "eks" {
cluster_addons = {
eks-pod-identity-agent = {
most_recent = true
}
}
vpc-cni = {
# Specify the VPC CNI addon should be deployed before compute to ensure
# the addon is configured before data plane compute resources are created
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ variable "authentication_mode" {
description = "The authentication mode for the cluster. Valid values are CONFIG_MAP, API or API_AND_CONFIG_MAP"
type = string
default = "API"
}
}
2 changes: 1 addition & 1 deletion patterns/ipv6-eks-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ locals {

module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 20.0"
version = "~> 20.8"

cluster_name = local.name
cluster_version = "1.29"
Expand Down
4 changes: 2 additions & 2 deletions patterns/istio/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ locals {

module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 20.0"
version = "~> 20.8"

cluster_name = local.name
cluster_version = "1.29"
Expand Down Expand Up @@ -117,7 +117,7 @@ resource "kubernetes_namespace_v1" "istio_system" {

module "eks_blueprints_addons" {
source = "aws-ia/eks-blueprints-addons/aws"
version = "~> 1.14"
version = "~> 1.16"

cluster_name = module.eks.cluster_name
cluster_endpoint = module.eks.cluster_endpoint
Expand Down
4 changes: 2 additions & 2 deletions patterns/karpenter/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ locals {

module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 20.0"
version = "~> 20.8"

cluster_name = local.name
cluster_version = "1.29"
Expand Down Expand Up @@ -102,7 +102,7 @@ module "eks" {

module "eks_blueprints_addons" {
source = "aws-ia/eks-blueprints-addons/aws"
version = "~> 1.14"
version = "~> 1.16"

cluster_name = module.eks.cluster_name
cluster_endpoint = module.eks.cluster_endpoint
Expand Down
Loading

0 comments on commit 2630956

Please sign in to comment.