Building a Zero-SSH DevSecOps Pipeline on AWS Free Tier
For the second project of my internship at PT Darmawan Aryansyah Teknologi (DAT), I worked across the DevOps and IT Security divisions to design and implement a complete infrastructure and CI/CD pipeline for a multi-service demo application (frontend, backend, background worker, PostgreSQL, and Redis).
Because interns understandably don't get direct access to company production infrastructure, the entire stack was built on a personal AWS Free Tier account—with strict security and cost constraints from my mentors: no SSH ports open, no static AWS access keys in CI, automated quality and vulnerability gates before deployment, and proper observability.
Infrastructure Topology & Cost Constraints
Using Terraform (split into a bootstrap layer for remote S3 state and a main layer for networking, IAM, and compute), I provisioned a single VPC in ap-southeast-3a (Jakarta) with three role-separated EC2 instances:
- Application server (
t4g.small, ARM64): Runs Nginx as a reverse proxy, the frontend, backend, worker, PostgreSQL, Redis,node-exporter, andcAdvisor. Only HTTP/HTTPS ports are exposed to the public. - Monitoring server (
t4g.small, ARM64): Runs Prometheus, Grafana, and Alertmanager with zero public ingress rules. - Code quality server (
c7i-flex.large, x86-64): Runs SonarQube and its companion PostgreSQL database, also with zero public ingress rules.
Choosing ARM64 (t4g.small) instances, a single availability zone, and skipping a NAT Gateway kept the setup within Free Tier limits. It's a conscious trade-off—single-AZ means no multi-zone redundancy—and one we documented explicitly as a budget constraint rather than a production recommendation.
Zero-SSH & Secretless Access
One of the core security requirements was eliminating traditional SSH and long-lived credentials:
- No SSH: Port 22 is closed on every instance. Ansible connects using the
amazon.aws.aws_ec2dynamic inventory plugin over AWS Systems Manager (SSM) Session Manager. - Private operator access: Grafana and SonarQube have no public ingress; operators reach them through a private Tailscale network.
- No static AWS keys in CI: GitHub Actions authenticates to AWS using OpenID Connect (OIDC), assuming scoped IAM roles per workflow.
Server configuration is organized into five idempotent Ansible roles (docker_engine, notes_app, notes_monitoring, notes_sonarqube, and tailscale), using docker compose up -d --wait so Ansible waits for database and service health checks before moving on.
Three-Stage CI/CD with Quality Gates & Rollback
Across the application repositories (notes-fe, notes-be, notes-worker) and the infrastructure repository (notes-infra), I separated delivery into three distinct GitHub Actions workflows:
- CI (
ci.yml): Runs linting, unit tests, and SonarQube static analysis on pushes and pull requests. To prove the gate wasn't just decorative, I intentionally pushed faulty code with a SQL injection pattern to a test branch—the pipeline blocked it before it could progress. - CD (
cd.yml): Triggered after CI passes onmaster. Builds ARM64 container images, scans them with Docker Scout, and pushes commit-SHA-tagged images to Docker Hub. - Deploy (
deploy.yml): Triggered manually with a target commit SHA. It validates that the SHA exists onorigin/master, verifies the image in Docker Hub, re-runs Docker Scout, and sends the deployment bundle via AWS SSMSendCommand.
If health checks pass, the deployment script saves the configuration and image tags to a last-good directory and prunes old images. To verify recovery, I tested an intentionally broken release that failed health checks: the script automatically restored the last-good state so the app stayed healthy, while still exiting with code 1 so GitHub Actions accurately flagged the deployment as failed.
Observability & Alerting
On the monitoring instance, Prometheus scrapes host and container metrics every 15 seconds (7-day retention), Grafana visualizes them over Tailscale, and Alertmanager sends email notifications for instance downtime (>2 minutes), high CPU (>85%), high memory (>90%), or low disk space (<15% for 10 minutes).
Building this end-to-end—from Terraform state bootstrapping to testing a live rollback—made DevSecOps principles concrete. Security controls like OIDC, SSM, and vulnerability gates aren't extra overhead when they're baked into the pipeline from day one; they're what make automated releases safe to trust.