Provision a complete AWS infrastructure using Terraform and automatically deploy a Jenkins Server on an EC2 instance using a Shell Script.
- Overview
- Architecture
- Project Structure
- Features
- Technologies Used
- AWS Resources Created
- Prerequisites
- Deployment
- Terraform Commands
- File Description
- Project Screenshots
- Outputs
- Security Best Practices
- Future Enhancements
- Contributing
- License
- Author
This project demonstrates Infrastructure as Code (IaC) using Terraform by provisioning AWS infrastructure and deploying Jenkins automatically.
The infrastructure includes:
- Custom VPC
- Public Subnet
- Internet Gateway
- Route Table
- Security Group
- EC2 Instance
- Jenkins Installation using User Data Script
This project is suitable for beginners learning Terraform and AWS as well as recruiters evaluating DevOps skills.
AWS Cloud
β
βββββββββββββββββββ
β VPC β
βββββββββββββββββββ
β
Public Subnet
β
Internet Gateway
β
Route Table
β
Security Group
β
EC2 Instance
β
User Data Script
β
Install Jenkins
β
Jenkins Dashboard
Terraform-Jenkins-AWS/
β
βββ backend.tf
βββ provider.tf
βββ variable.tf
βββ terraform.tfvars
βββ vpc.tf
βββ jenkins-server.tf
βββ jenkins-server-script.sh
βββ outputs.tf
β
βββ .gitignore
βββ README.md
- Infrastructure as Code (Terraform)
- AWS Cloud Deployment
- Custom VPC
- Public Networking
- Security Groups
- EC2 Provisioning
- Automated Jenkins Installation
- Reusable Terraform Variables
- Terraform Outputs
- Easy Customization
- Beginner Friendly
- Production Ready Structure
| Technology | Purpose |
|---|
| Terraform | Infrastructure as Code | | AWS | Cloud Platform | | EC2 | Virtual Machine | | VPC | Networking | | Ubuntu | Operating System | | Shell Script | Jenkins Installation | | Jenkins | CI/CD Tool |
This Terraform project provisions:
- VPC
- Public Subnet
- Internet Gateway
- Route Table
- Route Table Association
- Security Group
- EC2 Instance
- Jenkins Installation
- Elastic IP (Optional)
Before deploying the infrastructure, ensure you have:
- AWS Account
- Terraform v1.x+
- AWS CLI Installed
- AWS CLI Configured
- IAM User with Administrator Access
- EC2 Key Pair
Verify installation:
terraform -version
aws --versiongit clone https://github.com/shubham-rasal-123/terraform-code-to-create-jenkins-server.git
cd terraform-code-to-create-jenkins-serverterraform initterraform fmtterraform validateterraform planterraform apply --auto-approveterraform outputterraform destroyterraform init
terraform fmt
terraform validate
terraform plan
terraform apply
terraform show
terraform output
terraform destroyConfigures Terraform backend.
Configures AWS Provider and Region.
Defines all Terraform variables.
Stores variable values.
Creates
- VPC
- Public Subnet
- Internet Gateway
- Route Table
- Route Table Association
Creates
- Security Group
- EC2 Instance
- User Data Configuration
Automatically installs
- Java
- Jenkins
- Starts Jenkins Service
- Enables Jenkins at Boot
Displays
- Public IP
- Instance ID
- VPC ID
- Subnet ID
| Resource | Description |
|---|
| VPC | Custom Virtual Private Cloud |
| Public Subnet | Public Network |
| Internet Gateway | Internet Connectivity |
| Route Table | Routing Configuration |
| Security Group | Firewall Rules |
| EC2 Instance | Ubuntu Server |
| Jenkins | CI/CD Automation |
- Never commit AWS credentials.
- Never commit Terraform State files.
- Restrict SSH access.
- Use IAM Roles instead of Access Keys.
- Store state remotely using S3.
- Enable DynamoDB State Locking.
- Protect sensitive variables.
- Terraform Modules
- Remote Backend (S3)
- DynamoDB Locking
- Auto Scaling Group
- Application Load Balancer
- Route53
- SSL using ACM
- GitHub Actions
- Docker Deployment
- Kubernetes (EKS)
- CloudWatch Monitoring
.terraform/
*.tfstate
*.tfstate.*
terraform.tfvars
.terraform.lock.hcl
crash.log
.vscode/
.idea/
.DS_Store
Thumbs.dbContributions are welcome!
- Fork this repository.
- Create a feature branch.
- Commit your changes.
- Push your branch.
- Open a Pull Request.
This project is licensed under the MIT License.
-- Shubham Rasal -- DevOps Engineer
- AWS
- Terraform
- Jenkins
- Docker
- Linux
- Shell Scripting
- Git & GitHub
GitHub: shubham-rasal-123
If you found this project helpful,
Please β Star this repository.
It motivates me to build more Cloud and DevOps projects.
This project demonstrates practical experience with:
- Infrastructure as Code (IaC)
- AWS Networking
- EC2 Provisioning
- Jenkins Automation
- Shell Scripting
- Terraform Variables
- Terraform Outputs
- Cloud Infrastructure Deployment
- DevOps Best Practices