
# terraform-jenkins


Terraform repository for Jenkins clusters (controllers & agents)

> [!WARNING]
> Breaking changes! Starting with version 7.0.0, the module has been refactored to use a DNS provider for Route53 record creation. The following changes have been made:
> 
> 1. The previous `aws_route53_record.networking_dns` resource has been removed, and the `aws_route53_record.dns` resource has been updated to use the DNS provider.
> 2. The variables `aws_route53_params` and `aws_route53_networking_params` have been removed and replaced with `override_route53_zone_id`.
> 3. DNS records are now always created in the networking account using the DNS provider.
>
> The value for the Route53 zone ID is now determined automatically based on the environment:
> - For the development environment, it defaults to `Z21XEY26C989RH`, which is the zone ID for `dev.theorchard.io` in the Orchard development account.
> - For all other environments, the default is `Z0183645HDT0XCWHLW7S`, corresponding to the `theorchard.io` zone in the networking account.
> - If you need to create records in a different account or zone, please specify the appropriate zone ID using the `override_route53_zone_id` parameter.
>
> In the development and shared account, you may need to use `moved` blocks to migrate existing resources.




## CI/CD links

![Static Badge](https://img.shields.io/badge/jenkins_pipline-blue?logo=jenkins&logoColor=black&labelColor=red&link=https%3A%2F%2Fpipeline.theorchard.io)

![Static Badge](https://img.shields.io/badge/jenkins_scheduler-blue?logo=jenkins&logoColor=black&labelColor=red&link=https%3A%2F%2Fscheduler.theorchard.io)

![Static Badge](https://img.shields.io/badge/jenkins_chefci-blue?logo=jenkins&logoColor=black&labelColor=red&link=https%3A%2F%2Fprod-chef-jenkins-master.theorchard.io)


## Controller & Agent Platform

| Controller Type      | OS             | Controller AWS Resource Name     |
|----------------------|----------------|----------------------------------|
| Pipeline controller  | Amazon Linux 2 | prod-jenkins-pipeline-controller |
| Scheduler controller | Amazon Linux 2 | prod-jenkins-scheduler           |
| ChefCI controller    | Amazon Linux 2 | prod-jenkins-chefci-controller   |


| Agent Type       | OS       | Agents AWS Resource Name        | Agent roles                     | 
|------------------|----------|---------------------------------|---------------------------------|
| Pipeline agents  | Centos 7 | prod-jenkins-aws-pipeline-agent | prod-jenkins-aws-pipeline-agent | 
| Scheduler agents | Centos 7 | prod-jenkins-aws-task-agent     | prod-jenkins-aws-task-agent     |
| ChefCI agents    | Centos 7 | prod-chef-jenkins-agent         | prod-chef-jenkins-agent         |


## Features not in this terraform yet.

AWS launch template that uses Amazon Linux 2 ami by default uses root volume size of 8GB. Root volume can be resized
in the ec2 console. After resizing the root volume, wait for the volume optimization to complete. Then reboot the instance.

Same goes for the jenkins data volume. It can be extended in the console but need to be resize2fs after that. Please
check the documentation for the resize2fs command.

## Documentation

![Static Badge](https://img.shields.io/badge/Notion-000000?style=for-the-badge&logo=notion&logoColor=white&link=https%3A%2F%2Fwww.notion.so%2FResize-aws-jenkins-controller-data-volume-b53c3d9e8b1b48abb201149f4b3bb4d3)

## Migration Guide

If you are upgrading from a previous version of this module, you will need to use `moved` blocks in your Terraform configuration to migrate the existing Route53 records to the new resource names. Here's an example of how to do this:

```hcl
# For non-dev environments (if you had networking_dns records)
moved {
  from = module.jenkins_controller.aws_route53_record.networking_dns
  to   = module.jenkins_controller.aws_route53_record.dns
}
```

Replace `module.jenkins_controller` with the actual module name in your configuration.

