Member-only story

My Jenkins Story: Provisioning Jenkins (master & build agents) on AWS EC2 — using Terraform

Colin But
5 min readApr 10, 2020

--

In this post I am going to show a quick fire technical demonstration on how to:

build up a small Jenkins cluster (with 1 Master & a few build agents) on AWS Cloud infrastructure (e.g EC2 instances) — using a tool called Terraform to automatically provisioning them.

Terraform is a infrastructure provisioning tool where it allows you to ‘provision’ ‘infrastructure’ resources. These infrastructure resources can be any infrastructure either on Cloud Providers or Container Platforms like Kubernetes.

In Terraform you define the state of the infrastructure you want in a main.tffile:

In the above, I create 3 EC2 instance resources with one of them acting as the ‘master’ controller in Jenkins and the other 2 are the Jenkins build agents.

I purposely separately created the master from the build agents as I wanted to clearly distinguish the kind of EC2 instance i am creating. I chose to do it this way as i wanted it to be as declarative as it can be and not over-do the customising logic by using fancy HCL syntax such as for , for_each , count etc.

--

--

Colin But
Colin But

Written by Colin But

Writer sharing thoughts on pretty much everything. P.S. I’m a Coffee-Addict ☕ You can support me by buying me a coffee: https://bit.ly/3hQ5M63

No responses yet