This repository demonstrates a production-inspired, modular Infrastructure-as-Code architecture built with:
- Terraform
- Official terraform-aws-modules for VPC and Security Groups
- A custom EC2 module (wrapping
aws_instancefor full control)
- cloud-init (bootstrap preparation before Ansible runs)
- Ansible (Docker installation & pull-based deployment)
- Docker + GHCR (pre-built images, no builds on the server)
- GitHub Actions CI (Terraform validation + Ansible linting)
This mirrors real-world SRE / DevOps / Infrastructure Architect patterns: clean separation of concerns, modularity, reproducibility, and production-style workflows. It remains a deliberately small demo stack, not a hardened production deployment.
Terraform → AWS (VPC, SG, EC2 via custom module)
→ cloud-init
→ Ansible
→ Docker Compose
→ GHCR container images
- Provisions VPC, public subnet, internet gateway, route table
- Creates Security Group for SSH + HTTP/HTTPS
- Uses official AWS Terraform modules for all networking + security
- Deploys EC2 using a custom lightweight EC2 module (thin wrapper around
aws_instance) - Performs AMI lookup through SSM Parameter Store
- Injects cloud-init YAML for machine bootstrap
- Auto-generates Ansible inventory (
ansible/inventory/hosts.yaml)
- Updates apt
- Installs Python3 (required by Ansible)
- Enables SSH
- Waits for full cloud-init completion
- Leaves readiness marker
- Installs Docker Engine + Compose plugin
- Creates
/opt/ccore-ai - Renders templates:
docker-compose.ymlnginx.conf
- Pulls GHCR images (backend, frontend, nginx)
- Starts Docker Compose stack (idempotent)
ghcr.io/laurisneimanis/ccore-ai-demo-backend:latestghcr.io/laurisneimanis/ccore-ai-demo-frontend:latest
All application images are pre-built and pulled from GHCR. The current demo uses latest tags, so true immutable promotion would require release tags or image digests.
ccore-ai-infra/
├── terraform/ # Infrastructure provisioning (AWS modules + cloud-init)
├── ansible/ # Post-provision configuration & application deployment
├── diagrams/ # Architecture diagrams (Mermaid)
├── .github/ # CI pipelines (Terraform + Ansible)
└── README.md # Root documentation
Note
terraform.tfvarsis intentionally included for demonstration purposes to ensure full reproducibility.
It contains no sensitive data and is safe to store in this repository for the demo.
The default SSH CIDR is open for demo simplicity and should be restricted before any real deployment.
flowchart TD
A["Terraform (envs + AWS modules + custom EC2 module)"]
A --> C[Security Group]
A --> D["EC2 Instance (Ubuntu 24.04)"]
A --> E[Generate hosts.yaml]
D --> F[cloud-init Bootstrap]
F --> G[Ansible Provisioning]
G --> H[Install Docker Engine]
G --> I[Render docker-compose + nginx.conf]
I --> J[Docker Compose Stack]
J --> K["Backend + Frontend + Nginx (GHCR images)"]
Full low-level version (modules + cloud-init + Ansible roles + containers):
Full architecture diagram: diagrams/architecture.mmd
- fmt
- init
- validate
- ansible-lint
- yamllint
cd terraform/envs/dev
terraform init
terraform apply
ansible-playbook -i ansible/inventory/hosts.yaml ansible/playbook.yml
docker compose -f /opt/ccore-ai/docker-compose.yml pull
docker compose -f /opt/ccore-ai/docker-compose.yml up -d
- AWS: VPC, Subnet, IGW, EC2
- Terraform: AWS modules + custom EC2 module, cloud-init, inventory generation
- Ansible: roles, templates, provisioning
- Docker + GHCR: pre-built image deployments
- GitHub Actions CI
- Mermaid diagrams
This repository demonstrates:
- Enterprise-level IaC design
- Modern AWS Terraform module usage
- Zero-drift, pull-based server provisioning
- Clear separation of infra, config, runtime
- Production-inspired architecture
- Real DevOps & Infrastructure Architect capabilities
MIT License.