🤖 feat: migrate sandbox EKS Terraform to EKS Auto Mode#39
Conversation
Enable EKS Auto Mode compute, load balancing, and block storage in Terraform. This removes the managed node group configuration, adds Auto Mode IAM policies/roles, and updates outputs/variables/docs to match the new architecture. --- _Generated with `mux` • Model: `openai:gpt-5.3-codex` • Thinking: `xhigh` • Cost: `$0.38`_ <!-- mux-attribution: model=openai:gpt-5.3-codex thinking=xhigh costs=0.38 -->
|
@codex review Please review this Terraform migration of |
|
Codex Review: Didn't find any major issues. You're on a roll. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Add missing EKS Auto Mode prerequisites discovered during live terraform apply: - set EKS authentication mode to API_AND_CONFIG_MAP - enable both builtin Auto Mode node pools (general-purpose + system) - allow sts:TagSession in the EKS cluster role trust policy These changes unblock Auto Mode node provisioning and allow CoreDNS to become healthy. --- _Generated with `mux` • Model: `openai:gpt-5.3-codex` • Thinking: `xhigh` • Cost: `$0.38`_ <!-- mux-attribution: model=openai:gpt-5.3-codex thinking=xhigh costs=0.38 -->
|
@codex review Follow-up commit pushed after live apply testing to satisfy EKS Auto Mode prerequisites:
Local validation rerun:
|
|
Codex Review: Didn't find any major issues. Keep it up! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Migrate the Terraform-managed
sandbox-ekscluster from a managed node group setup to EKS Auto Mode.Background
The previous Terraform configuration used an EKS managed node group and did not model Auto Mode-managed compute/storage/load balancing behavior. This change aligns the sandbox cluster with EKS Auto Mode and removes now-obsolete node group configuration.
Implementation
aws_eks_cluster:compute_config(general-purposenode pool)kubernetes_network_config.elastic_load_balancingstorage_config.block_storageValidation
make verify-vendormake testmake buildmake lintterraform -chdir=terraform fmt -check -diffterraform -chdir=terraform init -backend=falseterraform -chdir=terraform validateRisks
📋 Implementation Plan
Plan: Migrate Terraform-managed sandbox EKS to EKS Auto Mode
Context / Why
The current Terraform in
terraform/provisions a standard EKS cluster with a managed node group and only the core EKS managed add-ons (coredns,kube-proxy,vpc-cni). It does not deploy the EBS CSI driver, so dynamic provisioning of EBS-backed PersistentVolumes via PVCs is not guaranteed.Goal: migrate the existing
sandbox-ekscluster to EKS Auto Mode so AWS manages:This plan assumes the following (based on your answers):
Evidence
terraform/eks.tfterraform/iam.tfterraform/.terraform.lock.hcl(hashicorp/aws 6.31.0)aws_eks_cluster.compute_config,kubernetes_network_config.elastic_load_balancing, andstorage_config.block_storage: hashicorp/aws provider docs foraws_eks_cluster(v6.31.0)automode.html)Migration plan (recommended: staged applies)
Phase 0 — Pre-flight safety checks
Confirm you can access current cluster (so you can validate after each apply):
terraform -chdir=terraform output -raw kubeconfig_command(then run it)kubectl get nodes -o widekubectl get pods -ACapture a quick baseline (helpful for rollback/debug):
terraform -chdir=terraform state listterraform -chdir=terraform plan(save the output)Communicate expected disruption
Why staged applies?
Auto Mode enablement is a control-plane update plus new IAM requirements. Keeping the managed node group initially provides a safety net while you validate Auto Mode health (and avoids a “no nodes in cluster” scenario if something is misconfigured).
Phase 1 — Enable Auto Mode capabilities (keep existing node group)
1) Terraform changes (IAM)
Edit
terraform/iam.tf:Keep existing cluster role
aws_iam_role.eks_clusterbut attach the additional AWS-managed policies required for Auto Mode:arn:aws:iam::aws:policy/AmazonEKSComputePolicyarn:aws:iam::aws:policy/AmazonEKSBlockStoragePolicyarn:aws:iam::aws:policy/AmazonEKSLoadBalancingPolicyarn:aws:iam::aws:policy/AmazonEKSNetworkingPolicyAdd a dedicated node role for Auto Mode managed instances (don’t reuse the managed node group role so it can be deleted later):
ec2.amazonaws.comarn:aws:iam::aws:policy/AmazonEKSWorkerNodeMinimalPolicyarn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPullOnlyShape of the intended additions:
2) Terraform changes (EKS cluster Auto Mode config)
Edit
terraform/eks.tfinaws_eks_cluster.this:Add all three of the following blocks (they must be enabled together):
Also update the cluster
depends_onto include the new policy attachments so deletion ordering remains correct:3) Apply (Phase 1)
Run:
terraform -chdir=terraform fmtterraform -chdir=terraform init -upgrade -backend-config=backend.hclterraform -chdir=terraform planterraform -chdir=terraform apply4) Validate (Phase 1)
Confirm Auto Mode flags are enabled:
aws eks describe-cluster --region $(terraform -chdir=terraform output -raw region) --name $(terraform -chdir=terraform output -raw cluster_name)Confirm nodes still exist (node group should still be present):
kubectl get nodes -o wideConfirm EBS CSI is available and storage works:
kubectl get csidriverskubectl get storageclassPhase 2 — Retire the managed node group (move fully to Auto Mode)
1) Create Auto Mode capacity (if needed)
EKS Auto Mode generally provisions nodes based on unschedulable pods. To force a clean cutover:
kubectl cordon <node>kubectl drain <node> --ignore-daemonsets --delete-emptydir-datakubectl get nodes -wIf the cluster ends up briefly without schedulable nodes, this is acceptable for sandbox, but you should still watch
kube-systempods recover.2) Terraform changes (remove node group)
Once you’ve confirmed Auto Mode is healthy:
aws_eks_node_group.thisfromterraform/eks.tf.terraform/iam.tf:aws_iam_role.node_groupaws_iam_role_policy_attachment.node_group_*depends_oninterraform/eks.tf:depends_on = [aws_eks_node_group.this]todepends_on = [aws_eks_cluster.this](or removedepends_onentirely if not needed).output "node_group_name"interraform/outputs.tf.3) Apply (Phase 2)
terraform -chdir=terraform planterraform -chdir=terraform apply4) Validate (Phase 2)
kubectl get nodes -o wide(should show only Auto Mode-managed nodes)kubectl get pods -A(all Running/Ready)Cleanup / follow-ups
Update
terraform/README.mdto reflect:Optional: remove now-unused variables from
terraform/variables.tf(node_*) after confirming no external automation relies on them.Rollback strategy (sandbox-friendly)
aws_eks_node_groupand apply, or destroy/recreate the sandbox cluster.Because PVC data preservation is not required, the simplest escape hatch is
terraform -chdir=terraform destroyfollowed byapplyonce the configuration is corrected.Generated with
mux• Model:openai:gpt-5.3-codex• Thinking:xhigh• Cost:$0.38