This project provides a comprehensive infrastructure deployment solution using Terraform, Docker, and Ansible for setting up a server hosting two services and forwarding traffic based on requests sent to the server using Nginx with a robust network configuration on AWS.
- Creates a VPC with public subnets
- Provisions an EC2 instance
- Configures security groups
- Utilizes Terraform Cloud for state management
1-network.tf
: Defines VPC, subnets, internet gateway2-terraform.tfvars
: Configuration variables3-provider.tf
: Terraform and AWS provider configuration4-server.tf
: EC2 instance and security group setup5-variables.tf
: Variable definitions
- Deploys SonarQube with PostgreSQL
- Uses Docker Compose for service orchestration
docker-compose.yml
: Defines SonarQube and PostgreSQL servicesDockerfile
: Custom SonarQube configurationsonar.properties
: SonarQube configuration properties
- Automates server setup
- Installs and configures Apache, Nginx (as a reverse-proxy), Docker
- Deploys Docker services
playbook.yml
: Main Ansible playbookansible.cfg
: Ansible configurationports.conf
: Corstat (Apache server) port configurationreverse-proxy.conf
: Nginx reverse proxy setup
- Automates infrastructure deployment
- Manages Terraform apply
- Runs Ansible configuration
- AWS Account
- Terraform Cloud Account
- GitHub Secrets Configured:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
TF_API_TOKEN
PRIVATE_KEY
(SSH key for EC2 access)
- Push to
main
branch triggers GitHub Actions - Terraform provisions AWS infrastructure
- Ansible configures the server
- Docker deploys SonarQube
- SonarQube:
http://[EC2_IP]/sonarqube
- Application:
http://[EC2_IP]/corstat
Modify the following files to adapt to your environment:
terraform.tfvars
ansible/inventory
docker-compose.yml