This project automates the Jenkins CI/CD environment on AWS — using Terraform as Infrastructure-as-Code (IaC). It provisions all networking, security, and application components, integrating with a custom domain and SSL certificate for secure web access.
The setup automates the deployment of a Jenkins server behind an Application Load Balancer (ALB) with a valid SSL certificate (ACM), using Terraform Infrastructure as Code (IaC).
- ➡️ Custom VPC with public subnets, Internet Gateway, and route tables
- ➡️ Security Groups for Jenkins and ALB
- ➡️ EC2 Instance for Jenkins (with User Data installation script)
- ➡️ Target Group and Application Load Balancer (ALB) setup
- ➡️ ACM Certificate for HTTPS
- ➡️ DNS Integration with Route 53
Before Running Terraform, Make sure you have the following prerequisites ready:
- ➡️ Terraform v1.3+ (recommended)
- ➡️ AWS CLI configured with proper IAM credentials
- ➡️ A registered domain name (e.g., from GoDaddy, Namecheap, etc.)
- ➡️ Hosted Zone created in Route 53 — Example: hosted zone name: techsaif.gzz.io
- ➡️ Name Servers updated at your domain registrar
- ➡️ Public and Private Key
To work with this whole setup we need to setup Route53 and in Route53 we first need to setup our hosted zone.
- 1️⃣ Navigate to Route 53 → Hosted zones → Create hosted zone
- 2️⃣ In the Domain name field, enter the exact domain name you own (e.g., techsaif.gzz.io)
- 3️⃣ Select Type → Public hosted zone
- 4️⃣ Click Create hosted zone
- 5️⃣ Once you created you will get these four records which is "ns records".
- 6️⃣ Update these ns recode over your domine register's ns recode.
git clone https://github.com/xrootms/terraform-jenkins-setup.git
cd terraform-jenkins-setup2. Copy and edit variables: (Update variable values as needed — VPC, CIDR, public key, region, etc.)
cp terraform.tfvars.example terraform.tfvarsterraform initterraform plan
terraform apply🔹Hosted zone:
- The ALB DNS name is mapped to jenkins.techsaif.gzz.io using a Route 53 A record
🔹SSL Configuration:
- An ACM Certificate is created for: jenkins.techsaif.gzz.io and attached to the ALB for https traffic.
🔹Jenkins Installation (User Data):
- During EC2 instance creation, a user data script automatically installs and configures Jenkins and Terraform.
- Script used: jenkins-runner-script/jenkins-installer.sh*
🔹Accessing Jenkins:
- Once Terraform apply completes and DNS propagation finishes:
- Open https://jenkins.techsaif.gzz.io in your browser.
Retrieve the initial Jenkins admin password from the EC2 instance:
- Get the initial admin password:
sudo cat /var/lib/jenkins/secrets/initialAdminPasswordNotes
- ➡️ ACM and ALB must be in the same AWS region
- ➡️ DNS propagation may take up to 30 minutes
- ➡️ Check ACM validation status in AWS Console → Certificate Manager
- ➡️ To avoid unnecessary costs, destroy the infrastructure when no longer needed
terraform destroy ⭐ If you found this project interesting, consider giving it a star!









