Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

tf-modules

Terraform modules I use to stand up an AWS EKS environment end to end: network, cluster, Kubernetes add-ons, Argo CD bootstrap and a PostgreSQL database with secrets delivered through External Secrets.

The modules are intentionally small and readable (plain aws_* resources instead of large community wrappers), so each piece of the platform can be understood and changed on its own.

flowchart LR
  vpc[vpc] --> eks[eks]
  eks --> addons[kubernetes-addons]
  eks --> argocd[argocd]
  vpc --> rds[rds]
  rds -- Secrets Manager + ExternalSecret --> eks
  argocd -- app-of-apps --> gitops[(GitOps repo)]
Loading

Modules

Module What it creates
vpc VPC, public/private subnets across AZs, Internet Gateway, NAT gateway, route tables, Kubernetes subnet tags for load balancers
eks EKS control plane with all control-plane log types, managed node groups (for_each over a map, on-demand or spot), node IAM role, IRSA OIDC provider, CloudWatch agent role, worker security group
kubernetes-addons Cluster Autoscaler, AWS Load Balancer Controller, EBS CSI driver (each with its own IRSA role and Helm release) and a default ALB IngressClass
argocd Argo CD via Helm with an IRSA role, ALB ingress with ACM certificate, SSH repository credentials, root app-of-apps Application and an ECR pull secret
rds PostgreSQL RDS instance with enhanced monitoring, Performance Insights, CloudWatch logs and CPU alarm; generated passwords stored in Secrets Manager and synced into the cluster with External Secrets Operator

Usage

module "vpc" {
  source = "github.com/ozy31/tf-modules//vpc"

  env             = "dev"
  azs             = ["eu-central-1a", "eu-central-1b"]
  private_subnets = ["10.0.0.0/19", "10.0.32.0/19"]
  public_subnets  = ["10.0.64.0/19", "10.0.96.0/19"]

  private_subnet_tags = { "kubernetes.io/role/internal-elb" = 1 }
  public_subnet_tags  = { "kubernetes.io/role/elb" = 1 }
}

module "eks" {
  source = "github.com/ozy31/tf-modules//eks"

  env         = "dev"
  eks_name    = "platform"
  eks_version = "1.31"
  vpc_id      = module.vpc.vpc_id
  subnet_ids  = module.vpc.private_subnet_ids

  node_groups = {
    general = {
      capacity_type  = "ON_DEMAND"
      instance_types = ["m6i.large"]
      scaling_config = { desired_size = 2, max_size = 5, min_size = 1 }
    }
  }
}

module "argocd" {
  source = "github.com/ozy31/tf-modules//argocd"

  env                 = "dev"
  eks_name            = "platform"
  openid_provider_arn = module.eks.openid_provider_arn
  argocd_domain       = "argocd.example.com"
  acm_certificate_arn = "arn:aws:acm:eu-central-1:111111111111:certificate/xxxx"
  gitops_repo_url     = "git@github.com:example/gitops.git"
}

Check each module's variables and outputs files for the full list of inputs.

Design notes

  • IRSA everywhere. Every controller (Cluster Autoscaler, AWS LBC, EBS CSI, Argo CD) gets its own IAM role bound to a single service account. No node-wide permissions.
  • GitOps from day one. Terraform only bootstraps Argo CD and the root Application; everything else in the cluster is reconciled from Git.
  • No secrets in state outputs or Git. Database passwords are generated with random_password, stored in Secrets Manager and pulled into Kubernetes by External Secrets.
  • Observability on by default. EKS control-plane logs, RDS enhanced monitoring, Performance Insights and CloudWatch alarms are part of the modules, not an afterthought.

Development

terraform fmt -recursive
for m in vpc eks kubernetes-addons argocd rds; do (cd $m && terraform init -backend=false && terraform validate); done

CI runs the same checks on every push (.github/workflows/validate.yml). For a newer, Terragrunt-based multi-environment setup with Karpenter and DR, see terraform-aws-eks-platform.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages