Four parts closed the accounts (pt. 1), the people and services (pt. 2), the vision (pt. 3), and the network with the data (pt. 4). What’s left is the workload — an EKS cluster and an RDS Postgres database that make all of it come alive. The thesis of this finale: a “basic” setup and a “secure” setup are not two different projects but the same Terraform module, if you assemble it from the details of the first four parts.
Why now: org-wide GuardDuty with EKS detections and centralized posture management makes “secure by default” reachable without an enterprise budget: Kubernetes detections are an organization-wide checkbox, not a quarterly project.
Table of contents
Open Table of contents
- What’s already built, and what’s missing
- EKS: a cluster that doesn’t stick out
- IRSA: pods without keys
- RDS Postgres: a database you can’t reach from outside
- Secrets: External Secrets Operator
- Observability and backups: parts 3 and 4 on autopilot
- The comparison in one table
- What you need to assemble the baseline
- How to verify
- The honest monthly bill
- The series checklist
- Pitfalls
- Bottom line
What’s already built, and what’s missing
On the foundation of parts 1–4 the workload assembles in an evening — and that’s exactly where it usually breaks: EKS gets stood up “by the tutorial” — public endpoint on 0.0.0.0/0, nodes wherever they landed, AWS keys in variables. The cluster works, and the baseline gets retrofitted afterwards, as a migration with downtime. The right order: rules first, then terraform apply.
EKS: a cluster that doesn’t stick out
Three settings separate this cluster from the tutorial one:
- Nodes in private subnets. Managed node groups land in the private tier from part 4: no public IPs, egress through NAT. Pass public subnets instead — the cluster will come up and “work”.
- API endpoint private access. The control plane isn’t published to the internet:
endpoint_public_access = false, access from inside the VPC (an SSM port session, VPN or a bastion); the compromise for getting started is a public endpoint with an allow-list of office CIDRs — a deliberate step, not a default. - Pod Security Standards. Built-in admission control, free: app namespaces get
enforce=restricted,privilegedstays with system components. A pod can no longer ask for hostNetwork and root “just because”.
The cluster’s etcd secrets are encrypted with the same CMK — cluster_encryption_config in the module.
IRSA: pods without keys
IRSA — Roles for Service Accounts — carries the part-2 model over from people to pods. The cluster publishes an OIDC provider; a service account annotated with eks.amazonaws.com/role-arn gets a projected token and exchanges it at STS for temporary credentials. Zero long-lived keys: a leaked manifest is worth nothing within hours.
Permissions work like the permission sets in part 2: a role bound to namespace:serviceaccount, a policy scoped to one resource — s3:GetObject on one bucket, not * on the account. AdministratorAccess on a service account is formally “IRSA”, but in substance it’s the same eternal key, just fashionable.
RDS Postgres: a database you can’t reach from outside
The carcass comes entirely from part 4: database subnets with no IGW route, publicly_accessible = false, 5432 open only from the EKS nodes’ SG (a reference, not a CIDR), storage_encrypted at creation under the prod/data CMK.
The new choice is how the pod authenticates to the database:
- IAM database authentication — no password at all; connections use an IAM token via the same IRSA role. The token lives 15 minutes and is generated per connection: with a connection pooler that’s a token generator. Fits when there is no pooler.
- A secret with rotation — Secrets Manager stores the password, a Lambda rotates it on schedule, pods pick the value up through ESO. That’s how the classic stack with a connection pool works.
Rule of thumb: connection pool → a rotated secret; no pool → IAM auth.
Secrets: External Secrets Operator
We covered distributing secrets into a cluster in detail in the ESO article — here it falls into place: the operator under its own IRSA role, a ClusterSecretStore pointed at Secrets Manager, an ExternalSecret syncing prod/db/pg into a Kubernetes Secret. Rotation reaches the pods on its own — ESO polls the source on refreshInterval.
Observability and backups: parts 3 and 4 on autopilot
Almost nothing new here — and that’s the series’ main point. GuardDuty EKS: the org-wide GuardDuty from part 3 already watches the cluster — control-plane audit-log analysis is enabled org-wide, and runtime protection installs as the aws-guardduty-agent managed add-on, an agent on every node; a finding goes to the same EventBridge → Telegram pipeline. Audit logs of the control plane go to CloudWatch next to CloudTrail — one investigation timeline. Backups: RDS automated backups with a 7–35 day retention give PITR down to 5 minutes (“dropped a table” rolls back in minutes), while the backup=daily tag from part 4 attaches the database to the plan and a copy lands in the vault with Vault Lock in a separate account (“wiped everything” rolls back in hours). Two scenarios — two mechanisms.
The comparison in one table
| “Stood up by a tutorial” | The series baseline | |
|---|---|---|
| EKS API | public, 0.0.0.0/0 | private-only, access from the VPC |
| Nodes | wherever they landed, often public | private subnets + NAT |
| Pod permissions on AWS | static keys in a Secret | an IRSA role per service account |
| Pod privileges | unrestricted | PSS restricted in app namespaces |
| Database | public subnet, password in env | private + SG from EKS + CMK + rotation |
| Secrets | in git and CI variables | Secrets Manager → ESO |
| Detection | none | GuardDuty EKS: audit + runtime |
What you need to assemble the baseline
Preconditions: parts 1–4 closed, Terraform state in S3, kubectl and the AWS CLI configured. Region eu-central-1, two AZs.
1. The VPC from part 4 and the CMK — same as there, in short (aws_kms_key.data is the prod/data CMK from part 4):
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 6"
name = "prod"
cidr = "10.20.0.0/16"
azs = ["eu-central-1a", "eu-central-1b"]
public_subnets = ["10.20.0.0/24", "10.20.1.0/24"]
private_subnets = ["10.20.8.0/22", "10.20.12.0/22"] # nodes land here
database_subnets = ["10.20.64.0/22", "10.20.68.0/22"] # no IGW route
create_database_subnet_group = true
}
2. EKS — private endpoint, nodes in private, the GuardDuty agent:
module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "~> 21"
name = "prod"
vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.private_subnets # private only
# the control plane doesn't stick out into the internet
endpoint_private_access = true
endpoint_public_access = false
# access via the Identity Center role (pt. 2)
enable_cluster_creator_admin_permissions = true
# etcd secrets under the CMK (pt. 4)
cluster_encryption_config = {
provider_key_arn = aws_kms_key.data.arn
resources = ["secrets"]
}
cluster_addons = {
coredns = {}
kube-proxy = {}
vpc-cni = {}
aws-guardduty-agent = {} # runtime detection (pt. 3)
}
eks_managed_node_groups = {
apps = {
instance_types = ["m7g.large"]
min_size = 2
max_size = 4
desired_size = 2
subnets = module.vpc.private_subnets
}
}
}
3. The database SG — 5432 from EKS only — and RDS itself:
resource "aws_security_group" "db" {
name = "prod-db"
vpc_id = module.vpc.vpc_id
ingress { # a reference to the nodes' SG, not a CIDR (pt. 4)
description = "postgres from EKS nodes only"
from_port = 5432
to_port = 5432
protocol = "tcp"
security_groups = [module.eks.node_security_group_id]
}
}
resource "aws_db_instance" "pg" {
identifier = "prod-pg"
engine = "postgres"
engine_version = "18"
instance_class = "db.t4g.medium"
db_name = "app"
# the password without manual values: RDS puts it
# into Secrets Manager and rotates it itself (pt. 4)
manage_master_user_password = true
storage_encrypted = true
kms_key_id = aws_kms_key.data.arn
db_subnet_group_name = module.vpc.database_subnet_group_name
vpc_security_group_ids = [aws_security_group.db.id]
publicly_accessible = false
backup_retention_period = 14 # PITR down to 5 minutes
deletion_protection = true
}
4. An IRSA role for one service — reading a single bucket:
module "irsa_app" {
source = "terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks"
role_name = "prod-app-s3"
role_policy_arns = { s3 = aws_iam_policy.app_s3.arn }
oidc_providers = {
main = {
provider_arn = module.eks.oidc_provider_arn
namespace_service_accounts = ["apps:app"] # this SA only
}
}
}
resource "aws_iam_policy" "app_s3" {
name = "prod-app-s3"
policy = jsonencode({
Version = "2012-10-17"
Statement = [{
Effect = "Allow"
Action = ["s3:GetObject"]
Resource = "arn:aws:s3:::prod-uploads/*" # one bucket, one action
}]
})
}
And in the cluster — the annotation on a service account and PSS on the namespace:
apiVersion: v1
kind: ServiceAccount
metadata:
name: app
namespace: apps
annotations:
eks.amazonaws.com/role-arn: arn:aws:iam::ACCOUNT_ID:role/prod-app-s3
kubectl create namespace apps
kubectl label namespace apps pod-security.kubernetes.io/enforce=restricted
5. ESO and the SecretStore — per the ESO article.
How to verify
One command per layer:
# the API doesn't stick out: public is off
aws eks describe-cluster --name prod \
--query 'cluster.resourcesVpcConfig.[endpointPublicAccess,endpointPrivateAccess]'
# IRSA: the pod sees its service-account role, creds are temporary
kubectl exec -n apps deploy/app -- aws sts get-caller-identity
# PSS: the namespace actually enforces restricted
kubectl get ns apps --show-labels | grep 'enforce=restricted'
# the path to the database: a connection from inside the cluster works
kubectl run pg-check --rm -it --image=postgres:18-alpine -- \
psql "host=prod-pg.abcdefgh.eu-central-1.rds.amazonaws.com \
user=app dbname=app sslmode=require"
# the GuardDuty runtime agent runs on the nodes; backups — retention ≥ 7
kubectl get daemonset -A | grep guardduty
aws rds describe-db-instances --db-instance-identifier prod-pg \
--query 'DBInstances[].BackupRetentionPeriod'
get-caller-identity from the pod answering with the prod-app-s3 role is the key check: there are no keys in the cluster — and none are needed.
The honest monthly bill
A minimal production setup, us-east-1, on-demand, rounded (eu-central-1 comes out 5–10% higher):
| Item | What | $/mo |
|---|---|---|
| EKS control plane | $0.10/hour | 73 |
| Nodes | 2 × m7g.large | ≈106 |
| RDS Postgres | db.t4g.medium single-AZ + 100 GB gp3 | ≈72 |
| ALB | + LCU | ≈20 |
| NAT Gateway | 1 gateway + traffic | ≈35 |
| KMS CMK | 1 key | 1 |
| Secrets Manager | 2 secrets | 1 |
| GuardDuty | audit ≈$1.60/M events + runtime $1.50/vCPU × 4 | ≈10 |
| CloudWatch | audit logs, metrics | ≈10 |
| Total | ≈330 |
What can be trimmed: nodes on Spot (60–70% off), the database a size smaller, dev without the runtime agent and with a single AZ. A Multi-AZ database doubles the RDS line — but that’s availability, not security. What can’t be trimmed, because it’s pennies: the $1 CMK, rotation at $0.40 a secret, Vault Lock which is free outright — a policy, not a service. All the “security” in this bill is a rounding error; the expensive lines are compute and the database — exactly what you already pay for in an unprotected setup.
The series checklist
Audit your setup bottom-up:
- Account (pt. 1): root behind hardware MFA, alternate contacts filled in, SCPs fencing regions and root powers, an account per environment.
- People (pt. 2): sign-in through Identity Center, permission sets instead of IAM users, break-glass with an alert, SSH replaced by SSM.
- Vision (pt. 3): org-wide CloudTrail into S3 with Object Lock, GuardDuty on all sources, Security Hub against CIS, and a finding that reaches the on-call engineer.
- Data & network (pt. 4): three subnet tiers, rules as SG references, a CMK per environment, secret rotation, Backup + Vault Lock in a separate account.
- Workload (pt. 5): EKS private endpoint, nodes in private subnets, IRSA per service, PSS
restricted, the database behind an SG reference, ESO handing out secrets, PITR enabled.
If the ticks stand across all five — you don’t have “a secure setup on top of a basic one”; you have one setup that is simply built this way.
Pitfalls
- A public endpoint “for a couple of days” — the most common EKS-tutorial default. Private-only requires
kubectlto come from inside the VPC — plan for it on day one, or under a deadline you’ll open 0.0.0.0/0. - IAM DB auth with PgBouncer — the token lives 15 minutes and is generated per connection; a reconnecting pool becomes a token generator. Pool → a rotated secret.
aws-authinstead of access entries — a configmap that IAM users get written into “temporarily” for years; access entries with Identity Center roles close that zoo.- The GuardDuty agent missing nodes — the autoscaler adds a node, the DaemonSet hasn’t caught up, the window is open; keep an agent check in your node-group-growth alerts.
- Backup doesn’t replace PITR — restoring from a vault copy takes hours; PITR takes minutes. “Dropped a table” and “wiped the account” are different scenarios.
Bottom line
A “basic setup” and a “secure setup” in AWS are the same thing if you assemble it from the details of the first four parts: private subnets and SG references cost nothing, a CMK and secret rotation are dollars a month, IRSA is literally cheaper than static keys, and Vault Lock is a free policy. The trade: one evening of Terraform now against a week of rework later — moving nodes into private subnets or encrypting the database “eventually” is a migration with downtime, not a checkbox. The series is closed; from here the setup drifts, and what keeps it in line is the SCPs from part 1, the detections from part 3, and the checklist above.