Skip to content

vuba2002/Jenkins-Server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform Infrastructure for Jenkins Deployment

This Terraform configuration automates the provisioning of AWS infrastructure for a Jenkins deployment. The setup includes a Virtual Private Cloud (VPC), subnets, security groups, and an EC2 instance for Jenkins.

Infrastructure Overview

Picture_1

This Terraform script provisions the following AWS resources:

  • VPC with configurable CIDR block, DNS support, and hostname resolution.
  • Subnets (Public and Private) in a specified availability zone.
  • Internet Gateway (IGW) for public subnet connectivity.
  • NAT Gateway for private subnet connectivity.
  • Route Tables to manage traffic routing.
  • Security Groups to control inbound and outbound access.
  • Key Pair for SSH access to EC2 instances.
  • EC2 Instance configured for Jenkins deployment.

Configuration Variables

Below are the configurable variables used in the Terraform script:

General Tags

tags = {
    Name        = "<vpc-name>"
    Environment = "<environment>"
    Owner       = "<owner>"
}
  • Name: Name assigned to the VPC.
  • Environment: Deployment environment (e.g., Development, Staging, Production).
  • Owner: Owner of the infrastructure.

AWS Provider

region = "<aws-region>"
  • region: AWS region where the infrastructure will be deployed.

VPC Configuration

cidr_block           = "<vpc-cidr-block>"
enable_dns_support   = <true/false>
enable_dns_hostnames = <true/false>
  • cidr_block: CIDR range for the VPC.
  • enable_dns_support: Enable/disable DNS resolution support.
  • enable_dns_hostnames: Enable/disable DNS hostnames for instances.

Subnet Configuration

public_subnet_cidr_block  = "<public-subnet-cidr>"
private_subnet_cidr_block = "<private-subnet-cidr>"
availability_zone         = "<availability-zone>"
  • public_subnet_cidr_block: CIDR block for the public subnet.
  • private_subnet_cidr_block: CIDR block for the private subnet.
  • availability_zone: AWS availability zone to deploy the subnets.

Security Group Configuration

My_computer_ip = "<your-ip-address>/32"
  • My_computer_ip: IP address allowed to connect via SSH.

Key Pair

key_name = "<key-pair-name>"
  • key_name: Name of the SSH key pair used for EC2 instance access.

EC2 Instance Configuration

instance_type      = ["<instance-type>"]
private_key_path   = "<path-to-private-key>"
  • instance_type: AWS instance type for the Jenkins server.
  • private_key_path: Path to the private key file for SSH access.

Usage

  1. Initialize Terraform
    terraform init
  2. Validate Configuration
    terraform validate
  3. Plan Deployment
    terraform plan
  4. Apply Configuration
    terraform apply -auto-approve
  5. Destroy Infrastructure (if needed)
    terraform destroy -auto-approve

Variables

Variable Name Description Example Value
tags General tags for resource identification { Name = "jenkins-vpc", Environment = "Production" }
region AWS region for resource deployment ap-southeast-1
cidr_block CIDR block for VPC 11.0.0.0/16
enable_dns_support Enable DNS resolution support true
enable_dns_hostnames Enable DNS hostnames for instances true
public_subnet_cidr_block CIDR block for public subnet 11.0.1.0/24
private_subnet_cidr_block CIDR block for private subnet 11.0.3.0/24
availability_zone Availability zone for subnets ap-southeast-1a
My_computer_ip IP address allowed for SSH access 192.168.154.131/32
key_name SSH key pair name jenkins-key
instance_type AWS instance type t2.medium
private_key_path Path to the SSH private key ./Modules/08_aws_key_pair/jenkins-key.pem

Prerequisites

  • Terraform installed (>= v5.0).
  • AWS CLI configured with necessary permissions.
  • SSH key pair created for EC2 instance access.

Author

  • VuPlayBoizz

About

Create Jenkins Master Slave

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages