The objective of this post is to walk you through how to set up a completely serverless Jenkins environment on AWS Fargate using AWS Cloud Development Kit (AWS CDK).
Jenkins is a popular open-source automation server that provides hundreds of plugins to support building, testing, deploying, and automation. Jenkins uses a controller-agent architecture in which the controller is responsible for serving the web UI, stores the configurations and related data on disk, and delegates the jobs to the worker agents that run these jobs as their primary responsibility.
Amazon Elastic Container Service (Amazon ECS) using Fargate is a fully-managed container orchestration service that helps you easily deploy, manage, and scale containerized applications. It deeply integrates with the rest of the AWS platform to provide a secure and easy-to-use solution for running container workloads in the cloud and now on your infrastructure. Fargate is a serverless, pay-as-you-go compute engine that lets you focus on building applications without managing servers. Fargate is compatible with both Amazon ECS and Amazon Elastic Kubernetes Service (Amazon EKS).
Solution overview
This diagram shows AWS CDK and how it deploys using AWS CloudFormation to create the Elastic Load Balancer, AWS Fargate, and Amazon EFS
You’ll be using the following:
- The Jenkins controller URL backed by an Application Load Balancer (ALB).
- You’ll be using your default Amazon Virtual Private Cloud (Amazon VPC) for this example.
- The Jenkins controller runs as a service in Amazon ECS using Fargate as the launch type.
You’ll use Amazon Elastic File System (Amazon EFS) as the persistent backing store for
the Jenkins controller task. The Jenkins controller and Amazon EFS are launched in private subnets.
Prerequisites
For this post, you’ll utilize AWS CDK using TypeScript.Follow the guide on Getting Started for AWS CDK to:Get your local environment setup Bootstrap your development account