You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 12, 2026. It is now read-only.
`terraform-aws-jenkins` is a Terraform module to build a Docker image with [Jenkins](https://jenkins.io/), save it to an [ECR](https://aws.amazon.com/ecr/) repo,
57
+
and deploy to [Elastic Beanstalk](https://aws.amazon.com/elasticbeanstalk/) running [Docker](https://www.docker.com/).
58
+
59
+
This is an enterprise-ready, scalable and highly-available architecture and the CI/CD pattern to build and deploy Jenkins.
60
+
## Features
61
+
62
+
The module will create the following AWS resources:
63
+
64
+
* Elastic Beanstalk Application
65
+
* Elastic Beanstalk Environment with Docker stack to run the Jenkins master
66
+
* ECR repository to store the Jenkins Docker image
67
+
* EFS filesystem to store Jenkins config and jobs (it will be mounted to a directory on the EC2 host, and then to the Docker container)
68
+
* CodePipeline with CodeBuild to build and deploy Jenkins so even Jenkins itself follows the CI/CD pattern
69
+
* CloudFormation stack to run a DataPipeline to automatically backup the EFS to S3
70
+
* CloudFormation stack for SNS notifications about the status of each backup
71
+
72
+
73
+
After all of the AWS resources are created,
74
+
75
+
__CodePipeline__ will:
76
+
77
+
* Get the specified Jenkins repo from GitHub, _e.g._ https://github.com/cloudposse/jenkins
78
+
* Build a Docker image from it
79
+
* Save the Docker image to the ECR repo
80
+
* Deploy the Docker image from the ECR repo to Elastic Beanstalk running Docker stack
81
+
* Monitor the GitHub repo for changes and re-run the steps above if new commits are pushed
82
+
83
+
84
+
__DataPipeline__ will run on the specified schedule and will backup all Jenkins files to an S3 bucket by doing the following:
85
+
86
+
* Spawn an EC2 instance
87
+
* Mount the EFS filesystem to a directory on the EC2 instance
88
+
* Backup the directory to an S3 bucket
89
+
* Notify about the status of the backup (Success or Failure) via email
90
+
* Destroy the EC2 instance
91
+
92
+
93
+

94
+
95
+
# How to use this project
96
+
usage: |-
97
+
For complete examples, see [examples](examples).
98
+
99
+
# Example usage
100
+
101
+
examples: |-
102
+
### Deploy Jenkins into an existing VPC with existing subnets
| Name | Description | Type | Default | Required |
5
+
|------|-------------|:----:|:-----:|:-----:|
6
+
| attributes | Additional attributes (e.g. `policy` or `role`) | list |`<list>`| no |
7
+
| availability_zones | List of Availability Zones for EFS | list | - | yes |
8
+
| aws_account_id | AWS Account ID. Used as CodeBuild ENV variable $AWS_ACCOUNT_ID when building Docker images. For more info: http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html| string | - | yes |
9
+
| aws_region | AWS region in which to provision the AWS resources | string |`us-west-2`| no |
10
+
| build_compute_type | CodeBuild compute type, e.g. 'BUILD_GENERAL1_SMALL'. For more info: http://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref.html#build-env-ref-compute-types| string |`BUILD_GENERAL1_SMALL`| no |
11
+
| build_image | CodeBuild build image, e.g. 'aws/codebuild/docker:1.12.1'. For more info: http://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref.html#build-env-ref-available| string |`aws/codebuild/docker:1.12.1`| no |
| delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string |`-`| no |
14
+
| description | Will be used as Elastic Beanstalk application description | string |`Jenkins server as Docker container running on Elastic Benastalk`| no |
15
+
| env_default_key | Default ENV variable key for Elastic Beanstalk `aws:elasticbeanstalk:application:environment` setting | string |`DEFAULT_ENV_%d`| no |
16
+
| env_default_value | Default ENV variable value for Elastic Beanstalk `aws:elasticbeanstalk:application:environment` setting | string |`UNSET`| no |
17
+
| env_vars | Map of custom ENV variables to be provided to the Jenkins application running on Elastic Beanstalk, e.g. env_vars = { JENKINS_USER = 'admin' JENKINS_PASS = 'xxxxxx' } | map |`<map>`| no |
18
+
| github_branch | GitHub repository branch, e.g. 'master'. By default, this module will deploy 'https://github.com/cloudposse/jenkins' master branch | string |`master`| no |
19
+
| github_oauth_token | GitHub Oauth Token for accessing private repositories. Leave it empty when deploying a public 'Jenkins' repository, e.g. https://github.com/cloudposse/jenkins| string | `` | no |
20
+
| github_organization | GitHub organization, e.g. 'cloudposse'. By default, this module will deploy 'https://github.com/cloudposse/jenkins' repository | string |`cloudposse`| no |
21
+
| github_repo_name | GitHub repository name, e.g. 'jenkins'. By default, this module will deploy 'https://github.com/cloudposse/jenkins' repository | string |`jenkins`| no |
22
+
| healthcheck_url | Application Health Check URL. Elastic Beanstalk will call this URL to check the health of the application running on EC2 instances | string |`/login`| no |
23
+
| image_tag | Docker image tag in the ECR repository, e.g. 'latest'. Used as CodeBuild ENV variable $IMAGE_TAG when building Docker images. For more info: http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html| string |`latest`| no |
24
+
| loadbalancer_certificate_arn | Load Balancer SSL certificate ARN. The certificate must be present in AWS Certificate Manager | string | - | yes |
25
+
| loadbalancer_type | Load Balancer type, e.g. 'application' or 'classic' | string |`application`| no |
26
+
| master_instance_type | EC2 instance type for Jenkins master, e.g. 't2.medium' | string |`t2.medium`| no |
27
+
| name | Solution name, e.g. 'app' or 'jenkins' | string |`jenkins`| no |
28
+
| namespace | Namespace, which could be your organization name, e.g. 'cp' or 'cloudposse' | string | - | yes |
29
+
| noncurrent_version_expiration_days | Backup S3 bucket noncurrent version expiration days | string |`35`| no |
30
+
| private_subnets | List of private subnets to place EC2 instances and EFS | list | - | yes |
31
+
| public_subnets | List of public subnets to place Elastic Load Balancer | list | - | yes |
32
+
| security_groups | List of security groups to be allowed to connect to the EC2 instances | list |`<list>`| no |
33
+
| solution_stack_name | Elastic Beanstalk stack, e.g. Docker, Go, Node, Java, IIS. For more info: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/concepts.platforms.html| string |`64bit Amazon Linux 2017.09 v2.8.4 running Docker 17.09.1-ce`| no |
34
+
| ssh_key_pair | Name of SSH key that will be deployed on Elastic Beanstalk and DataPipeline instance. The key should be present in AWS | string | `` | no |
35
+
| stage | Stage, e.g. 'prod', 'staging', 'dev', or 'test' | string | - | yes |
| vpc_id | ID of the VPC in which to provision the AWS resources | string | - | yes |
39
+
| zone_id | Route53 parent zone ID. The module will create sub-domain DNS records in the parent zone for the EB environment and EFS | string | - | yes |
0 commit comments