Install Jenkins Using Terraform Script

Nivas DevSecOps
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:

  1. ec2.tf
  2. jenkins.sh
  3. key.pem
  4. provider.tf
  5. output.tf
  6. securitygroups.tf
  7. variables.tf
  8. terraform.tfvars
EC2.tf
provider.tf
Output.tf
security.tf
Variables.tf
# 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:

--

--

Nivas DevSecOps
Nivas DevSecOps

Written by Nivas DevSecOps

Cloud | DevSecOps| AWS ⭐Passionate Cloud and DevOps . 🎯 Like to stay up-to-date with the latest trends and insights.

Responses (1)