Jenkins Terraform Module
A Terraform module that deploys a multi-az master using ebs-pin and a spot ASG for build agents using Self-Organizing Swarm Plug-in. The build agents scale preemtively based on demand using jenkins-autoscaler.
Inputs
Name |
Description |
Type |
Default |
Required |
agents_disk_size |
Size of root volume on Jenkins agents |
string |
"50" |
no |
agents_instance_type |
Instance type of agents |
string |
"c5.large" |
no |
agents_max_size |
Max size of agents ASG |
string |
"20" |
no |
agents_min_size |
Minimum size of agents ASG |
string |
"2" |
no |
agents_spot_price |
Max price for spot bids on agents |
string |
"0.5" |
no |
agents_subnet_ids |
Subnet IDs for the Jenkins agents. |
list |
n/a |
yes |
ami_id |
AMI ID used by the Jenkins master instance |
string |
"ami-08589eca6dcc9b39c" |
no |
asg_tags |
Tags used for ASGs, has an addition attribute propagate_at_launch on every map. Do not include 'Name'. |
list |
n/a |
yes |
aws_key_pair_name |
Keypair for the Jenkins master instance |
string |
n/a |
yes |
aws_key_pair_public_key |
Public Key in authorized_keys format |
string |
n/a |
yes |
dns_base_name |
DNS base zone, e.g. example.com |
string |
n/a |
yes |
dns_name |
DNS record created for Jenkins master in dns_zone |
string |
n/a |
yes |
dns_zone |
DNS zone ID used for Jenkins records |
string |
n/a |
yes |
http_proxy |
HTTP Proxy used in the Jenkins userdata script |
string |
n/a |
yes |
instance_type |
Instance type used by Jenkins master instance |
string |
"t3.medium" |
no |
jenkins-cert |
ACM Certificate Domain Name for Jenkins |
string |
n/a |
yes |
jenkins_unique_id |
Unique ID used to identify the EBS volume accross instance terminations |
string |
n/a |
yes |
lb_subnet_ids |
Subnet IDs for the ALB. |
list |
n/a |
yes |
master_ebs_jenkinshome_size |
Size of the master jenkins home volume |
string |
"50" |
no |
master_ebs_root_size |
Size of the master EBS root volume |
string |
"20" |
no |
master_subnet_ids |
Subnet ID for the Jenkins master instance. Multi AZ is supported :) |
list |
n/a |
yes |
no_proxy |
Proxy exceptions used in the Jenkins userdata script |
string |
n/a |
yes |
tags |
Tags used for all resources except asgs |
map |
n/a |
yes |
vpc_id |
VPC ID used by the Jenkins master instance |
string |
n/a |
yes |
Outputs
Name |
Description |
master_ssh |
SSH to access the Jenkins master instance |
url |
URL to access the Jenkins UI |
Manual Steps Required
- Go through Jenkins setup, install recommended plugins and configure the proxy if required
- Install
Self-Organizing Swarm Plug-in Modules
and Blue Ocean plugin
- Enable JNLP port on 43863
- Create a local Jenkins service account called "agents" and put password in SSM with the key
JENKINS_AGENTS_PASSWORD
.
- Terminate agents and ensure they connect. Set number of build executors on the master to 0 (Manage Jenkins -> Manage Nodes -> Master).
- Terminate the master and ensure that it reboots with the correct data, and that metrics from jenkins-autoscaler are being output to CloudWatch Metrics
- Configure SCM plugins if required