Install Jenkins Using Terraform Script
2 min readOct 31, 2024
Automate your Infrastructure using Terraform
This script will help you to create Jenkins in Ec2 Server using the Terraform script.
Objectives
Foundational
✔ Deploy an AWS EC2 instance in the default VPC.
✔ Bootstrap the EC2 instance with a script to install and start Jenkins.
✔ Create and assign a Security Group to the Jenkins Security Group that allows traffic on port 22 from your IP and allows traffic from port 8080.
✔ Verify that Jenkins is reachable via port 8080 in your browser.
Files:
- ec2.tf
- jenkins.sh
- key.pem
- provider.tf
- output.tf
- securitygroups.tf
- variables.tf
- terraform.tfvars
# Download the random provider
terraform init
# Check the formatting
terraform fmt
# Validate configuration
terraform validate
# Visualize changes
terraform plan
# Execute the plan
terraform apply -auto-approve
# Destroy the Plan
terraform destroy -auto-approve
Hope it helps..!
Thank you for reading so far! Before you go:
- 👏 Clap for the story if it helped :)
- 📰 View more content from me https://medium.com/@clouddevsecops