AWS, EKS, DevSecOps, Terraform, Kubernetes, Cilium, Trivy, Docker, FastAPI, Security
Secure EKS Delivery Lab — Update #2: From AWS Design to a Secured Local Cluster
EKS is mostly a costly service, considering that you may need additional services like endpoints/Nat Gateway, on top of the hourly EKS costs, so for local testing I moved to kubernetes using Kind (K8s in Docker) to test the security hardening and networking policies, and well, just general testing and configurations.
This update covers mostly the point where the project advances from provisiong infra (shown in the AWS diagram below) to "on-premise" K8s.

Caption: Architecture diagram.
The scope and goal remains the same: build a small service, deliver it securely to Amazon EKS, use the project to use technolpgies and DevSecOps principles, through Terraform, container security, Kubernetes security, vulnerability management, and runtime detection.
AWS infrastructure: designed in layers, intentionally not running as of now
So far the layers were built following this structure:
- Remote Terraform state with an S3 backend
- A VPC with private subnets across two Availability Zones, route tables, Kubernetes discovery tags, and outputs
- Separate security groups for the EKS control plane, worker nodes, and VPC interface endpoints
- An immutable (SHA ingest) Amazon ECR repository with scan-on-push enabled
- IAM roles for the EKS control plane and managed worker nodes.
- An EKS control-plane definition, managed node group, and a custom launch template that explicitly attaches the worker-node security group and requires IMDSv2.
- Feature flags for potentially billable services, including EKS, node groups, and private endpoints in variables.tf.
The private-node egress design is based on VPC endpoints rather than a NAT Gateway for additional security. The intended endpoints are S3, ECR API, ECR Docker, STS, and EC2, this minimizes unnecessary internet paths and keeps all the network full private.
A local Kubernetes security baseline
The cluster is running with one control-plane node and two workers, Cilium provides the CNI and enforces the NetworkPolicies used in local testing.
The web server app is deployed into a dedicated secure-eks-delivery namespace with the Kubernetes Restricted Pod Security Admission profile enabled and proper labeling.

Caption: Kubernetes diagram used for local testing.
The deployment configuration was defined as following:
- A dedicated ServiceAccount with automatic token mounting disabled.
- A non-root process running as UID/GID
10001. allowPrivilegeEscalation: false.- All Linux capabilities dropped.
RuntimeDefaultseccomp.- A read-only root filesystem.
- CPU and memory requests and limits.
- Startup, readiness, and liveness probes against the FastAPI health endpoints.
That configuration showed expected results. A test pod was rejected because it did not meet the Restricted Pod Security requirements, meanwhile the the corrected test manifest had to explicitly run as a known non-root UID, drop capabilities, disable privilege escalation, and select a seccomp profile, passing the first tests.
NetworkPolicies: proving both deny and allow paths
The namespace starts with default-deny ingress and egress policies. I then added narrowly scoped exceptions for:
- DNS access from the FastAPI pod to CoreDNS on TCP/UDP 53.
- Ingress to the API on TCP
8080only from a same-namespace pod labelledaccess=api-client. - Matching egress from that labelled client to the FastAPI pod.
The useful part was testing the policy, not just applying YAML:
Unlabelled test pod -> FastAPI service:8080 = denied (connection timeout)
Labelled test pod -> FastAPI service:8080 = allowed (200 /health/ready)
A future RBAC and admission-policy exercise will prevent arbitrary workloads from assigning themselves the access=api-client label.
Container and dependency hardening
The Dockerfile now has separate builder and runtime stages. The runtime container uses the same non-root UID as the Kubernetes manifest and carries the application source plus the virtual environment used to run Uvicorn. Removing unnecessary package-management tooling from the final image is a documented follow-up.
I also started working on a reproducible dependency workflow:
- The Python base image is pinned by SHA-256 digest instead of relying on a mutable tag.
requirements.lockis generated withpip-compile, includes transitive dependencies, and records hashes.- The image build uses
pip install --require-hashes -r requirements.lock. .dockerignoreallows only the required application files and dependency metadata into the build context.
Trivy is now installed locally and the first scan of the selected Python base image found six pip findings: five CVEs Medium and one Low, with no High or Critical findings. This is being recorded as a baseline rather than ignored. Five findings have an available fixed version; one currently has no reported fix. Before changing the pinned base image, will finish the reproducible Docker build, scan the complete application image, then test a newer candidate base-image digest and compare the reports later on.
What is next
There is still quite a lot of work to do!! So far I have come up with this checklist:
Verify the locked Docker build and application health
-> scan the completed application image with Trivy
-> investigate and remediate a finding
-> add CI checks: Gitleaks, Checkov, and Trivy
-> configure GitHub Actions OIDC with least-privilege AWS access
-> create the EKS image overlay using an ECR digest
-> package the workload with Helm
-> add Falco and run controlled runtime-detection exercises
-> introduce Argo CD and look for GitOps improvements
Signing off for now, -Ale