forked from cloudposse-archives/terraform-aws-jenkins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.yaml
219 lines (183 loc) · 7.92 KB
/
README.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
---
#
# This is the canonical configuration for the `README.md`
# Run `make readme` to rebuild the `README.md`
#
# Name of this project
name: terraform-aws-jenkins
# Tags of this project
tags:
- aws
- terraform
- terraform-modules
- cicd
- codepipeline
- codebuild
- continuous-integration
- continuous-delivery
- jenkins
- ecr
- terraform-jenkins
- docker
- elasticbeanstalk
# Categories of this project
categories:
- terraform-modules/cicd
# Logo for this project
#logo: docs/logo.png
# License of this project
license: "APACHE2"
# Canonical GitHub repo
github_repo: cloudposse/terraform-aws-jenkins
# Badges to display
badges:
- name: "Codefresh Build Status"
image: "https://g.codefresh.io/api/badges/pipeline/cloudposse/terraform-modules%2Fterraform-aws-jenkins?type=cf-1"
url: "https://g.codefresh.io/public/accounts/cloudposse/pipelines/5d9fea1192fba6201f04faca"
- name: "Latest Release"
image: "https://img.shields.io/github/release/cloudposse/terraform-aws-jenkins.svg"
url: "https://github.com/cloudposse/terraform-aws-jenkins/releases/latest"
- name: "Slack Community"
image: "https://slack.cloudposse.com/badge.svg"
url: "https://slack.cloudposse.com"
related:
- name: "terraform-aws-elastic-beanstalk-application"
description: "Terraform module to provision AWS Elastic Beanstalk application"
url: "https://github.com/cloudposse/terraform-aws-elastic-beanstalk-application"
- name: "terraform-aws-elastic-beanstalk-environment"
description: "Terraform module to provision AWS Elastic Beanstalk environment"
url: "https://github.com/cloudposse/terraform-aws-elastic-beanstalk-environment"
- name: "terraform-aws-ecr"
description: "Terraform Module to manage Docker Container Registries on AWS ECR"
url: "https://github.com/cloudposse/terraform-aws-ecr"
- name: "terraform-aws-efs"
description: "Terraform Module to define an EFS Filesystem (aka NFS)"
url: "https://github.com/cloudposse/terraform-aws-efs"
- name: "terraform-aws-efs-backup"
description: "Terraform module designed to easily backup EFS filesystems to S3 using DataPipeline"
url: "https://github.com/cloudposse/terraform-aws-efs-backup"
- name: "terraform-aws-cicd"
description: "Terraform Module for CI/CD with AWS Code Pipeline and Code Build"
url: "https://github.com/cloudposse/terraform-aws-cicd"
- name: "terraform-aws-codebuild"
description: "Terraform Module to easily leverage AWS CodeBuild for Continuous Integration"
url: "https://github.com/cloudposse/terraform-aws-codebuild"
# Short description of this project
description: |-
`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,
and deploy to [Elastic Beanstalk](https://aws.amazon.com/elasticbeanstalk/) running [Docker](https://www.docker.com/).
This is an enterprise-ready, scalable and highly-available architecture and the CI/CD pattern to build and deploy Jenkins.
## Features
The module will create the following AWS resources:
* Elastic Beanstalk Application
* Elastic Beanstalk Environment with Docker stack to run the Jenkins master
* ECR repository to store the Jenkins Docker image
* 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)
* AWS Backup stack to automatically backup the EFS
* CodePipeline with CodeBuild to build and deploy Jenkins so even Jenkins itself follows the CI/CD pattern
After all of the AWS resources are created,
__CodePipeline__ will:
* Get the specified Jenkins repo from GitHub, _e.g._ https://github.com/cloudposse/jenkins
* Build a Docker image from it
* Save the Docker image to the ECR repo
* Deploy the Docker image from the ECR repo to Elastic Beanstalk running Docker stack
* Monitor the GitHub repo for changes and re-run the steps above if new commits are pushed
![jenkins build server architecture](https://user-images.githubusercontent.com/52489/30888694-d07d68c8-a2d6-11e7-90b2-d8275ef94f39.png)
# How to use this project
usage: |-
For a complete example, see [examples/complete](examples/complete).
For automatic tests of the complete example, see [test](test).
```hcl
provider "aws" {
region = var.region
}
module "vpc" {
source = "git::https://github.com/cloudposse/terraform-aws-vpc.git?ref=tags/0.8.0"
namespace = var.namespace
stage = var.stage
name = var.name
attributes = var.attributes
tags = var.tags
delimiter = var.delimiter
cidr_block = "172.16.0.0/16"
}
module "subnets" {
source = "git::https://github.com/cloudposse/terraform-aws-dynamic-subnets.git?ref=tags/0.16.0"
availability_zones = var.availability_zones
namespace = var.namespace
stage = var.stage
name = var.name
attributes = var.attributes
tags = var.tags
delimiter = var.delimiter
vpc_id = module.vpc.vpc_id
igw_id = module.vpc.igw_id
cidr_block = module.vpc.vpc_cidr_block
nat_gateway_enabled = true
nat_instance_enabled = false
}
module "jenkins" {
source = "git::https://github.com/cloudposse/terraform-aws-jenkins.git?ref=master"
namespace = var.namespace
stage = var.stage
name = var.name
description = var.description
master_instance_type = var.master_instance_type
aws_account_id = var.aws_account_id
region = var.region
availability_zones = var.availability_zones
vpc_id = module.vpc.vpc_id
dns_zone_id = var.dns_zone_id
loadbalancer_subnets = module.subnets.public_subnet_ids
application_subnets = module.subnets.private_subnet_ids
environment_type = var.environment_type
loadbalancer_type = var.loadbalancer_type
loadbalancer_certificate_arn = var.loadbalancer_certificate_arn
availability_zone_selector = var.availability_zone_selector
rolling_update_type = var.rolling_update_type
loadbalancer_logs_bucket_force_destroy = var.loadbalancer_logs_bucket_force_destroy
cicd_bucket_force_destroy = var.cicd_bucket_force_destroy
github_oauth_token = var.github_oauth_token
github_organization = var.github_organization
github_repo_name = var.github_repo_name
github_branch = var.github_branch
image_tag = var.image_tag
healthcheck_url = var.healthcheck_url
build_image = var.build_image
build_compute_type = var.build_compute_type
efs_backup_schedule = var.efs_backup_schedule
efs_backup_start_window = var.efs_backup_start_window
efs_backup_completion_window = var.efs_backup_completion_window
efs_backup_cold_storage_after = var.efs_backup_cold_storage_after
efs_backup_delete_after = var.efs_backup_delete_after
env_vars = {
"JENKINS_USER" = var.jenkins_username
"JENKINS_PASS" = var.jenkins_password
"JENKINS_NUM_EXECUTORS" = var.jenkins_num_executors
}
}
```
# How to get started quickly
#quickstart: |-
# Here's how to get started...
# Other files to include in this README from the project folder
include:
- "docs/targets.md"
- "docs/terraform.md"
# Contributors to this project
contributors:
- name: "Erik Osterman"
homepage: "https://github.com/osterman"
github: "osterman"
- name: "Andriy Knysh"
homepage: "https://github.com/aknysh/"
github: "aknysh"
- name: "Igor Rodionov"
homepage: "https://github.com/goruha/"
github: "goruha"
- name: "Ivan Pinatti"
homepage: "https://github.com/ivan-pinatti/"
github: "ivan-pinatti"
- name: "Sergey Vasilyev"
homepage: "https://github.com/s2504s/"
github: "s2504s"