How to run Jenkins using Docker on AWS EC2 instance with Terraform. Step-by-step DevOps Guide.

Andrey Byhalenko
5 min readSep 3, 2024

In my previous guide, “How to run Jenkins using Docker on an AWS EC2 Ubuntu instance” I wrote about the step-by-step manual process to do that using AWS Console.

Today I want to talk about the way to do it using Terraform.

Not a member? Click here to read this article for free.

Infrastructure as Code quickly became standard in industry.

Using tools like Terraform, you can create and destroy the whole infrastructure by running a few commands only.

Let’s see how we can create the following configuration using Terraform:

  • Create an EC2 Linux instance.
  • Install Docker on an EC2 instance.
  • Run Jenkins on Docker and print the public IP.
  • Access Jenkins from your browser.

Prerequisites:

Terraform configuration

--

--

Andrey Byhalenko

I'm a DevOps Engineer, Photography Enthusiast, and Traveler. I write articles aimed at junior DevOps engineers and those aspiring to become DevOps engineers.