Amazon EKS in Production with Terraform›Automate & Recover · Cheat sheet & self-check
Learning Hub / Cloud — OpenStack, AWS & EKS / Amazon EKS in Production with Terraform

Automate & Recover · wrap-up

Cheat sheet & self-check

Every command from this section on one page.

10 · CI/CD for the stack

Pipeline stages

terraform fmt -check && terraform validateFormatting and syntax
tflintTerraform linter (provider-aware rules)
checkov -d . / trivy config .Security misconfiguration scanning
terraform plan -out=tfplanPlan (posted to the PR)
terraform apply tfplanApply the exact reviewed plan

GitHub OIDC to AWS

permissions: id-token: writeAllow the job to request an OIDC token
uses: aws-actions/configure-aws-credentials@v4 with role-to-assumeExchange it for temporary AWS credentials

11 · Disaster recovery

State recovery

aws s3api list-object-versions --bucket acme-tfstate-prod --prefix eks/prod/cluster/Previous versions of a state file
aws s3api get-object --bucket … --key … --version-id <id> old.tfstateDownload an older version
terraform state pull > backup.tfstateBack up current state before any repair
import { to = aws_s3_bucket.logs id = "acme-logs" }Re-adopt an existing resource (in code, Terraform 1.5+)

Prevention

lifecycle { prevent_destroy = true }Refuse to plan destruction of critical resources
deletion_protection / termination protectionProvider-level protection where available
IAM deny on eks:DeleteCluster for CI roles (except break-glass)Stop destructive calls at the API

12 · Capstone: own, harden & operate

Readiness checks

aws eks describe-cluster --name prod --query 'cluster.resourcesVpcConfig'Endpoint access and networking
aws eks list-access-entries --cluster-name prodWho can access the cluster
aws eks list-insights --cluster-name prodUpgrade readiness
kubectl get nodepools,nodeclaimsKarpenter capacity
velero backup getBackups and their status