├── .github
├── CODEOWNERS
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ ├── bug_report.yml
│ ├── config.yml
│ ├── feature_request.md
│ ├── feature_request.yml
│ └── question.md
├── PULL_REQUEST_TEMPLATE.md
├── auto-release.yml
├── mergify.yml
├── renovate.json
└── workflows
│ ├── feature-branch-chatops.yml
│ ├── feature-branch.yml
│ ├── release-branch.yml
│ ├── release-published.yml
│ └── scheduled.yml
├── .gitignore
├── LICENSE
├── Makefile
├── README.md
├── README.yaml
├── context.tf
├── docs
├── targets.md
└── terraform.md
├── examples
├── complete
│ ├── context.tf
│ ├── fixtures.us-east-2.tfvars
│ ├── main.tf
│ ├── outputs.tf
│ ├── variables.tf
│ └── versions.tf
├── existing_vpc_existing_subnets
│ └── main.tf
├── existing_vpc_new_subnets
│ └── main.tf
└── new_vpc_new_subnets
│ └── main.tf
├── main.tf
├── outputs.tf
├── test
├── .gitignore
├── Makefile
├── Makefile.alpine
└── src
│ ├── .gitignore
│ ├── Makefile
│ ├── examples_complete_test.go
│ ├── go.mod
│ └── go.sum
├── variables.tf
└── versions.tf
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # Use this file to define individuals or teams that are responsible for code in a repository.
2 | # Read more:
3 | #
4 | # Order is important: the last matching pattern has the highest precedence
5 |
6 | # These owners will be the default owners for everything
7 | * @cloudposse/engineering @cloudposse/contributors
8 |
9 | # Cloud Posse must review any changes to Makefiles
10 | **/Makefile @cloudposse/engineering
11 | **/Makefile.* @cloudposse/engineering
12 |
13 | # Cloud Posse must review any changes to GitHub actions
14 | .github/* @cloudposse/engineering
15 |
16 | # Cloud Posse must review any changes to standard context definition,
17 | # but some changes can be rubber-stamped.
18 | **/*.tf @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers
19 | README.yaml @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers
20 | README.md @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers
21 | docs/*.md @cloudposse/engineering @cloudposse/contributors @cloudposse/approvers
22 |
23 | # Cloud Posse Admins must review all changes to CODEOWNERS or the mergify configuration
24 | .github/mergify.yml @cloudposse/admins
25 | .github/CODEOWNERS @cloudposse/admins
26 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: 'bug'
6 | assignees: ''
7 |
8 | ---
9 |
10 | Found a bug? Maybe our [Slack Community](https://slack.cloudposse.com) can help.
11 |
12 | [](https://slack.cloudposse.com)
13 |
14 | ## Describe the Bug
15 | A clear and concise description of what the bug is.
16 |
17 | ## Expected Behavior
18 | A clear and concise description of what you expected to happen.
19 |
20 | ## Steps to Reproduce
21 | Steps to reproduce the behavior:
22 | 1. Go to '...'
23 | 2. Run '....'
24 | 3. Enter '....'
25 | 4. See error
26 |
27 | ## Screenshots
28 | If applicable, add screenshots or logs to help explain your problem.
29 |
30 | ## Environment (please complete the following information):
31 |
32 | Anything that will help us triage the bug will help. Here are some ideas:
33 | - OS: [e.g. Linux, OSX, WSL, etc]
34 | - Version [e.g. 10.15]
35 |
36 | ## Additional Context
37 | Add any other context about the problem here.
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | description: Create a report to help us improve
4 | labels: ["bug"]
5 | assignees: [""]
6 | body:
7 | - type: markdown
8 | attributes:
9 | value: |
10 | Found a bug?
11 |
12 | Please checkout our [Slack Community](https://slack.cloudposse.com)
13 | or visit our [Slack Archive](https://archive.sweetops.com/).
14 |
15 | [](https://slack.cloudposse.com)
16 |
17 | - type: textarea
18 | id: concise-description
19 | attributes:
20 | label: Describe the Bug
21 | description: A clear and concise description of what the bug is.
22 | placeholder: What is the bug about?
23 | validations:
24 | required: true
25 |
26 | - type: textarea
27 | id: expected
28 | attributes:
29 | label: Expected Behavior
30 | description: A clear and concise description of what you expected.
31 | placeholder: What happened?
32 | validations:
33 | required: true
34 |
35 | - type: textarea
36 | id: reproduction-steps
37 | attributes:
38 | label: Steps to Reproduce
39 | description: Steps to reproduce the behavior.
40 | placeholder: How do we reproduce it?
41 | validations:
42 | required: true
43 |
44 | - type: textarea
45 | id: screenshots
46 | attributes:
47 | label: Screenshots
48 | description: If applicable, add screenshots or logs to help explain.
49 | validations:
50 | required: false
51 |
52 | - type: textarea
53 | id: environment
54 | attributes:
55 | label: Environment
56 | description: Anything that will help us triage the bug.
57 | placeholder: |
58 | - OS: [e.g. Linux, OSX, WSL, etc]
59 | - Version [e.g. 10.15]
60 | - Module version
61 | - Terraform version
62 | validations:
63 | required: false
64 |
65 | - type: textarea
66 | id: additional
67 | attributes:
68 | label: Additional Context
69 | description: |
70 | Add any other context about the problem here.
71 | validations:
72 | required: false
73 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: false
2 |
3 | contact_links:
4 |
5 | - name: Community Slack Team
6 | url: https://cloudposse.com/slack/
7 | about: |-
8 | Please ask and answer questions here.
9 |
10 | - name: Office Hours
11 | url: https://cloudposse.com/office-hours/
12 | about: |-
13 | Join us every Wednesday for FREE Office Hours (lunch & learn).
14 |
15 | - name: DevOps Accelerator Program
16 | url: https://cloudposse.com/accelerate/
17 | about: |-
18 | Own your infrastructure in record time. We build it. You drive it.
19 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature Request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: 'feature request'
6 | assignees: ''
7 |
8 | ---
9 |
10 | Have a question? Please checkout our [Slack Community](https://slack.cloudposse.com) or visit our [Slack Archive](https://archive.sweetops.com/).
11 |
12 | [](https://slack.cloudposse.com)
13 |
14 | ## Describe the Feature
15 |
16 | A clear and concise description of what the bug is.
17 |
18 | ## Expected Behavior
19 |
20 | A clear and concise description of what you expected to happen.
21 |
22 | ## Use Case
23 |
24 | Is your feature request related to a problem/challenge you are trying to solve? Please provide some additional context of why this feature or capability will be valuable.
25 |
26 | ## Describe Ideal Solution
27 |
28 | A clear and concise description of what you want to happen. If you don't know, that's okay.
29 |
30 | ## Alternatives Considered
31 |
32 | Explain what alternative solutions or features you've considered.
33 |
34 | ## Additional Context
35 |
36 | Add any other context or screenshots about the feature request here.
37 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature Request
3 | description: Suggest an idea for this project
4 | labels: ["feature request"]
5 | assignees: [""]
6 | body:
7 | - type: markdown
8 | attributes:
9 | value: |
10 | Have a question?
11 |
12 | Please checkout our [Slack Community](https://slack.cloudposse.com)
13 | or visit our [Slack Archive](https://archive.sweetops.com/).
14 |
15 | [](https://slack.cloudposse.com)
16 |
17 | - type: textarea
18 | id: concise-description
19 | attributes:
20 | label: Describe the Feature
21 | description: A clear and concise description of what the feature is.
22 | placeholder: What is the feature about?
23 | validations:
24 | required: true
25 |
26 | - type: textarea
27 | id: expected
28 | attributes:
29 | label: Expected Behavior
30 | description: A clear and concise description of what you expected.
31 | placeholder: What happened?
32 | validations:
33 | required: true
34 |
35 | - type: textarea
36 | id: use-case
37 | attributes:
38 | label: Use Case
39 | description: |
40 | Is your feature request related to a problem/challenge you are trying
41 | to solve?
42 |
43 | Please provide some additional context of why this feature or
44 | capability will be valuable.
45 | validations:
46 | required: true
47 |
48 | - type: textarea
49 | id: ideal-solution
50 | attributes:
51 | label: Describe Ideal Solution
52 | description: A clear and concise description of what you want to happen.
53 | validations:
54 | required: true
55 |
56 | - type: textarea
57 | id: alternatives-considered
58 | attributes:
59 | label: Alternatives Considered
60 | description: Explain alternative solutions or features considered.
61 | validations:
62 | required: false
63 |
64 | - type: textarea
65 | id: additional
66 | attributes:
67 | label: Additional Context
68 | description: |
69 | Add any other context about the problem here.
70 | validations:
71 | required: false
72 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/question.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/cloudposse-archives/terraform-aws-jenkins/71a267b8390cb7debd3f6d2af7f79bb357a5fa2d/.github/ISSUE_TEMPLATE/question.md
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | ## what
2 |
3 |
7 |
8 | ## why
9 |
10 |
15 |
16 | ## references
17 |
18 |
22 |
--------------------------------------------------------------------------------
/.github/auto-release.yml:
--------------------------------------------------------------------------------
1 | name-template: 'v$RESOLVED_VERSION'
2 | tag-template: '$RESOLVED_VERSION'
3 | version-template: '$MAJOR.$MINOR.$PATCH'
4 | version-resolver:
5 | major:
6 | labels:
7 | - 'major'
8 | minor:
9 | labels:
10 | - 'minor'
11 | - 'enhancement'
12 | patch:
13 | labels:
14 | - 'auto-update'
15 | - 'patch'
16 | - 'fix'
17 | - 'bugfix'
18 | - 'bug'
19 | - 'hotfix'
20 | default: 'minor'
21 | filter-by-commitish: true
22 |
23 | categories:
24 | - title: '🚀 Enhancements'
25 | labels:
26 | - 'enhancement'
27 | - 'patch'
28 | - title: '🐛 Bug Fixes'
29 | labels:
30 | - 'fix'
31 | - 'bugfix'
32 | - 'bug'
33 | - 'hotfix'
34 | - title: '🤖 Automatic Updates'
35 | labels:
36 | - 'auto-update'
37 |
38 | change-template: |
39 |
40 | $TITLE @$AUTHOR (#$NUMBER)
41 |
42 | $BODY
43 |
44 |
45 | template: |
46 | $CHANGES
47 |
48 | replacers:
49 | # Remove irrelevant information from Renovate bot
50 | - search: '/(?<=---\s)\s*^#.*(Renovate configuration|Configuration)(?:.|\n)*?This PR has been generated .*/gm'
51 | replace: ''
52 | # Remove Renovate bot banner image
53 | - search: '/\[!\[[^\]]*Renovate\][^\]]*\](\([^)]*\))?\s*\n+/gm'
54 | replace: ''
55 |
--------------------------------------------------------------------------------
/.github/mergify.yml:
--------------------------------------------------------------------------------
1 | # https://docs.mergify.io/conditions.html
2 | # https://docs.mergify.io/actions.html
3 | pull_request_rules:
4 | - name: "approve automated PRs that have passed checks"
5 | conditions:
6 | - "author~=^(cloudpossebot|renovate\\[bot\\])$"
7 | - "-closed"
8 | - "head~=^(auto-update|renovate)/.*"
9 | - "check-success=test/bats"
10 | - "check-success=test/readme"
11 | - "check-success=test/terratest"
12 | - "check-success=validate-codeowners"
13 | - or:
14 | - "base=master"
15 | - "base=main"
16 | - "base~=^release/v\\d{1,2}$"
17 |
18 | actions:
19 | review:
20 | type: "APPROVE"
21 | bot_account: "cloudposse-mergebot"
22 | message: "We've automatically approved this PR because the checks from the automated Pull Request have passed."
23 |
24 | - name: "merge automated PRs when approved and tests pass"
25 | conditions:
26 | - "author~=^(cloudpossebot|renovate\\[bot\\])$"
27 | - "-closed"
28 | - "head~=^(auto-update|renovate)/.*"
29 | - "check-success=test/bats"
30 | - "check-success=test/readme"
31 | - "check-success=test/terratest"
32 | - "check-success=validate-codeowners"
33 | - "#approved-reviews-by>=1"
34 | - "#changes-requested-reviews-by=0"
35 | - "#commented-reviews-by=0"
36 | - or:
37 | - "base=master"
38 | - "base=main"
39 | - "base~=^release/v\\d{1,2}$"
40 |
41 | actions:
42 | merge:
43 | method: "squash"
44 |
45 | - name: "delete the head branch after merge"
46 | conditions:
47 | - "merged"
48 | actions:
49 | delete_head_branch: {}
50 |
51 | - name: "ask to resolve conflict"
52 | conditions:
53 | - "conflict"
54 | - "-closed"
55 | actions:
56 | comment:
57 | message: "This pull request is now in conflict. Could you fix it @{{author}}? 🙏"
58 |
59 | - name: "remove outdated reviews"
60 | conditions:
61 | - or:
62 | - "base=master"
63 | - "base=main"
64 | - "base~=^release/v\\d{1,2}$"
65 | actions:
66 | dismiss_reviews:
67 | changes_requested: true
68 | approved: true
69 | message: "This Pull Request has been updated, so we're dismissing all reviews."
70 |
71 | - name: "close Pull Requests without files changed"
72 | conditions:
73 | - "#files=0"
74 | actions:
75 | close:
76 | message: "This pull request has been automatically closed by Mergify because there are no longer any changes."
77 |
--------------------------------------------------------------------------------
/.github/renovate.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "config:base",
4 | ":preserveSemverRanges"
5 | ],
6 | "baseBranches": ["main", "master", "/^release\\/v\\d{1,2}$/"],
7 | "labels": ["auto-update"],
8 | "dependencyDashboardAutoclose": true,
9 | "enabledManagers": ["terraform"],
10 | "terraform": {
11 | "ignorePaths": ["**/context.tf", "examples/**"]
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/.github/workflows/feature-branch-chatops.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: feature-branch-chatops
3 | on:
4 | issue_comment:
5 | types: [created]
6 |
7 | permissions:
8 | pull-requests: write
9 | id-token: write
10 | contents: write
11 |
12 | jobs:
13 | terraform-module:
14 | uses: cloudposse/github-actions-workflows-terraform-module/.github/workflows/feature-branch-chatops.yml@main
15 | secrets:
16 | github_access_token: ${{ secrets.REPO_ACCESS_TOKEN }}
17 |
--------------------------------------------------------------------------------
/.github/workflows/feature-branch.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: feature-branch
3 | on:
4 | pull_request:
5 | branches:
6 | - main
7 | - release/**
8 | types: [opened, synchronize, reopened, labeled, unlabeled]
9 |
10 | permissions:
11 | pull-requests: write
12 | id-token: write
13 | contents: write
14 |
15 | jobs:
16 | terraform-module:
17 | uses: cloudposse/github-actions-workflows-terraform-module/.github/workflows/feature-branch.yml@main
18 | secrets:
19 | github_access_token: ${{ secrets.REPO_ACCESS_TOKEN }}
20 |
--------------------------------------------------------------------------------
/.github/workflows/release-branch.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: release-branch
3 | on:
4 | push:
5 | branches:
6 | - main
7 | - release/**
8 | paths-ignore:
9 | - '.github/**'
10 | - 'docs/**'
11 | - 'examples/**'
12 | - 'test/**'
13 |
14 | permissions:
15 | contents: write
16 | id-token: write
17 |
18 | jobs:
19 | terraform-module:
20 | uses: cloudposse/github-actions-workflows-terraform-module/.github/workflows/release-branch.yml@main
21 | secrets:
22 | github_access_token: ${{ secrets.REPO_ACCESS_TOKEN }}
23 |
--------------------------------------------------------------------------------
/.github/workflows/release-published.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: release-published
3 | on:
4 | release:
5 | types:
6 | - published
7 |
8 | permissions:
9 | contents: write
10 | id-token: write
11 |
12 | jobs:
13 | terraform-module:
14 | uses: cloudposse/github-actions-workflows-terraform-module/.github/workflows/release.yml@main
15 |
--------------------------------------------------------------------------------
/.github/workflows/scheduled.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: scheduled
3 | on:
4 | workflow_dispatch: { } # Allows manually trigger this workflow
5 | schedule:
6 | - cron: "0 3 * * *"
7 |
8 | permissions:
9 | pull-requests: write
10 | id-token: write
11 | contents: write
12 |
13 | jobs:
14 | scheduled:
15 | uses: cloudposse/github-actions-workflows-terraform-module/.github/workflows/scheduled.yml@main
16 | secrets:
17 | github_access_token: ${{ secrets.REPO_ACCESS_TOKEN }}
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled files
2 | *.tfstate
3 | *.tfstate.backup
4 |
5 | # Module directory
6 | .terraform
7 | .idea
8 | *.iml
9 |
10 | .build-harness
11 | build-harness
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2017-2019 Cloud Posse, LLC
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | SHELL := /bin/bash
2 |
3 | # List of targets the `readme` target should call before generating the readme
4 | export README_DEPS ?= docs/targets.md docs/terraform.md
5 |
6 | -include $(shell curl -sSL -o .build-harness "https://cloudposse.tools/build-harness"; echo .build-harness)
7 |
8 | ## Lint terraform code
9 | lint:
10 | $(SELF) terraform/install terraform/get-modules terraform/get-plugins terraform/lint terraform/validate
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # terraform-aws-jenkins [](https://github.com/cloudposse/terraform-aws-jenkins/releases/latest) [](https://slack.cloudposse.com)
4 |
5 |
6 | [![README Header][readme_header_img]][readme_header_link]
7 |
8 | [![Cloud Posse][logo]](https://cpco.io/homepage)
9 |
10 |
30 |
31 | `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,
32 | and deploy to [Elastic Beanstalk](https://aws.amazon.com/elasticbeanstalk/) running [Docker](https://www.docker.com/).
33 |
34 | This is an enterprise-ready, scalable and highly-available architecture and the CI/CD pattern to build and deploy Jenkins.
35 |
36 | ## Features
37 |
38 | The module will create the following AWS resources:
39 |
40 | * Elastic Beanstalk Application
41 | * Elastic Beanstalk Environment with Docker stack to run the Jenkins master
42 | * ECR repository to store the Jenkins Docker image
43 | * 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)
44 | * AWS Backup stack to automatically backup the EFS
45 | * CodePipeline with CodeBuild to build and deploy Jenkins so even Jenkins itself follows the CI/CD pattern
46 |
47 |
48 | After all of the AWS resources are created,
49 |
50 | __CodePipeline__ will:
51 |
52 | * Get the specified Jenkins repo from GitHub, _e.g._ https://github.com/cloudposse/jenkins
53 | * Build a Docker image from it
54 | * Save the Docker image to the ECR repo
55 | * Deploy the Docker image from the ECR repo to Elastic Beanstalk running Docker stack
56 | * Monitor the GitHub repo for changes and re-run the steps above if new commits are pushed
57 |
58 |
59 | 
60 |
61 | ---
62 |
63 | This project is part of our comprehensive ["SweetOps"](https://cpco.io/sweetops) approach towards DevOps.
64 | [
][share_email]
65 | [
][share_googleplus]
66 | [
][share_facebook]
67 | [
][share_reddit]
68 | [
][share_linkedin]
69 | [
][share_twitter]
70 |
71 |
72 | [][terraform_modules]
73 |
74 |
75 |
76 | It's 100% Open Source and licensed under the [APACHE2](LICENSE).
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | We literally have [*hundreds of terraform modules*][terraform_modules] that are Open Source and well-maintained. Check them out!
85 |
86 |
87 |
88 |
89 |
90 |
91 | ## Security & Compliance [
](https://bridgecrew.io/)
92 |
93 | Security scanning is graciously provided by Bridgecrew. Bridgecrew is the leading fully hosted, cloud-native solution providing continuous Terraform security and compliance.
94 |
95 | | Benchmark | Description |
96 | |--------|---------------|
97 | | [](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-jenkins&benchmark=INFRASTRUCTURE+SECURITY) | Infrastructure Security Compliance |
98 | | [](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-jenkins&benchmark=CIS+KUBERNETES+V1.5) | Center for Internet Security, KUBERNETES Compliance |
99 | | [](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-jenkins&benchmark=CIS+AWS+V1.2) | Center for Internet Security, AWS Compliance |
100 | | [](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-jenkins&benchmark=CIS+AZURE+V1.1) | Center for Internet Security, AZURE Compliance |
101 | | [](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-jenkins&benchmark=PCI-DSS+V3.2) | Payment Card Industry Data Security Standards Compliance |
102 | | [](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-jenkins&benchmark=NIST-800-53) | National Institute of Standards and Technology Compliance |
103 | | [](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-jenkins&benchmark=ISO27001) | Information Security Management System, ISO/IEC 27001 Compliance |
104 | | [](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-jenkins&benchmark=SOC2)| Service Organization Control 2 Compliance |
105 | | [](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-jenkins&benchmark=CIS+GCP+V1.1) | Center for Internet Security, GCP Compliance |
106 | | [](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=cloudposse%2Fterraform-aws-jenkins&benchmark=HIPAA) | Health Insurance Portability and Accountability Compliance |
107 |
108 |
109 |
110 | ## Usage
111 |
112 |
113 | **IMPORTANT:** We do not pin modules to versions in our examples because of the
114 | difficulty of keeping the versions in the documentation in sync with the latest released versions.
115 | We highly recommend that in your code you pin the version to the exact version you are
116 | using so that your infrastructure remains stable, and update versions in a
117 | systematic way so that they do not catch you by surprise.
118 |
119 | Also, because of a bug in the Terraform registry ([hashicorp/terraform#21417](https://github.com/hashicorp/terraform/issues/21417)),
120 | the registry shows many of our inputs as required when in fact they are optional.
121 | The table below correctly indicates which inputs are required.
122 |
123 |
124 | For a complete example, see [examples/complete](examples/complete).
125 |
126 | For automatic tests of the complete example, see [test](test).
127 |
128 | ```hcl
129 | provider "aws" {
130 | region = var.region
131 | }
132 |
133 | module "vpc" {
134 | source = "git::https://github.com/cloudposse/terraform-aws-vpc.git?ref=tags/0.8.0"
135 | namespace = var.namespace
136 | stage = var.stage
137 | name = var.name
138 | attributes = var.attributes
139 | tags = var.tags
140 | delimiter = var.delimiter
141 | cidr_block = "172.16.0.0/16"
142 | }
143 |
144 | module "subnets" {
145 | source = "git::https://github.com/cloudposse/terraform-aws-dynamic-subnets.git?ref=tags/0.16.0"
146 | availability_zones = var.availability_zones
147 | namespace = var.namespace
148 | stage = var.stage
149 | name = var.name
150 | attributes = var.attributes
151 | tags = var.tags
152 | delimiter = var.delimiter
153 | vpc_id = module.vpc.vpc_id
154 | igw_id = module.vpc.igw_id
155 | cidr_block = module.vpc.vpc_cidr_block
156 | nat_gateway_enabled = true
157 | nat_instance_enabled = false
158 | }
159 |
160 | module "jenkins" {
161 | source = "cloudposse/jenkins/aws"
162 | # Cloud Posse recommends pinning every module to a specific version
163 | # version = "x.x.x"
164 | namespace = var.namespace
165 | stage = var.stage
166 | name = var.name
167 | description = var.description
168 |
169 | master_instance_type = var.master_instance_type
170 | aws_account_id = var.aws_account_id
171 | region = var.region
172 | availability_zones = var.availability_zones
173 | vpc_id = module.vpc.vpc_id
174 | dns_zone_id = var.dns_zone_id
175 | loadbalancer_subnets = module.subnets.public_subnet_ids
176 | application_subnets = module.subnets.private_subnet_ids
177 |
178 | environment_type = var.environment_type
179 | loadbalancer_type = var.loadbalancer_type
180 | loadbalancer_certificate_arn = var.loadbalancer_certificate_arn
181 | availability_zone_selector = var.availability_zone_selector
182 | rolling_update_type = var.rolling_update_type
183 | loadbalancer_logs_bucket_force_destroy = var.loadbalancer_logs_bucket_force_destroy
184 | cicd_bucket_force_destroy = var.cicd_bucket_force_destroy
185 |
186 | github_oauth_token = var.github_oauth_token
187 | github_organization = var.github_organization
188 | github_repo_name = var.github_repo_name
189 | github_branch = var.github_branch
190 |
191 | image_tag = var.image_tag
192 |
193 | healthcheck_url = var.healthcheck_url
194 |
195 | build_image = var.build_image
196 | build_compute_type = var.build_compute_type
197 |
198 | efs_backup_schedule = var.efs_backup_schedule
199 | efs_backup_start_window = var.efs_backup_start_window
200 | efs_backup_completion_window = var.efs_backup_completion_window
201 | efs_backup_cold_storage_after = var.efs_backup_cold_storage_after
202 | efs_backup_delete_after = var.efs_backup_delete_after
203 |
204 | env_vars = {
205 | "JENKINS_USER" = var.jenkins_username
206 | "JENKINS_PASS" = var.jenkins_password
207 | "JENKINS_NUM_EXECUTORS" = var.jenkins_num_executors
208 | }
209 | }
210 | ```
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 | ## Makefile Targets
219 | ```text
220 | Available targets:
221 |
222 | help Help screen
223 | help/all Display help for all targets
224 | help/short This help short screen
225 | lint Lint terraform code
226 |
227 | ```
228 |
229 |
230 | ## Requirements
231 |
232 | | Name | Version |
233 | |------|---------|
234 | | [terraform](#requirement\_terraform) | >= 0.14.0 |
235 | | [aws](#requirement\_aws) | >= 2.0 |
236 |
237 | ## Providers
238 |
239 | | Name | Version |
240 | |------|---------|
241 | | [aws](#provider\_aws) | >= 2.0 |
242 |
243 | ## Modules
244 |
245 | | Name | Source | Version |
246 | |------|--------|---------|
247 | | [cicd](#module\_cicd) | cloudposse/cicd/aws | 0.19.5 |
248 | | [ecr](#module\_ecr) | cloudposse/ecr/aws | 0.34.0 |
249 | | [efs](#module\_efs) | cloudposse/efs/aws | 0.32.7 |
250 | | [efs\_backup](#module\_efs\_backup) | cloudposse/backup/aws | 0.14.0 |
251 | | [elastic\_beanstalk\_application](#module\_elastic\_beanstalk\_application) | cloudposse/elastic-beanstalk-application/aws | 0.11.1 |
252 | | [elastic\_beanstalk\_environment](#module\_elastic\_beanstalk\_environment) | cloudposse/elastic-beanstalk-environment/aws | 0.46.0 |
253 | | [label\_slaves](#module\_label\_slaves) | cloudposse/label/null | 0.25.0 |
254 | | [this](#module\_this) | cloudposse/label/null | 0.25.0 |
255 |
256 | ## Resources
257 |
258 | | Name | Type |
259 | |------|------|
260 | | [aws_iam_policy.slaves](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
261 | | [aws_iam_role_policy_attachment.slaves](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
262 | | [aws_security_group.slaves](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource |
263 | | [aws_iam_policy_document.slaves](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
264 |
265 | ## Inputs
266 |
267 | | Name | Description | Type | Default | Required |
268 | |------|-------------|------|---------|:--------:|
269 | | [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.
This is for some rare cases where resources want additional configuration of tags
and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
270 | | [application\_subnets](#input\_application\_subnets) | List of subnets to place EC2 instances and EFS | `list(string)` | n/a | yes |
271 | | [associated\_security\_group\_ids](#input\_associated\_security\_group\_ids) | List of security groups to be allowed to connect to Jenkins master EC2 instances | `list(string)` | `[]` | no |
272 | | [attributes](#input\_attributes) | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,
in the order they appear in the list. New attributes are appended to the
end of the list. The elements of the list are joined by the `delimiter`
and treated as a single ID element. | `list(string)` | `[]` | no |
273 | | [availability\_zone\_selector](#input\_availability\_zone\_selector) | Availability Zone selector | `string` | `"Any"` | no |
274 | | [availability\_zones](#input\_availability\_zones) | List of Availability Zones for EFS | `list(string)` | n/a | yes |
275 | | [aws\_account\_id](#input\_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` | n/a | yes |
276 | | [build\_compute\_type](#input\_build\_compute\_type) | CodeBuild compute type, e.g. 'BUILD\_GENERAL1\_SMALL'. For more info: https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html | `string` | `"BUILD_GENERAL1_SMALL"` | no |
277 | | [build\_image](#input\_build\_image) | CodeBuild build image, e.g. 'aws/codebuild/amazonlinux2-x86\_64-standard:1.0'. For more info: https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html | `string` | `"aws/codebuild/docker:1.12.1"` | no |
278 | | [cicd\_bucket\_force\_destroy](#input\_cicd\_bucket\_force\_destroy) | Force destroy the CI/CD S3 bucket even if it's not empty | `bool` | `false` | no |
279 | | [context](#input\_context) | Single object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as `null` to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional\_tag\_map, which are merged. | `any` |
{
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"descriptor_formats": {},
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"labels_as_tags": [
"unset"
],
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {},
"tenant": null
}
| no |
280 | | [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.
Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
281 | | [description](#input\_description) | Will be used as Elastic Beanstalk application description | `string` | `"Jenkins server as Docker container running on Elastic Benastalk"` | no |
282 | | [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.
Map of maps. Keys are names of descriptors. Values are maps of the form
`{
format = string
labels = list(string)
}`
(Type is `any` so the map values can later be enhanced to provide additional options.)
`format` is a Terraform format string to be passed to the `format()` function.
`labels` is a list of labels, in order, to pass to `format()` function.
Label values will be normalized before being passed to `format()` so they will be
identical to how they appear in `id`.
Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no |
283 | | [dns\_zone\_id](#input\_dns\_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` | n/a | yes |
284 | | [efs\_backup\_cold\_storage\_after](#input\_efs\_backup\_cold\_storage\_after) | Specifies the number of days after creation that a recovery point is moved to cold storage | `number` | `null` | no |
285 | | [efs\_backup\_completion\_window](#input\_efs\_backup\_completion\_window) | The amount of time AWS Backup attempts a backup before canceling the job and returning an error. Must be at least 60 minutes greater than `start_window` | `number` | `null` | no |
286 | | [efs\_backup\_delete\_after](#input\_efs\_backup\_delete\_after) | Specifies the number of days after creation that a recovery point is deleted. Must be 90 days greater than `cold_storage_after` | `number` | `null` | no |
287 | | [efs\_backup\_schedule](#input\_efs\_backup\_schedule) | A CRON expression specifying when AWS Backup initiates a backup job | `string` | `null` | no |
288 | | [efs\_backup\_start\_window](#input\_efs\_backup\_start\_window) | The amount of time in minutes before beginning a backup. Minimum value is 60 minutes | `number` | `null` | no |
289 | | [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
290 | | [env\_vars](#input\_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(string)` | `{}` | no |
291 | | [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
292 | | [environment\_type](#input\_environment\_type) | Environment type, e.g. 'LoadBalanced' or 'SingleInstance'. If setting to 'SingleInstance', `rolling_update_type` must be set to 'Time' or `Immutable`, and `loadbalancer_subnets` will be unused (it applies to the ELB, which does not exist in SingleInstance environments) | `string` | `"LoadBalanced"` | no |
293 | | [github\_branch](#input\_github\_branch) | GitHub repository branch, e.g. 'master'. By default, this module will deploy 'https://github.com/cloudposse/jenkins' master branch | `string` | `"master"` | no |
294 | | [github\_oauth\_token](#input\_github\_oauth\_token) | GitHub Oauth Token | `string` | n/a | yes |
295 | | [github\_organization](#input\_github\_organization) | GitHub organization, e.g. 'cloudposse'. By default, this module will deploy 'https://github.com/cloudposse/jenkins' repository | `string` | `"cloudposse"` | no |
296 | | [github\_repo\_name](#input\_github\_repo\_name) | GitHub repository name, e.g. 'jenkins'. By default, this module will deploy 'https://github.com/cloudposse/jenkins' repository | `string` | `"jenkins"` | no |
297 | | [healthcheck\_url](#input\_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 |
298 | | [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).
Set to `0` for unlimited length.
Set to `null` for keep the existing setting, which defaults to `0`.
Does not affect `id_full`. | `number` | `null` | no |
299 | | [image\_tag](#input\_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 |
300 | | [label\_key\_case](#input\_label\_key\_case) | Controls the letter case of the `tags` keys (label names) for tags generated by this module.
Does not affect keys of tags passed in via the `tags` input.
Possible values: `lower`, `title`, `upper`.
Default value: `title`. | `string` | `null` | no |
301 | | [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. | `list(string)` | `null` | no |
302 | | [label\_value\_case](#input\_label\_value\_case) | Controls the letter case of ID elements (labels) as included in `id`,
set as tag values, and output by this module individually.
Does not affect values of tags passed in via the `tags` input.
Possible values: `lower`, `title`, `upper` and `none` (no transformation).
Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs.
Default value: `lower`. | `string` | `null` | no |
303 | | [labels\_as\_tags](#input\_labels\_as\_tags) | Set of labels (ID elements) to include as tags in the `tags` output.
Default is to include all labels.
Tags with empty values will not be included in the `tags` output.
Set to `[]` to suppress all generated tags.
**Notes:**
The value of the `name` tag, if included, will be the `id`, not the `name`.
Unlike other `null-label` inputs, the initial setting of `labels_as_tags` cannot be
changed in later chained modules. Attempts to change it will be silently ignored. | `set(string)` | [
"default"
]
| no |
304 | | [loadbalancer\_certificate\_arn](#input\_loadbalancer\_certificate\_arn) | Load Balancer SSL certificate ARN. The certificate must be present in AWS Certificate Manager | `string` | `""` | no |
305 | | [loadbalancer\_logs\_bucket\_force\_destroy](#input\_loadbalancer\_logs\_bucket\_force\_destroy) | Force destroy the S3 bucket for load balancer logs even if it's not empty | `bool` | `false` | no |
306 | | [loadbalancer\_ssl\_policy](#input\_loadbalancer\_ssl\_policy) | Specify a security policy to apply to the listener. This option is only applicable to environments with an application load balancer | `string` | `""` | no |
307 | | [loadbalancer\_subnets](#input\_loadbalancer\_subnets) | List of subnets to place Elastic Load Balancer | `list(string)` | n/a | yes |
308 | | [loadbalancer\_type](#input\_loadbalancer\_type) | Load Balancer type, e.g. 'application' or 'classic' | `string` | `"application"` | no |
309 | | [master\_instance\_type](#input\_master\_instance\_type) | EC2 instance type for Jenkins master, e.g. 't2.medium' | `string` | `"t2.medium"` | no |
310 | | [name](#input\_name) | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
This is the only ID element not also included as a `tag`.
The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. | `string` | `null` | no |
311 | | [namespace](#input\_namespace) | ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique | `string` | `null` | no |
312 | | [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.
Characters matching the regex will be removed from the ID elements.
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
313 | | [region](#input\_region) | AWS region in which to provision the AWS resources | `string` | n/a | yes |
314 | | [rolling\_update\_type](#input\_rolling\_update\_type) | `Health`, `Time` or `Immutable`. Set it to `Immutable` to apply the configuration change to a fresh group of instances. For more details, see https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options-general.html#command-options-general-autoscalingupdatepolicyrollingupdate | `string` | `"Health"` | no |
315 | | [solution\_stack\_name](#input\_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 2018.03 v2.12.17 running Docker 18.06.1-ce"` | no |
316 | | [ssh\_key\_pair](#input\_ssh\_key\_pair) | Name of SSH key that will be deployed on Elastic Beanstalk instances. The key should be present in AWS | `string` | `""` | no |
317 | | [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
318 | | [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).
Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no |
319 | | [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no |
320 | | [use\_efs\_ip\_address](#input\_use\_efs\_ip\_address) | If set to `true`, will provide the EFS IP address instead of DNS name to Jenkins as ENV var | `bool` | `false` | no |
321 | | [vpc\_id](#input\_vpc\_id) | ID of the VPC in which to provision the AWS resources | `string` | n/a | yes |
322 |
323 | ## Outputs
324 |
325 | | Name | Description |
326 | |------|-------------|
327 | | [codebuild\_badge\_url](#output\_codebuild\_badge\_url) | The URL of the build badge when badge\_enabled is enabled |
328 | | [codebuild\_cache\_bucket\_arn](#output\_codebuild\_cache\_bucket\_arn) | CodeBuild cache S3 bucket ARN |
329 | | [codebuild\_cache\_bucket\_name](#output\_codebuild\_cache\_bucket\_name) | CodeBuild cache S3 bucket name |
330 | | [codebuild\_project\_id](#output\_codebuild\_project\_id) | CodeBuild project ID |
331 | | [codebuild\_project\_name](#output\_codebuild\_project\_name) | CodeBuild project name |
332 | | [codebuild\_role\_arn](#output\_codebuild\_role\_arn) | CodeBuild IAM Role ARN |
333 | | [codebuild\_role\_id](#output\_codebuild\_role\_id) | CodeBuild IAM Role ID |
334 | | [codepipeline\_arn](#output\_codepipeline\_arn) | CodePipeline ARN |
335 | | [codepipeline\_id](#output\_codepipeline\_id) | CodePipeline ID |
336 | | [ecr\_registry\_id](#output\_ecr\_registry\_id) | Registry ID |
337 | | [ecr\_repository\_name](#output\_ecr\_repository\_name) | Repository name |
338 | | [ecr\_repository\_url](#output\_ecr\_repository\_url) | Repository URL |
339 | | [efs\_arn](#output\_efs\_arn) | EFS ARN |
340 | | [efs\_backup\_plan\_arn](#output\_efs\_backup\_plan\_arn) | Backup Plan ARN |
341 | | [efs\_backup\_plan\_version](#output\_efs\_backup\_plan\_version) | Unique, randomly generated, Unicode, UTF-8 encoded string that serves as the version ID of the backup plan |
342 | | [efs\_backup\_selection\_id](#output\_efs\_backup\_selection\_id) | Backup Selection ID |
343 | | [efs\_backup\_vault\_arn](#output\_efs\_backup\_vault\_arn) | Backup Vault ARN |
344 | | [efs\_backup\_vault\_id](#output\_efs\_backup\_vault\_id) | Backup Vault ID |
345 | | [efs\_dns\_name](#output\_efs\_dns\_name) | EFS DNS name |
346 | | [efs\_host](#output\_efs\_host) | Route53 DNS hostname for the EFS |
347 | | [efs\_id](#output\_efs\_id) | EFS ID |
348 | | [efs\_mount\_target\_dns\_names](#output\_efs\_mount\_target\_dns\_names) | List of EFS mount target DNS names |
349 | | [efs\_mount\_target\_ids](#output\_efs\_mount\_target\_ids) | List of EFS mount target IDs (one per Availability Zone) |
350 | | [efs\_mount\_target\_ips](#output\_efs\_mount\_target\_ips) | List of EFS mount target IPs (one per Availability Zone) |
351 | | [efs\_network\_interface\_ids](#output\_efs\_network\_interface\_ids) | List of mount target network interface IDs |
352 | | [elastic\_beanstalk\_application\_name](#output\_elastic\_beanstalk\_application\_name) | Elastic Beanstalk Application name |
353 | | [elastic\_beanstalk\_environment\_all\_settings](#output\_elastic\_beanstalk\_environment\_all\_settings) | List of all option settings configured in the environment. These are a combination of default settings and their overrides from setting in the configuration |
354 | | [elastic\_beanstalk\_environment\_application](#output\_elastic\_beanstalk\_environment\_application) | The Elastic Beanstalk Application specified for this environment |
355 | | [elastic\_beanstalk\_environment\_autoscaling\_groups](#output\_elastic\_beanstalk\_environment\_autoscaling\_groups) | The autoscaling groups used by this environment |
356 | | [elastic\_beanstalk\_environment\_ec2\_instance\_profile\_role\_name](#output\_elastic\_beanstalk\_environment\_ec2\_instance\_profile\_role\_name) | Instance IAM role name |
357 | | [elastic\_beanstalk\_environment\_elb\_zone\_id](#output\_elastic\_beanstalk\_environment\_elb\_zone\_id) | ELB zone id |
358 | | [elastic\_beanstalk\_environment\_endpoint](#output\_elastic\_beanstalk\_environment\_endpoint) | Fully qualified DNS name for the environment |
359 | | [elastic\_beanstalk\_environment\_hostname](#output\_elastic\_beanstalk\_environment\_hostname) | DNS hostname |
360 | | [elastic\_beanstalk\_environment\_id](#output\_elastic\_beanstalk\_environment\_id) | ID of the Elastic Beanstalk environment |
361 | | [elastic\_beanstalk\_environment\_instances](#output\_elastic\_beanstalk\_environment\_instances) | Instances used by this environment |
362 | | [elastic\_beanstalk\_environment\_launch\_configurations](#output\_elastic\_beanstalk\_environment\_launch\_configurations) | Launch configurations in use by this environment |
363 | | [elastic\_beanstalk\_environment\_load\_balancers](#output\_elastic\_beanstalk\_environment\_load\_balancers) | Elastic Load Balancers in use by this environment |
364 | | [elastic\_beanstalk\_environment\_name](#output\_elastic\_beanstalk\_environment\_name) | Name |
365 | | [elastic\_beanstalk\_environment\_queues](#output\_elastic\_beanstalk\_environment\_queues) | SQS queues in use by this environment |
366 | | [elastic\_beanstalk\_environment\_security\_group\_id](#output\_elastic\_beanstalk\_environment\_security\_group\_id) | Security group id |
367 | | [elastic\_beanstalk\_environment\_setting](#output\_elastic\_beanstalk\_environment\_setting) | Settings specifically set for this environment |
368 | | [elastic\_beanstalk\_environment\_tier](#output\_elastic\_beanstalk\_environment\_tier) | The environment tier |
369 | | [elastic\_beanstalk\_environment\_triggers](#output\_elastic\_beanstalk\_environment\_triggers) | Autoscaling triggers in use by this environment |
370 |
371 |
372 |
373 |
374 | ## Share the Love
375 |
376 | Like this project? Please give it a ★ on [our GitHub](https://github.com/cloudposse/terraform-aws-jenkins)! (it helps us **a lot**)
377 |
378 | Are you using this project or any of our other projects? Consider [leaving a testimonial][testimonial]. =)
379 |
380 |
381 |
382 | ## Related Projects
383 |
384 | Check out these related projects.
385 |
386 | - [terraform-aws-elastic-beanstalk-application](https://github.com/cloudposse/terraform-aws-elastic-beanstalk-application) - Terraform module to provision AWS Elastic Beanstalk application
387 | - [terraform-aws-elastic-beanstalk-environment](https://github.com/cloudposse/terraform-aws-elastic-beanstalk-environment) - Terraform module to provision AWS Elastic Beanstalk environment
388 | - [terraform-aws-ecr](https://github.com/cloudposse/terraform-aws-ecr) - Terraform Module to manage Docker Container Registries on AWS ECR
389 | - [terraform-aws-efs](https://github.com/cloudposse/terraform-aws-efs) - Terraform Module to define an EFS Filesystem (aka NFS)
390 | - [terraform-aws-efs-backup](https://github.com/cloudposse/terraform-aws-efs-backup) - Terraform module designed to easily backup EFS filesystems to S3 using DataPipeline
391 | - [terraform-aws-cicd](https://github.com/cloudposse/terraform-aws-cicd) - Terraform Module for CI/CD with AWS Code Pipeline and Code Build
392 | - [terraform-aws-codebuild](https://github.com/cloudposse/terraform-aws-codebuild) - Terraform Module to easily leverage AWS CodeBuild for Continuous Integration
393 |
394 | ## Help
395 |
396 | **Got a question?** We got answers.
397 |
398 | File a GitHub [issue](https://github.com/cloudposse/terraform-aws-jenkins/issues), send us an [email][email] or join our [Slack Community][slack].
399 |
400 | [![README Commercial Support][readme_commercial_support_img]][readme_commercial_support_link]
401 |
402 | ## DevOps Accelerator for Startups
403 |
404 |
405 | We are a [**DevOps Accelerator**][commercial_support]. We'll help you build your cloud infrastructure from the ground up so you can own it. Then we'll show you how to operate it and stick around for as long as you need us.
406 |
407 | [][commercial_support]
408 |
409 | Work directly with our team of DevOps experts via email, slack, and video conferencing.
410 |
411 | We deliver 10x the value for a fraction of the cost of a full-time engineer. Our track record is not even funny. If you want things done right and you need it done FAST, then we're your best bet.
412 |
413 | - **Reference Architecture.** You'll get everything you need from the ground up built using 100% infrastructure as code.
414 | - **Release Engineering.** You'll have end-to-end CI/CD with unlimited staging environments.
415 | - **Site Reliability Engineering.** You'll have total visibility into your apps and microservices.
416 | - **Security Baseline.** You'll have built-in governance with accountability and audit logs for all changes.
417 | - **GitOps.** You'll be able to operate your infrastructure via Pull Requests.
418 | - **Training.** You'll receive hands-on training so your team can operate what we build.
419 | - **Questions.** You'll have a direct line of communication between our teams via a Shared Slack channel.
420 | - **Troubleshooting.** You'll get help to triage when things aren't working.
421 | - **Code Reviews.** You'll receive constructive feedback on Pull Requests.
422 | - **Bug Fixes.** We'll rapidly work with you to fix any bugs in our projects.
423 |
424 | ## Slack Community
425 |
426 | Join our [Open Source Community][slack] on Slack. It's **FREE** for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally *sweet* infrastructure.
427 |
428 | ## Discourse Forums
429 |
430 | Participate in our [Discourse Forums][discourse]. Here you'll find answers to commonly asked questions. Most questions will be related to the enormous number of projects we support on our GitHub. Come here to collaborate on answers, find solutions, and get ideas about the products and services we value. It only takes a minute to get started! Just sign in with SSO using your GitHub account.
431 |
432 | ## Newsletter
433 |
434 | Sign up for [our newsletter][newsletter] that covers everything on our technology radar. Receive updates on what we're up to on GitHub as well as awesome new projects we discover.
435 |
436 | ## Office Hours
437 |
438 | [Join us every Wednesday via Zoom][office_hours] for our weekly "Lunch & Learn" sessions. It's **FREE** for everyone!
439 |
440 | [][office_hours]
441 |
442 | ## Contributing
443 |
444 | ### Bug Reports & Feature Requests
445 |
446 | Please use the [issue tracker](https://github.com/cloudposse/terraform-aws-jenkins/issues) to report any bugs or file feature requests.
447 |
448 | ### Developing
449 |
450 | If you are interested in being a contributor and want to get involved in developing this project or [help out](https://cpco.io/help-out) with our other projects, we would love to hear from you! Shoot us an [email][email].
451 |
452 | In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.
453 |
454 | 1. **Fork** the repo on GitHub
455 | 2. **Clone** the project to your own machine
456 | 3. **Commit** changes to your own branch
457 | 4. **Push** your work back up to your fork
458 | 5. Submit a **Pull Request** so that we can review your changes
459 |
460 | **NOTE:** Be sure to merge the latest changes from "upstream" before making a pull request!
461 |
462 |
463 | ## Copyright
464 |
465 | Copyright © 2017-2023 [Cloud Posse, LLC](https://cpco.io/copyright)
466 |
467 |
468 |
469 | ## License
470 |
471 | [](https://opensource.org/licenses/Apache-2.0)
472 |
473 | See [LICENSE](LICENSE) for full details.
474 |
475 | ```text
476 | Licensed to the Apache Software Foundation (ASF) under one
477 | or more contributor license agreements. See the NOTICE file
478 | distributed with this work for additional information
479 | regarding copyright ownership. The ASF licenses this file
480 | to you under the Apache License, Version 2.0 (the
481 | "License"); you may not use this file except in compliance
482 | with the License. You may obtain a copy of the License at
483 |
484 | https://www.apache.org/licenses/LICENSE-2.0
485 |
486 | Unless required by applicable law or agreed to in writing,
487 | software distributed under the License is distributed on an
488 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
489 | KIND, either express or implied. See the License for the
490 | specific language governing permissions and limitations
491 | under the License.
492 | ```
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 | ## Trademarks
503 |
504 | All other trademarks referenced herein are the property of their respective owners.
505 |
506 | ## About
507 |
508 | This project is maintained and funded by [Cloud Posse, LLC][website]. Like it? Please let us know by [leaving a testimonial][testimonial]!
509 |
510 | [![Cloud Posse][logo]][website]
511 |
512 | We're a [DevOps Professional Services][hire] company based in Los Angeles, CA. We ❤️ [Open Source Software][we_love_open_source].
513 |
514 | We offer [paid support][commercial_support] on all of our projects.
515 |
516 | Check out [our other projects][github], [follow us on twitter][twitter], [apply for a job][jobs], or [hire us][hire] to help with your cloud strategy and implementation.
517 |
518 |
519 |
520 | ### Contributors
521 |
522 |
523 | | [![Erik Osterman][osterman_avatar]][osterman_homepage]
[Erik Osterman][osterman_homepage] | [![Andriy Knysh][aknysh_avatar]][aknysh_homepage]
[Andriy Knysh][aknysh_homepage] | [![Igor Rodionov][goruha_avatar]][goruha_homepage]
[Igor Rodionov][goruha_homepage] | [![Ivan Pinatti][ivan-pinatti_avatar]][ivan-pinatti_homepage]
[Ivan Pinatti][ivan-pinatti_homepage] | [![Sergey Vasilyev][s2504s_avatar]][s2504s_homepage]
[Sergey Vasilyev][s2504s_homepage] | [![RB][nitrocode_avatar]][nitrocode_homepage]
[RB][nitrocode_homepage] |
524 | |---|---|---|---|---|---|
525 |
526 |
527 |
528 | [osterman_homepage]: https://github.com/osterman
529 | [osterman_avatar]: https://img.cloudposse.com/150x150/https://github.com/osterman.png
530 |
531 | [aknysh_homepage]: https://github.com/aknysh/
532 | [aknysh_avatar]: https://img.cloudposse.com/150x150/https://github.com/aknysh.png
533 |
534 | [goruha_homepage]: https://github.com/goruha/
535 | [goruha_avatar]: https://img.cloudposse.com/150x150/https://github.com/goruha.png
536 |
537 | [ivan-pinatti_homepage]: https://github.com/ivan-pinatti/
538 | [ivan-pinatti_avatar]: https://img.cloudposse.com/150x150/https://github.com/ivan-pinatti.png
539 |
540 | [s2504s_homepage]: https://github.com/s2504s/
541 | [s2504s_avatar]: https://img.cloudposse.com/150x150/https://github.com/s2504s.png
542 |
543 | [nitrocode_homepage]: https://github.com/nitrocode/
544 | [nitrocode_avatar]: https://img.cloudposse.com/150x150/https://github.com/nitrocode.png
545 |
546 | [![README Footer][readme_footer_img]][readme_footer_link]
547 | [![Beacon][beacon]][website]
548 |
549 | [logo]: https://cloudposse.com/logo-300x69.svg
550 | [docs]: https://cpco.io/docs?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-jenkins&utm_content=docs
551 | [website]: https://cpco.io/homepage?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-jenkins&utm_content=website
552 | [github]: https://cpco.io/github?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-jenkins&utm_content=github
553 | [jobs]: https://cpco.io/jobs?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-jenkins&utm_content=jobs
554 | [hire]: https://cpco.io/hire?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-jenkins&utm_content=hire
555 | [slack]: https://cpco.io/slack?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-jenkins&utm_content=slack
556 | [linkedin]: https://cpco.io/linkedin?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-jenkins&utm_content=linkedin
557 | [twitter]: https://cpco.io/twitter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-jenkins&utm_content=twitter
558 | [testimonial]: https://cpco.io/leave-testimonial?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-jenkins&utm_content=testimonial
559 | [office_hours]: https://cloudposse.com/office-hours?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-jenkins&utm_content=office_hours
560 | [newsletter]: https://cpco.io/newsletter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-jenkins&utm_content=newsletter
561 | [discourse]: https://ask.sweetops.com/?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-jenkins&utm_content=discourse
562 | [email]: https://cpco.io/email?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-jenkins&utm_content=email
563 | [commercial_support]: https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-jenkins&utm_content=commercial_support
564 | [we_love_open_source]: https://cpco.io/we-love-open-source?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-jenkins&utm_content=we_love_open_source
565 | [terraform_modules]: https://cpco.io/terraform-modules?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-jenkins&utm_content=terraform_modules
566 | [readme_header_img]: https://cloudposse.com/readme/header/img
567 | [readme_header_link]: https://cloudposse.com/readme/header/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-jenkins&utm_content=readme_header_link
568 | [readme_footer_img]: https://cloudposse.com/readme/footer/img
569 | [readme_footer_link]: https://cloudposse.com/readme/footer/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-jenkins&utm_content=readme_footer_link
570 | [readme_commercial_support_img]: https://cloudposse.com/readme/commercial-support/img
571 | [readme_commercial_support_link]: https://cloudposse.com/readme/commercial-support/link?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-jenkins&utm_content=readme_commercial_support_link
572 | [share_twitter]: https://twitter.com/intent/tweet/?text=terraform-aws-jenkins&url=https://github.com/cloudposse/terraform-aws-jenkins
573 | [share_linkedin]: https://www.linkedin.com/shareArticle?mini=true&title=terraform-aws-jenkins&url=https://github.com/cloudposse/terraform-aws-jenkins
574 | [share_reddit]: https://reddit.com/submit/?url=https://github.com/cloudposse/terraform-aws-jenkins
575 | [share_facebook]: https://facebook.com/sharer/sharer.php?u=https://github.com/cloudposse/terraform-aws-jenkins
576 | [share_googleplus]: https://plus.google.com/share?url=https://github.com/cloudposse/terraform-aws-jenkins
577 | [share_email]: mailto:?subject=terraform-aws-jenkins&body=https://github.com/cloudposse/terraform-aws-jenkins
578 | [beacon]: https://ga-beacon.cloudposse.com/UA-76589703-4/cloudposse/terraform-aws-jenkins?pixel&cs=github&cm=readme&an=terraform-aws-jenkins
579 |
580 |
--------------------------------------------------------------------------------
/README.yaml:
--------------------------------------------------------------------------------
1 | #
2 | # This is the canonical configuration for the `README.md`
3 | # Run `make readme` to rebuild the `README.md`
4 | #
5 |
6 | # Name of this project
7 | name: terraform-aws-jenkins
8 | # Tags of this project
9 | tags:
10 | - aws
11 | - terraform
12 | - terraform-modules
13 | - cicd
14 | - codepipeline
15 | - codebuild
16 | - continuous-integration
17 | - continuous-delivery
18 | - jenkins
19 | - ecr
20 | - terraform-jenkins
21 | - docker
22 | - elasticbeanstalk
23 | # Categories of this project
24 | categories:
25 | - terraform-modules/cicd
26 | # Logo for this project
27 | #logo: docs/logo.png
28 |
29 | # License of this project
30 | license: "APACHE2"
31 | # Canonical GitHub repo
32 | github_repo: cloudposse/terraform-aws-jenkins
33 | # Badges to display
34 | badges:
35 | - name: "Latest Release"
36 | image: "https://img.shields.io/github/release/cloudposse/terraform-aws-jenkins.svg"
37 | url: "https://github.com/cloudposse/terraform-aws-jenkins/releases/latest"
38 | - name: "Slack Community"
39 | image: "https://slack.cloudposse.com/badge.svg"
40 | url: "https://slack.cloudposse.com"
41 | related:
42 | - name: "terraform-aws-elastic-beanstalk-application"
43 | description: "Terraform module to provision AWS Elastic Beanstalk application"
44 | url: "https://github.com/cloudposse/terraform-aws-elastic-beanstalk-application"
45 | - name: "terraform-aws-elastic-beanstalk-environment"
46 | description: "Terraform module to provision AWS Elastic Beanstalk environment"
47 | url: "https://github.com/cloudposse/terraform-aws-elastic-beanstalk-environment"
48 | - name: "terraform-aws-ecr"
49 | description: "Terraform Module to manage Docker Container Registries on AWS ECR"
50 | url: "https://github.com/cloudposse/terraform-aws-ecr"
51 | - name: "terraform-aws-efs"
52 | description: "Terraform Module to define an EFS Filesystem (aka NFS)"
53 | url: "https://github.com/cloudposse/terraform-aws-efs"
54 | - name: "terraform-aws-efs-backup"
55 | description: "Terraform module designed to easily backup EFS filesystems to S3 using DataPipeline"
56 | url: "https://github.com/cloudposse/terraform-aws-efs-backup"
57 | - name: "terraform-aws-cicd"
58 | description: "Terraform Module for CI/CD with AWS Code Pipeline and Code Build"
59 | url: "https://github.com/cloudposse/terraform-aws-cicd"
60 | - name: "terraform-aws-codebuild"
61 | description: "Terraform Module to easily leverage AWS CodeBuild for Continuous Integration"
62 | url: "https://github.com/cloudposse/terraform-aws-codebuild"
63 | # Short description of this project
64 | description: |-
65 | `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,
66 | and deploy to [Elastic Beanstalk](https://aws.amazon.com/elasticbeanstalk/) running [Docker](https://www.docker.com/).
67 |
68 | This is an enterprise-ready, scalable and highly-available architecture and the CI/CD pattern to build and deploy Jenkins.
69 |
70 | ## Features
71 |
72 | The module will create the following AWS resources:
73 |
74 | * Elastic Beanstalk Application
75 | * Elastic Beanstalk Environment with Docker stack to run the Jenkins master
76 | * ECR repository to store the Jenkins Docker image
77 | * 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)
78 | * AWS Backup stack to automatically backup the EFS
79 | * CodePipeline with CodeBuild to build and deploy Jenkins so even Jenkins itself follows the CI/CD pattern
80 |
81 |
82 | After all of the AWS resources are created,
83 |
84 | __CodePipeline__ will:
85 |
86 | * Get the specified Jenkins repo from GitHub, _e.g._ https://github.com/cloudposse/jenkins
87 | * Build a Docker image from it
88 | * Save the Docker image to the ECR repo
89 | * Deploy the Docker image from the ECR repo to Elastic Beanstalk running Docker stack
90 | * Monitor the GitHub repo for changes and re-run the steps above if new commits are pushed
91 |
92 |
93 | 
94 | # How to use this project
95 | usage: |-
96 | For a complete example, see [examples/complete](examples/complete).
97 |
98 | For automatic tests of the complete example, see [test](test).
99 |
100 | ```hcl
101 | provider "aws" {
102 | region = var.region
103 | }
104 |
105 | module "vpc" {
106 | source = "git::https://github.com/cloudposse/terraform-aws-vpc.git?ref=tags/0.8.0"
107 | namespace = var.namespace
108 | stage = var.stage
109 | name = var.name
110 | attributes = var.attributes
111 | tags = var.tags
112 | delimiter = var.delimiter
113 | cidr_block = "172.16.0.0/16"
114 | }
115 |
116 | module "subnets" {
117 | source = "git::https://github.com/cloudposse/terraform-aws-dynamic-subnets.git?ref=tags/0.16.0"
118 | availability_zones = var.availability_zones
119 | namespace = var.namespace
120 | stage = var.stage
121 | name = var.name
122 | attributes = var.attributes
123 | tags = var.tags
124 | delimiter = var.delimiter
125 | vpc_id = module.vpc.vpc_id
126 | igw_id = module.vpc.igw_id
127 | cidr_block = module.vpc.vpc_cidr_block
128 | nat_gateway_enabled = true
129 | nat_instance_enabled = false
130 | }
131 |
132 | module "jenkins" {
133 | source = "cloudposse/jenkins/aws"
134 | # Cloud Posse recommends pinning every module to a specific version
135 | # version = "x.x.x"
136 | namespace = var.namespace
137 | stage = var.stage
138 | name = var.name
139 | description = var.description
140 |
141 | master_instance_type = var.master_instance_type
142 | aws_account_id = var.aws_account_id
143 | region = var.region
144 | availability_zones = var.availability_zones
145 | vpc_id = module.vpc.vpc_id
146 | dns_zone_id = var.dns_zone_id
147 | loadbalancer_subnets = module.subnets.public_subnet_ids
148 | application_subnets = module.subnets.private_subnet_ids
149 |
150 | environment_type = var.environment_type
151 | loadbalancer_type = var.loadbalancer_type
152 | loadbalancer_certificate_arn = var.loadbalancer_certificate_arn
153 | availability_zone_selector = var.availability_zone_selector
154 | rolling_update_type = var.rolling_update_type
155 | loadbalancer_logs_bucket_force_destroy = var.loadbalancer_logs_bucket_force_destroy
156 | cicd_bucket_force_destroy = var.cicd_bucket_force_destroy
157 |
158 | github_oauth_token = var.github_oauth_token
159 | github_organization = var.github_organization
160 | github_repo_name = var.github_repo_name
161 | github_branch = var.github_branch
162 |
163 | image_tag = var.image_tag
164 |
165 | healthcheck_url = var.healthcheck_url
166 |
167 | build_image = var.build_image
168 | build_compute_type = var.build_compute_type
169 |
170 | efs_backup_schedule = var.efs_backup_schedule
171 | efs_backup_start_window = var.efs_backup_start_window
172 | efs_backup_completion_window = var.efs_backup_completion_window
173 | efs_backup_cold_storage_after = var.efs_backup_cold_storage_after
174 | efs_backup_delete_after = var.efs_backup_delete_after
175 |
176 | env_vars = {
177 | "JENKINS_USER" = var.jenkins_username
178 | "JENKINS_PASS" = var.jenkins_password
179 | "JENKINS_NUM_EXECUTORS" = var.jenkins_num_executors
180 | }
181 | }
182 | ```
183 | # How to get started quickly
184 | #quickstart: |-
185 | # Here's how to get started...
186 |
187 | # Other files to include in this README from the project folder
188 | include:
189 | - "docs/targets.md"
190 | - "docs/terraform.md"
191 | # Contributors to this project
192 | contributors:
193 | - name: "Erik Osterman"
194 | homepage: "https://github.com/osterman"
195 | github: "osterman"
196 | - name: "Andriy Knysh"
197 | homepage: "https://github.com/aknysh/"
198 | github: "aknysh"
199 | - name: "Igor Rodionov"
200 | homepage: "https://github.com/goruha/"
201 | github: "goruha"
202 | - name: "Ivan Pinatti"
203 | homepage: "https://github.com/ivan-pinatti/"
204 | github: "ivan-pinatti"
205 | - name: "Sergey Vasilyev"
206 | homepage: "https://github.com/s2504s/"
207 | github: "s2504s"
208 | - name: "RB"
209 | homepage: "https://github.com/nitrocode/"
210 | github: "nitrocode"
211 |
--------------------------------------------------------------------------------
/context.tf:
--------------------------------------------------------------------------------
1 | #
2 | # ONLY EDIT THIS FILE IN github.com/cloudposse/terraform-null-label
3 | # All other instances of this file should be a copy of that one
4 | #
5 | #
6 | # Copy this file from https://github.com/cloudposse/terraform-null-label/blob/master/exports/context.tf
7 | # and then place it in your Terraform module to automatically get
8 | # Cloud Posse's standard configuration inputs suitable for passing
9 | # to Cloud Posse modules.
10 | #
11 | # curl -sL https://raw.githubusercontent.com/cloudposse/terraform-null-label/master/exports/context.tf -o context.tf
12 | #
13 | # Modules should access the whole context as `module.this.context`
14 | # to get the input variables with nulls for defaults,
15 | # for example `context = module.this.context`,
16 | # and access individual variables as `module.this.`,
17 | # with final values filled in.
18 | #
19 | # For example, when using defaults, `module.this.context.delimiter`
20 | # will be null, and `module.this.delimiter` will be `-` (hyphen).
21 | #
22 |
23 | module "this" {
24 | source = "cloudposse/label/null"
25 | version = "0.25.0" # requires Terraform >= 0.13.0
26 |
27 | enabled = var.enabled
28 | namespace = var.namespace
29 | tenant = var.tenant
30 | environment = var.environment
31 | stage = var.stage
32 | name = var.name
33 | delimiter = var.delimiter
34 | attributes = var.attributes
35 | tags = var.tags
36 | additional_tag_map = var.additional_tag_map
37 | label_order = var.label_order
38 | regex_replace_chars = var.regex_replace_chars
39 | id_length_limit = var.id_length_limit
40 | label_key_case = var.label_key_case
41 | label_value_case = var.label_value_case
42 | descriptor_formats = var.descriptor_formats
43 | labels_as_tags = var.labels_as_tags
44 |
45 | context = var.context
46 | }
47 |
48 | # Copy contents of cloudposse/terraform-null-label/variables.tf here
49 |
50 | variable "context" {
51 | type = any
52 | default = {
53 | enabled = true
54 | namespace = null
55 | tenant = null
56 | environment = null
57 | stage = null
58 | name = null
59 | delimiter = null
60 | attributes = []
61 | tags = {}
62 | additional_tag_map = {}
63 | regex_replace_chars = null
64 | label_order = []
65 | id_length_limit = null
66 | label_key_case = null
67 | label_value_case = null
68 | descriptor_formats = {}
69 | # Note: we have to use [] instead of null for unset lists due to
70 | # https://github.com/hashicorp/terraform/issues/28137
71 | # which was not fixed until Terraform 1.0.0,
72 | # but we want the default to be all the labels in `label_order`
73 | # and we want users to be able to prevent all tag generation
74 | # by setting `labels_as_tags` to `[]`, so we need
75 | # a different sentinel to indicate "default"
76 | labels_as_tags = ["unset"]
77 | }
78 | description = <<-EOT
79 | Single object for setting entire context at once.
80 | See description of individual variables for details.
81 | Leave string and numeric variables as `null` to use default value.
82 | Individual variable settings (non-null) override settings in context object,
83 | except for attributes, tags, and additional_tag_map, which are merged.
84 | EOT
85 |
86 | validation {
87 | condition = lookup(var.context, "label_key_case", null) == null ? true : contains(["lower", "title", "upper"], var.context["label_key_case"])
88 | error_message = "Allowed values: `lower`, `title`, `upper`."
89 | }
90 |
91 | validation {
92 | condition = lookup(var.context, "label_value_case", null) == null ? true : contains(["lower", "title", "upper", "none"], var.context["label_value_case"])
93 | error_message = "Allowed values: `lower`, `title`, `upper`, `none`."
94 | }
95 | }
96 |
97 | variable "enabled" {
98 | type = bool
99 | default = null
100 | description = "Set to false to prevent the module from creating any resources"
101 | }
102 |
103 | variable "namespace" {
104 | type = string
105 | default = null
106 | description = "ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique"
107 | }
108 |
109 | variable "tenant" {
110 | type = string
111 | default = null
112 | description = "ID element _(Rarely used, not included by default)_. A customer identifier, indicating who this instance of a resource is for"
113 | }
114 |
115 | variable "environment" {
116 | type = string
117 | default = null
118 | description = "ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT'"
119 | }
120 |
121 | variable "stage" {
122 | type = string
123 | default = null
124 | description = "ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release'"
125 | }
126 |
127 | variable "name" {
128 | type = string
129 | default = null
130 | description = <<-EOT
131 | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
132 | This is the only ID element not also included as a `tag`.
133 | The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input.
134 | EOT
135 | }
136 |
137 | variable "delimiter" {
138 | type = string
139 | default = null
140 | description = <<-EOT
141 | Delimiter to be used between ID elements.
142 | Defaults to `-` (hyphen). Set to `""` to use no delimiter at all.
143 | EOT
144 | }
145 |
146 | variable "attributes" {
147 | type = list(string)
148 | default = []
149 | description = <<-EOT
150 | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,
151 | in the order they appear in the list. New attributes are appended to the
152 | end of the list. The elements of the list are joined by the `delimiter`
153 | and treated as a single ID element.
154 | EOT
155 | }
156 |
157 | variable "labels_as_tags" {
158 | type = set(string)
159 | default = ["default"]
160 | description = <<-EOT
161 | Set of labels (ID elements) to include as tags in the `tags` output.
162 | Default is to include all labels.
163 | Tags with empty values will not be included in the `tags` output.
164 | Set to `[]` to suppress all generated tags.
165 | **Notes:**
166 | The value of the `name` tag, if included, will be the `id`, not the `name`.
167 | Unlike other `null-label` inputs, the initial setting of `labels_as_tags` cannot be
168 | changed in later chained modules. Attempts to change it will be silently ignored.
169 | EOT
170 | }
171 |
172 | variable "tags" {
173 | type = map(string)
174 | default = {}
175 | description = <<-EOT
176 | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).
177 | Neither the tag keys nor the tag values will be modified by this module.
178 | EOT
179 | }
180 |
181 | variable "additional_tag_map" {
182 | type = map(string)
183 | default = {}
184 | description = <<-EOT
185 | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.
186 | This is for some rare cases where resources want additional configuration of tags
187 | and therefore take a list of maps with tag key, value, and additional configuration.
188 | EOT
189 | }
190 |
191 | variable "label_order" {
192 | type = list(string)
193 | default = null
194 | description = <<-EOT
195 | The order in which the labels (ID elements) appear in the `id`.
196 | Defaults to ["namespace", "environment", "stage", "name", "attributes"].
197 | You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present.
198 | EOT
199 | }
200 |
201 | variable "regex_replace_chars" {
202 | type = string
203 | default = null
204 | description = <<-EOT
205 | Terraform regular expression (regex) string.
206 | Characters matching the regex will be removed from the ID elements.
207 | If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits.
208 | EOT
209 | }
210 |
211 | variable "id_length_limit" {
212 | type = number
213 | default = null
214 | description = <<-EOT
215 | Limit `id` to this many characters (minimum 6).
216 | Set to `0` for unlimited length.
217 | Set to `null` for keep the existing setting, which defaults to `0`.
218 | Does not affect `id_full`.
219 | EOT
220 | validation {
221 | condition = var.id_length_limit == null ? true : var.id_length_limit >= 6 || var.id_length_limit == 0
222 | error_message = "The id_length_limit must be >= 6 if supplied (not null), or 0 for unlimited length."
223 | }
224 | }
225 |
226 | variable "label_key_case" {
227 | type = string
228 | default = null
229 | description = <<-EOT
230 | Controls the letter case of the `tags` keys (label names) for tags generated by this module.
231 | Does not affect keys of tags passed in via the `tags` input.
232 | Possible values: `lower`, `title`, `upper`.
233 | Default value: `title`.
234 | EOT
235 |
236 | validation {
237 | condition = var.label_key_case == null ? true : contains(["lower", "title", "upper"], var.label_key_case)
238 | error_message = "Allowed values: `lower`, `title`, `upper`."
239 | }
240 | }
241 |
242 | variable "label_value_case" {
243 | type = string
244 | default = null
245 | description = <<-EOT
246 | Controls the letter case of ID elements (labels) as included in `id`,
247 | set as tag values, and output by this module individually.
248 | Does not affect values of tags passed in via the `tags` input.
249 | Possible values: `lower`, `title`, `upper` and `none` (no transformation).
250 | Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs.
251 | Default value: `lower`.
252 | EOT
253 |
254 | validation {
255 | condition = var.label_value_case == null ? true : contains(["lower", "title", "upper", "none"], var.label_value_case)
256 | error_message = "Allowed values: `lower`, `title`, `upper`, `none`."
257 | }
258 | }
259 |
260 | variable "descriptor_formats" {
261 | type = any
262 | default = {}
263 | description = <<-EOT
264 | Describe additional descriptors to be output in the `descriptors` output map.
265 | Map of maps. Keys are names of descriptors. Values are maps of the form
266 | `{
267 | format = string
268 | labels = list(string)
269 | }`
270 | (Type is `any` so the map values can later be enhanced to provide additional options.)
271 | `format` is a Terraform format string to be passed to the `format()` function.
272 | `labels` is a list of labels, in order, to pass to `format()` function.
273 | Label values will be normalized before being passed to `format()` so they will be
274 | identical to how they appear in `id`.
275 | Default is `{}` (`descriptors` output will be empty).
276 | EOT
277 | }
278 |
279 | #### End of copy of cloudposse/terraform-null-label/variables.tf
280 |
--------------------------------------------------------------------------------
/docs/targets.md:
--------------------------------------------------------------------------------
1 |
2 | ## Makefile Targets
3 | ```text
4 | Available targets:
5 |
6 | help Help screen
7 | help/all Display help for all targets
8 | help/short This help short screen
9 | lint Lint terraform code
10 |
11 | ```
12 |
13 |
--------------------------------------------------------------------------------
/docs/terraform.md:
--------------------------------------------------------------------------------
1 |
2 | ## Requirements
3 |
4 | | Name | Version |
5 | |------|---------|
6 | | [terraform](#requirement\_terraform) | >= 0.14.0 |
7 | | [aws](#requirement\_aws) | >= 2.0 |
8 |
9 | ## Providers
10 |
11 | | Name | Version |
12 | |------|---------|
13 | | [aws](#provider\_aws) | >= 2.0 |
14 |
15 | ## Modules
16 |
17 | | Name | Source | Version |
18 | |------|--------|---------|
19 | | [cicd](#module\_cicd) | cloudposse/cicd/aws | 0.19.5 |
20 | | [ecr](#module\_ecr) | cloudposse/ecr/aws | 0.34.0 |
21 | | [efs](#module\_efs) | cloudposse/efs/aws | 0.32.7 |
22 | | [efs\_backup](#module\_efs\_backup) | cloudposse/backup/aws | 0.14.0 |
23 | | [elastic\_beanstalk\_application](#module\_elastic\_beanstalk\_application) | cloudposse/elastic-beanstalk-application/aws | 0.11.1 |
24 | | [elastic\_beanstalk\_environment](#module\_elastic\_beanstalk\_environment) | cloudposse/elastic-beanstalk-environment/aws | 0.46.0 |
25 | | [label\_slaves](#module\_label\_slaves) | cloudposse/label/null | 0.25.0 |
26 | | [this](#module\_this) | cloudposse/label/null | 0.25.0 |
27 |
28 | ## Resources
29 |
30 | | Name | Type |
31 | |------|------|
32 | | [aws_iam_policy.slaves](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
33 | | [aws_iam_role_policy_attachment.slaves](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
34 | | [aws_security_group.slaves](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource |
35 | | [aws_iam_policy_document.slaves](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
36 |
37 | ## Inputs
38 |
39 | | Name | Description | Type | Default | Required |
40 | |------|-------------|------|---------|:--------:|
41 | | [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.
This is for some rare cases where resources want additional configuration of tags
and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
42 | | [application\_subnets](#input\_application\_subnets) | List of subnets to place EC2 instances and EFS | `list(string)` | n/a | yes |
43 | | [associated\_security\_group\_ids](#input\_associated\_security\_group\_ids) | List of security groups to be allowed to connect to Jenkins master EC2 instances | `list(string)` | `[]` | no |
44 | | [attributes](#input\_attributes) | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,
in the order they appear in the list. New attributes are appended to the
end of the list. The elements of the list are joined by the `delimiter`
and treated as a single ID element. | `list(string)` | `[]` | no |
45 | | [availability\_zone\_selector](#input\_availability\_zone\_selector) | Availability Zone selector | `string` | `"Any"` | no |
46 | | [availability\_zones](#input\_availability\_zones) | List of Availability Zones for EFS | `list(string)` | n/a | yes |
47 | | [aws\_account\_id](#input\_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` | n/a | yes |
48 | | [build\_compute\_type](#input\_build\_compute\_type) | CodeBuild compute type, e.g. 'BUILD\_GENERAL1\_SMALL'. For more info: https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html | `string` | `"BUILD_GENERAL1_SMALL"` | no |
49 | | [build\_image](#input\_build\_image) | CodeBuild build image, e.g. 'aws/codebuild/amazonlinux2-x86\_64-standard:1.0'. For more info: https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html | `string` | `"aws/codebuild/docker:1.12.1"` | no |
50 | | [cicd\_bucket\_force\_destroy](#input\_cicd\_bucket\_force\_destroy) | Force destroy the CI/CD S3 bucket even if it's not empty | `bool` | `false` | no |
51 | | [context](#input\_context) | Single object for setting entire context at once.
See description of individual variables for details.
Leave string and numeric variables as `null` to use default value.
Individual variable settings (non-null) override settings in context object,
except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | {
"additional_tag_map": {},
"attributes": [],
"delimiter": null,
"descriptor_formats": {},
"enabled": true,
"environment": null,
"id_length_limit": null,
"label_key_case": null,
"label_order": [],
"label_value_case": null,
"labels_as_tags": [
"unset"
],
"name": null,
"namespace": null,
"regex_replace_chars": null,
"stage": null,
"tags": {},
"tenant": null
}
| no |
52 | | [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.
Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
53 | | [description](#input\_description) | Will be used as Elastic Beanstalk application description | `string` | `"Jenkins server as Docker container running on Elastic Benastalk"` | no |
54 | | [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.
Map of maps. Keys are names of descriptors. Values are maps of the form
`{
format = string
labels = list(string)
}`
(Type is `any` so the map values can later be enhanced to provide additional options.)
`format` is a Terraform format string to be passed to the `format()` function.
`labels` is a list of labels, in order, to pass to `format()` function.
Label values will be normalized before being passed to `format()` so they will be
identical to how they appear in `id`.
Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no |
55 | | [dns\_zone\_id](#input\_dns\_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` | n/a | yes |
56 | | [efs\_backup\_cold\_storage\_after](#input\_efs\_backup\_cold\_storage\_after) | Specifies the number of days after creation that a recovery point is moved to cold storage | `number` | `null` | no |
57 | | [efs\_backup\_completion\_window](#input\_efs\_backup\_completion\_window) | The amount of time AWS Backup attempts a backup before canceling the job and returning an error. Must be at least 60 minutes greater than `start_window` | `number` | `null` | no |
58 | | [efs\_backup\_delete\_after](#input\_efs\_backup\_delete\_after) | Specifies the number of days after creation that a recovery point is deleted. Must be 90 days greater than `cold_storage_after` | `number` | `null` | no |
59 | | [efs\_backup\_schedule](#input\_efs\_backup\_schedule) | A CRON expression specifying when AWS Backup initiates a backup job | `string` | `null` | no |
60 | | [efs\_backup\_start\_window](#input\_efs\_backup\_start\_window) | The amount of time in minutes before beginning a backup. Minimum value is 60 minutes | `number` | `null` | no |
61 | | [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
62 | | [env\_vars](#input\_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(string)` | `{}` | no |
63 | | [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
64 | | [environment\_type](#input\_environment\_type) | Environment type, e.g. 'LoadBalanced' or 'SingleInstance'. If setting to 'SingleInstance', `rolling_update_type` must be set to 'Time' or `Immutable`, and `loadbalancer_subnets` will be unused (it applies to the ELB, which does not exist in SingleInstance environments) | `string` | `"LoadBalanced"` | no |
65 | | [github\_branch](#input\_github\_branch) | GitHub repository branch, e.g. 'master'. By default, this module will deploy 'https://github.com/cloudposse/jenkins' master branch | `string` | `"master"` | no |
66 | | [github\_oauth\_token](#input\_github\_oauth\_token) | GitHub Oauth Token | `string` | n/a | yes |
67 | | [github\_organization](#input\_github\_organization) | GitHub organization, e.g. 'cloudposse'. By default, this module will deploy 'https://github.com/cloudposse/jenkins' repository | `string` | `"cloudposse"` | no |
68 | | [github\_repo\_name](#input\_github\_repo\_name) | GitHub repository name, e.g. 'jenkins'. By default, this module will deploy 'https://github.com/cloudposse/jenkins' repository | `string` | `"jenkins"` | no |
69 | | [healthcheck\_url](#input\_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 |
70 | | [id\_length\_limit](#input\_id\_length\_limit) | Limit `id` to this many characters (minimum 6).
Set to `0` for unlimited length.
Set to `null` for keep the existing setting, which defaults to `0`.
Does not affect `id_full`. | `number` | `null` | no |
71 | | [image\_tag](#input\_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 |
72 | | [label\_key\_case](#input\_label\_key\_case) | Controls the letter case of the `tags` keys (label names) for tags generated by this module.
Does not affect keys of tags passed in via the `tags` input.
Possible values: `lower`, `title`, `upper`.
Default value: `title`. | `string` | `null` | no |
73 | | [label\_order](#input\_label\_order) | The order in which the labels (ID elements) appear in the `id`.
Defaults to ["namespace", "environment", "stage", "name", "attributes"].
You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present. | `list(string)` | `null` | no |
74 | | [label\_value\_case](#input\_label\_value\_case) | Controls the letter case of ID elements (labels) as included in `id`,
set as tag values, and output by this module individually.
Does not affect values of tags passed in via the `tags` input.
Possible values: `lower`, `title`, `upper` and `none` (no transformation).
Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs.
Default value: `lower`. | `string` | `null` | no |
75 | | [labels\_as\_tags](#input\_labels\_as\_tags) | Set of labels (ID elements) to include as tags in the `tags` output.
Default is to include all labels.
Tags with empty values will not be included in the `tags` output.
Set to `[]` to suppress all generated tags.
**Notes:**
The value of the `name` tag, if included, will be the `id`, not the `name`.
Unlike other `null-label` inputs, the initial setting of `labels_as_tags` cannot be
changed in later chained modules. Attempts to change it will be silently ignored. | `set(string)` | [
"default"
]
| no |
76 | | [loadbalancer\_certificate\_arn](#input\_loadbalancer\_certificate\_arn) | Load Balancer SSL certificate ARN. The certificate must be present in AWS Certificate Manager | `string` | `""` | no |
77 | | [loadbalancer\_logs\_bucket\_force\_destroy](#input\_loadbalancer\_logs\_bucket\_force\_destroy) | Force destroy the S3 bucket for load balancer logs even if it's not empty | `bool` | `false` | no |
78 | | [loadbalancer\_ssl\_policy](#input\_loadbalancer\_ssl\_policy) | Specify a security policy to apply to the listener. This option is only applicable to environments with an application load balancer | `string` | `""` | no |
79 | | [loadbalancer\_subnets](#input\_loadbalancer\_subnets) | List of subnets to place Elastic Load Balancer | `list(string)` | n/a | yes |
80 | | [loadbalancer\_type](#input\_loadbalancer\_type) | Load Balancer type, e.g. 'application' or 'classic' | `string` | `"application"` | no |
81 | | [master\_instance\_type](#input\_master\_instance\_type) | EC2 instance type for Jenkins master, e.g. 't2.medium' | `string` | `"t2.medium"` | no |
82 | | [name](#input\_name) | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
This is the only ID element not also included as a `tag`.
The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input. | `string` | `null` | no |
83 | | [namespace](#input\_namespace) | ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique | `string` | `null` | no |
84 | | [regex\_replace\_chars](#input\_regex\_replace\_chars) | Terraform regular expression (regex) string.
Characters matching the regex will be removed from the ID elements.
If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. | `string` | `null` | no |
85 | | [region](#input\_region) | AWS region in which to provision the AWS resources | `string` | n/a | yes |
86 | | [rolling\_update\_type](#input\_rolling\_update\_type) | `Health`, `Time` or `Immutable`. Set it to `Immutable` to apply the configuration change to a fresh group of instances. For more details, see https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options-general.html#command-options-general-autoscalingupdatepolicyrollingupdate | `string` | `"Health"` | no |
87 | | [solution\_stack\_name](#input\_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 2018.03 v2.12.17 running Docker 18.06.1-ce"` | no |
88 | | [ssh\_key\_pair](#input\_ssh\_key\_pair) | Name of SSH key that will be deployed on Elastic Beanstalk instances. The key should be present in AWS | `string` | `""` | no |
89 | | [stage](#input\_stage) | ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release' | `string` | `null` | no |
90 | | [tags](#input\_tags) | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).
Neither the tag keys nor the tag values will be modified by this module. | `map(string)` | `{}` | no |
91 | | [tenant](#input\_tenant) | ID element \_(Rarely used, not included by default)\_. A customer identifier, indicating who this instance of a resource is for | `string` | `null` | no |
92 | | [use\_efs\_ip\_address](#input\_use\_efs\_ip\_address) | If set to `true`, will provide the EFS IP address instead of DNS name to Jenkins as ENV var | `bool` | `false` | no |
93 | | [vpc\_id](#input\_vpc\_id) | ID of the VPC in which to provision the AWS resources | `string` | n/a | yes |
94 |
95 | ## Outputs
96 |
97 | | Name | Description |
98 | |------|-------------|
99 | | [codebuild\_badge\_url](#output\_codebuild\_badge\_url) | The URL of the build badge when badge\_enabled is enabled |
100 | | [codebuild\_cache\_bucket\_arn](#output\_codebuild\_cache\_bucket\_arn) | CodeBuild cache S3 bucket ARN |
101 | | [codebuild\_cache\_bucket\_name](#output\_codebuild\_cache\_bucket\_name) | CodeBuild cache S3 bucket name |
102 | | [codebuild\_project\_id](#output\_codebuild\_project\_id) | CodeBuild project ID |
103 | | [codebuild\_project\_name](#output\_codebuild\_project\_name) | CodeBuild project name |
104 | | [codebuild\_role\_arn](#output\_codebuild\_role\_arn) | CodeBuild IAM Role ARN |
105 | | [codebuild\_role\_id](#output\_codebuild\_role\_id) | CodeBuild IAM Role ID |
106 | | [codepipeline\_arn](#output\_codepipeline\_arn) | CodePipeline ARN |
107 | | [codepipeline\_id](#output\_codepipeline\_id) | CodePipeline ID |
108 | | [ecr\_registry\_id](#output\_ecr\_registry\_id) | Registry ID |
109 | | [ecr\_repository\_name](#output\_ecr\_repository\_name) | Repository name |
110 | | [ecr\_repository\_url](#output\_ecr\_repository\_url) | Repository URL |
111 | | [efs\_arn](#output\_efs\_arn) | EFS ARN |
112 | | [efs\_backup\_plan\_arn](#output\_efs\_backup\_plan\_arn) | Backup Plan ARN |
113 | | [efs\_backup\_plan\_version](#output\_efs\_backup\_plan\_version) | Unique, randomly generated, Unicode, UTF-8 encoded string that serves as the version ID of the backup plan |
114 | | [efs\_backup\_selection\_id](#output\_efs\_backup\_selection\_id) | Backup Selection ID |
115 | | [efs\_backup\_vault\_arn](#output\_efs\_backup\_vault\_arn) | Backup Vault ARN |
116 | | [efs\_backup\_vault\_id](#output\_efs\_backup\_vault\_id) | Backup Vault ID |
117 | | [efs\_dns\_name](#output\_efs\_dns\_name) | EFS DNS name |
118 | | [efs\_host](#output\_efs\_host) | Route53 DNS hostname for the EFS |
119 | | [efs\_id](#output\_efs\_id) | EFS ID |
120 | | [efs\_mount\_target\_dns\_names](#output\_efs\_mount\_target\_dns\_names) | List of EFS mount target DNS names |
121 | | [efs\_mount\_target\_ids](#output\_efs\_mount\_target\_ids) | List of EFS mount target IDs (one per Availability Zone) |
122 | | [efs\_mount\_target\_ips](#output\_efs\_mount\_target\_ips) | List of EFS mount target IPs (one per Availability Zone) |
123 | | [efs\_network\_interface\_ids](#output\_efs\_network\_interface\_ids) | List of mount target network interface IDs |
124 | | [elastic\_beanstalk\_application\_name](#output\_elastic\_beanstalk\_application\_name) | Elastic Beanstalk Application name |
125 | | [elastic\_beanstalk\_environment\_all\_settings](#output\_elastic\_beanstalk\_environment\_all\_settings) | List of all option settings configured in the environment. These are a combination of default settings and their overrides from setting in the configuration |
126 | | [elastic\_beanstalk\_environment\_application](#output\_elastic\_beanstalk\_environment\_application) | The Elastic Beanstalk Application specified for this environment |
127 | | [elastic\_beanstalk\_environment\_autoscaling\_groups](#output\_elastic\_beanstalk\_environment\_autoscaling\_groups) | The autoscaling groups used by this environment |
128 | | [elastic\_beanstalk\_environment\_ec2\_instance\_profile\_role\_name](#output\_elastic\_beanstalk\_environment\_ec2\_instance\_profile\_role\_name) | Instance IAM role name |
129 | | [elastic\_beanstalk\_environment\_elb\_zone\_id](#output\_elastic\_beanstalk\_environment\_elb\_zone\_id) | ELB zone id |
130 | | [elastic\_beanstalk\_environment\_endpoint](#output\_elastic\_beanstalk\_environment\_endpoint) | Fully qualified DNS name for the environment |
131 | | [elastic\_beanstalk\_environment\_hostname](#output\_elastic\_beanstalk\_environment\_hostname) | DNS hostname |
132 | | [elastic\_beanstalk\_environment\_id](#output\_elastic\_beanstalk\_environment\_id) | ID of the Elastic Beanstalk environment |
133 | | [elastic\_beanstalk\_environment\_instances](#output\_elastic\_beanstalk\_environment\_instances) | Instances used by this environment |
134 | | [elastic\_beanstalk\_environment\_launch\_configurations](#output\_elastic\_beanstalk\_environment\_launch\_configurations) | Launch configurations in use by this environment |
135 | | [elastic\_beanstalk\_environment\_load\_balancers](#output\_elastic\_beanstalk\_environment\_load\_balancers) | Elastic Load Balancers in use by this environment |
136 | | [elastic\_beanstalk\_environment\_name](#output\_elastic\_beanstalk\_environment\_name) | Name |
137 | | [elastic\_beanstalk\_environment\_queues](#output\_elastic\_beanstalk\_environment\_queues) | SQS queues in use by this environment |
138 | | [elastic\_beanstalk\_environment\_security\_group\_id](#output\_elastic\_beanstalk\_environment\_security\_group\_id) | Security group id |
139 | | [elastic\_beanstalk\_environment\_setting](#output\_elastic\_beanstalk\_environment\_setting) | Settings specifically set for this environment |
140 | | [elastic\_beanstalk\_environment\_tier](#output\_elastic\_beanstalk\_environment\_tier) | The environment tier |
141 | | [elastic\_beanstalk\_environment\_triggers](#output\_elastic\_beanstalk\_environment\_triggers) | Autoscaling triggers in use by this environment |
142 |
143 |
--------------------------------------------------------------------------------
/examples/complete/context.tf:
--------------------------------------------------------------------------------
1 | #
2 | # ONLY EDIT THIS FILE IN github.com/cloudposse/terraform-null-label
3 | # All other instances of this file should be a copy of that one
4 | #
5 | #
6 | # Copy this file from https://github.com/cloudposse/terraform-null-label/blob/master/exports/context.tf
7 | # and then place it in your Terraform module to automatically get
8 | # Cloud Posse's standard configuration inputs suitable for passing
9 | # to Cloud Posse modules.
10 | #
11 | # curl -sL https://raw.githubusercontent.com/cloudposse/terraform-null-label/master/exports/context.tf -o context.tf
12 | #
13 | # Modules should access the whole context as `module.this.context`
14 | # to get the input variables with nulls for defaults,
15 | # for example `context = module.this.context`,
16 | # and access individual variables as `module.this.`,
17 | # with final values filled in.
18 | #
19 | # For example, when using defaults, `module.this.context.delimiter`
20 | # will be null, and `module.this.delimiter` will be `-` (hyphen).
21 | #
22 |
23 | module "this" {
24 | source = "cloudposse/label/null"
25 | version = "0.25.0" # requires Terraform >= 0.13.0
26 |
27 | enabled = var.enabled
28 | namespace = var.namespace
29 | tenant = var.tenant
30 | environment = var.environment
31 | stage = var.stage
32 | name = var.name
33 | delimiter = var.delimiter
34 | attributes = var.attributes
35 | tags = var.tags
36 | additional_tag_map = var.additional_tag_map
37 | label_order = var.label_order
38 | regex_replace_chars = var.regex_replace_chars
39 | id_length_limit = var.id_length_limit
40 | label_key_case = var.label_key_case
41 | label_value_case = var.label_value_case
42 | descriptor_formats = var.descriptor_formats
43 | labels_as_tags = var.labels_as_tags
44 |
45 | context = var.context
46 | }
47 |
48 | # Copy contents of cloudposse/terraform-null-label/variables.tf here
49 |
50 | variable "context" {
51 | type = any
52 | default = {
53 | enabled = true
54 | namespace = null
55 | tenant = null
56 | environment = null
57 | stage = null
58 | name = null
59 | delimiter = null
60 | attributes = []
61 | tags = {}
62 | additional_tag_map = {}
63 | regex_replace_chars = null
64 | label_order = []
65 | id_length_limit = null
66 | label_key_case = null
67 | label_value_case = null
68 | descriptor_formats = {}
69 | # Note: we have to use [] instead of null for unset lists due to
70 | # https://github.com/hashicorp/terraform/issues/28137
71 | # which was not fixed until Terraform 1.0.0,
72 | # but we want the default to be all the labels in `label_order`
73 | # and we want users to be able to prevent all tag generation
74 | # by setting `labels_as_tags` to `[]`, so we need
75 | # a different sentinel to indicate "default"
76 | labels_as_tags = ["unset"]
77 | }
78 | description = <<-EOT
79 | Single object for setting entire context at once.
80 | See description of individual variables for details.
81 | Leave string and numeric variables as `null` to use default value.
82 | Individual variable settings (non-null) override settings in context object,
83 | except for attributes, tags, and additional_tag_map, which are merged.
84 | EOT
85 |
86 | validation {
87 | condition = lookup(var.context, "label_key_case", null) == null ? true : contains(["lower", "title", "upper"], var.context["label_key_case"])
88 | error_message = "Allowed values: `lower`, `title`, `upper`."
89 | }
90 |
91 | validation {
92 | condition = lookup(var.context, "label_value_case", null) == null ? true : contains(["lower", "title", "upper", "none"], var.context["label_value_case"])
93 | error_message = "Allowed values: `lower`, `title`, `upper`, `none`."
94 | }
95 | }
96 |
97 | variable "enabled" {
98 | type = bool
99 | default = null
100 | description = "Set to false to prevent the module from creating any resources"
101 | }
102 |
103 | variable "namespace" {
104 | type = string
105 | default = null
106 | description = "ID element. Usually an abbreviation of your organization name, e.g. 'eg' or 'cp', to help ensure generated IDs are globally unique"
107 | }
108 |
109 | variable "tenant" {
110 | type = string
111 | default = null
112 | description = "ID element _(Rarely used, not included by default)_. A customer identifier, indicating who this instance of a resource is for"
113 | }
114 |
115 | variable "environment" {
116 | type = string
117 | default = null
118 | description = "ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT'"
119 | }
120 |
121 | variable "stage" {
122 | type = string
123 | default = null
124 | description = "ID element. Usually used to indicate role, e.g. 'prod', 'staging', 'source', 'build', 'test', 'deploy', 'release'"
125 | }
126 |
127 | variable "name" {
128 | type = string
129 | default = null
130 | description = <<-EOT
131 | ID element. Usually the component or solution name, e.g. 'app' or 'jenkins'.
132 | This is the only ID element not also included as a `tag`.
133 | The "name" tag is set to the full `id` string. There is no tag with the value of the `name` input.
134 | EOT
135 | }
136 |
137 | variable "delimiter" {
138 | type = string
139 | default = null
140 | description = <<-EOT
141 | Delimiter to be used between ID elements.
142 | Defaults to `-` (hyphen). Set to `""` to use no delimiter at all.
143 | EOT
144 | }
145 |
146 | variable "attributes" {
147 | type = list(string)
148 | default = []
149 | description = <<-EOT
150 | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,
151 | in the order they appear in the list. New attributes are appended to the
152 | end of the list. The elements of the list are joined by the `delimiter`
153 | and treated as a single ID element.
154 | EOT
155 | }
156 |
157 | variable "labels_as_tags" {
158 | type = set(string)
159 | default = ["default"]
160 | description = <<-EOT
161 | Set of labels (ID elements) to include as tags in the `tags` output.
162 | Default is to include all labels.
163 | Tags with empty values will not be included in the `tags` output.
164 | Set to `[]` to suppress all generated tags.
165 | **Notes:**
166 | The value of the `name` tag, if included, will be the `id`, not the `name`.
167 | Unlike other `null-label` inputs, the initial setting of `labels_as_tags` cannot be
168 | changed in later chained modules. Attempts to change it will be silently ignored.
169 | EOT
170 | }
171 |
172 | variable "tags" {
173 | type = map(string)
174 | default = {}
175 | description = <<-EOT
176 | Additional tags (e.g. `{'BusinessUnit': 'XYZ'}`).
177 | Neither the tag keys nor the tag values will be modified by this module.
178 | EOT
179 | }
180 |
181 | variable "additional_tag_map" {
182 | type = map(string)
183 | default = {}
184 | description = <<-EOT
185 | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.
186 | This is for some rare cases where resources want additional configuration of tags
187 | and therefore take a list of maps with tag key, value, and additional configuration.
188 | EOT
189 | }
190 |
191 | variable "label_order" {
192 | type = list(string)
193 | default = null
194 | description = <<-EOT
195 | The order in which the labels (ID elements) appear in the `id`.
196 | Defaults to ["namespace", "environment", "stage", "name", "attributes"].
197 | You can omit any of the 6 labels ("tenant" is the 6th), but at least one must be present.
198 | EOT
199 | }
200 |
201 | variable "regex_replace_chars" {
202 | type = string
203 | default = null
204 | description = <<-EOT
205 | Terraform regular expression (regex) string.
206 | Characters matching the regex will be removed from the ID elements.
207 | If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits.
208 | EOT
209 | }
210 |
211 | variable "id_length_limit" {
212 | type = number
213 | default = null
214 | description = <<-EOT
215 | Limit `id` to this many characters (minimum 6).
216 | Set to `0` for unlimited length.
217 | Set to `null` for keep the existing setting, which defaults to `0`.
218 | Does not affect `id_full`.
219 | EOT
220 | validation {
221 | condition = var.id_length_limit == null ? true : var.id_length_limit >= 6 || var.id_length_limit == 0
222 | error_message = "The id_length_limit must be >= 6 if supplied (not null), or 0 for unlimited length."
223 | }
224 | }
225 |
226 | variable "label_key_case" {
227 | type = string
228 | default = null
229 | description = <<-EOT
230 | Controls the letter case of the `tags` keys (label names) for tags generated by this module.
231 | Does not affect keys of tags passed in via the `tags` input.
232 | Possible values: `lower`, `title`, `upper`.
233 | Default value: `title`.
234 | EOT
235 |
236 | validation {
237 | condition = var.label_key_case == null ? true : contains(["lower", "title", "upper"], var.label_key_case)
238 | error_message = "Allowed values: `lower`, `title`, `upper`."
239 | }
240 | }
241 |
242 | variable "label_value_case" {
243 | type = string
244 | default = null
245 | description = <<-EOT
246 | Controls the letter case of ID elements (labels) as included in `id`,
247 | set as tag values, and output by this module individually.
248 | Does not affect values of tags passed in via the `tags` input.
249 | Possible values: `lower`, `title`, `upper` and `none` (no transformation).
250 | Set this to `title` and set `delimiter` to `""` to yield Pascal Case IDs.
251 | Default value: `lower`.
252 | EOT
253 |
254 | validation {
255 | condition = var.label_value_case == null ? true : contains(["lower", "title", "upper", "none"], var.label_value_case)
256 | error_message = "Allowed values: `lower`, `title`, `upper`, `none`."
257 | }
258 | }
259 |
260 | variable "descriptor_formats" {
261 | type = any
262 | default = {}
263 | description = <<-EOT
264 | Describe additional descriptors to be output in the `descriptors` output map.
265 | Map of maps. Keys are names of descriptors. Values are maps of the form
266 | `{
267 | format = string
268 | labels = list(string)
269 | }`
270 | (Type is `any` so the map values can later be enhanced to provide additional options.)
271 | `format` is a Terraform format string to be passed to the `format()` function.
272 | `labels` is a list of labels, in order, to pass to `format()` function.
273 | Label values will be normalized before being passed to `format()` so they will be
274 | identical to how they appear in `id`.
275 | Default is `{}` (`descriptors` output will be empty).
276 | EOT
277 | }
278 |
279 | #### End of copy of cloudposse/terraform-null-label/variables.tf
280 |
--------------------------------------------------------------------------------
/examples/complete/fixtures.us-east-2.tfvars:
--------------------------------------------------------------------------------
1 | region = "us-east-2"
2 |
3 | availability_zones = ["us-east-2a", "us-east-2b"]
4 |
5 | aws_account_id = "126450723953"
6 |
7 | namespace = "eg"
8 |
9 | stage = "test"
10 |
11 | name = "jenkins"
12 |
13 | description = "Jenkins server as Docker container running on Elastic Benastalk"
14 |
15 | master_instance_type = "t2.medium"
16 |
17 | healthcheck_url = "/login"
18 |
19 | # https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html
20 | # https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.docker
21 | solution_stack_name = "64bit Amazon Linux 2018.03 v2.12.17 running Docker 18.06.1-ce"
22 |
23 | dns_zone_id = "Z3SO0TKDDQ0RGG"
24 |
25 | availability_zone_selector = "Any"
26 |
27 | environment_type = "LoadBalanced"
28 |
29 | loadbalancer_type = "application"
30 |
31 | loadbalancer_logs_bucket_force_destroy = true
32 |
33 | cicd_bucket_force_destroy = true
34 |
35 | rolling_update_type = "Health"
36 |
37 | # `github_oauth_token` is required for CodePipeline to download the Jenkins repo (https://github.com/cloudposse/jenkins) from GitHub
38 | # Can be provided in `TF_VAR_github_oauth_token` environment variable
39 | github_oauth_token = "XXXXXXXXXXXXXX"
40 |
41 | github_organization = "cloudposse"
42 |
43 | github_repo_name = "jenkins"
44 |
45 | github_branch = "master"
46 |
47 | # https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html
48 | build_image = "aws/codebuild/docker:1.12.1"
49 |
50 | # https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html
51 | build_compute_type = "BUILD_GENERAL1_SMALL"
52 |
53 | image_tag = "latest"
54 |
55 | efs_backup_schedule = "cron(0 12 * * ? *)"
56 |
57 | efs_backup_start_window = 60
58 |
59 | efs_backup_completion_window = 120
60 |
61 | efs_backup_cold_storage_after = 30
62 |
63 | efs_backup_delete_after = 180
64 |
65 | jenkins_username = "admin"
66 |
67 | jenkins_password = "1234567"
68 |
69 | jenkins_num_executors = 2
70 |
--------------------------------------------------------------------------------
/examples/complete/main.tf:
--------------------------------------------------------------------------------
1 | provider "aws" {
2 | region = var.region
3 | }
4 |
5 | module "vpc" {
6 | source = "cloudposse/vpc/aws"
7 | version = "0.18.1"
8 | cidr_block = "172.16.0.0/16"
9 |
10 | context = module.this.context
11 | }
12 |
13 | module "subnets" {
14 | source = "cloudposse/dynamic-subnets/aws"
15 | version = "0.33.0"
16 | availability_zones = var.availability_zones
17 | vpc_id = module.vpc.vpc_id
18 | igw_id = module.vpc.igw_id
19 | cidr_block = module.vpc.vpc_cidr_block
20 | nat_gateway_enabled = true
21 | nat_instance_enabled = false
22 |
23 | context = module.this.context
24 | }
25 |
26 | module "jenkins" {
27 | source = "../../"
28 | description = var.description
29 |
30 | master_instance_type = var.master_instance_type
31 | aws_account_id = var.aws_account_id
32 | region = var.region
33 | availability_zones = var.availability_zones
34 | vpc_id = module.vpc.vpc_id
35 | dns_zone_id = var.dns_zone_id
36 | loadbalancer_subnets = module.subnets.public_subnet_ids
37 | application_subnets = module.subnets.private_subnet_ids
38 |
39 | environment_type = var.environment_type
40 | loadbalancer_type = var.loadbalancer_type
41 | loadbalancer_certificate_arn = var.loadbalancer_certificate_arn
42 | availability_zone_selector = var.availability_zone_selector
43 | rolling_update_type = var.rolling_update_type
44 | loadbalancer_logs_bucket_force_destroy = var.loadbalancer_logs_bucket_force_destroy
45 | cicd_bucket_force_destroy = var.cicd_bucket_force_destroy
46 |
47 | github_oauth_token = var.github_oauth_token
48 | github_organization = var.github_organization
49 | github_repo_name = var.github_repo_name
50 | github_branch = var.github_branch
51 |
52 | image_tag = var.image_tag
53 |
54 | healthcheck_url = var.healthcheck_url
55 |
56 | build_image = var.build_image
57 | build_compute_type = var.build_compute_type
58 |
59 | efs_backup_schedule = var.efs_backup_schedule
60 | efs_backup_start_window = var.efs_backup_start_window
61 | efs_backup_completion_window = var.efs_backup_completion_window
62 | efs_backup_cold_storage_after = var.efs_backup_cold_storage_after
63 | efs_backup_delete_after = var.efs_backup_delete_after
64 |
65 | env_vars = {
66 | "JENKINS_USER" = var.jenkins_username
67 | "JENKINS_PASS" = var.jenkins_password
68 | "JENKINS_NUM_EXECUTORS" = var.jenkins_num_executors
69 | }
70 |
71 | context = module.this.context
72 | }
73 |
--------------------------------------------------------------------------------
/examples/complete/outputs.tf:
--------------------------------------------------------------------------------
1 | output "public_subnet_cidrs" {
2 | value = module.subnets.public_subnet_cidrs
3 | description = "Public subnet CIDRs"
4 | }
5 |
6 | output "private_subnet_cidrs" {
7 | value = module.subnets.private_subnet_cidrs
8 | description = "Private subnet CIDRs"
9 | }
10 |
11 | output "vpc_cidr" {
12 | value = module.vpc.vpc_cidr_block
13 | description = "VPC ID"
14 | }
15 |
16 | output "elastic_beanstalk_application_name" {
17 | value = module.jenkins.elastic_beanstalk_application_name
18 | description = "Elastic Beanstalk Application name"
19 | }
20 |
21 | output "elastic_beanstalk_environment_hostname" {
22 | value = module.jenkins.elastic_beanstalk_environment_hostname
23 | description = "DNS hostname"
24 | }
25 |
26 | output "elastic_beanstalk_environment_id" {
27 | description = "ID of the Elastic Beanstalk environment"
28 | value = module.jenkins.elastic_beanstalk_environment_id
29 | }
30 |
31 | output "elastic_beanstalk_environment_name" {
32 | value = module.jenkins.elastic_beanstalk_environment_name
33 | description = "Name"
34 | }
35 |
36 | output "elastic_beanstalk_environment_security_group_id" {
37 | value = module.jenkins.elastic_beanstalk_environment_security_group_id
38 | description = "Security group id"
39 | }
40 |
41 | output "elastic_beanstalk_environment_elb_zone_id" {
42 | value = module.jenkins.elastic_beanstalk_environment_elb_zone_id
43 | description = "ELB zone id"
44 | }
45 |
46 | output "elastic_beanstalk_environment_ec2_instance_profile_role_name" {
47 | value = module.jenkins.elastic_beanstalk_environment_ec2_instance_profile_role_name
48 | description = "Instance IAM role name"
49 | }
50 |
51 | output "elastic_beanstalk_environment_tier" {
52 | description = "The environment tier"
53 | value = module.jenkins.elastic_beanstalk_environment_tier
54 | }
55 |
56 | output "elastic_beanstalk_environment_setting" {
57 | description = "Settings specifically set for this environment"
58 | value = module.jenkins.elastic_beanstalk_environment_setting
59 | }
60 |
61 | output "elastic_beanstalk_environment_all_settings" {
62 | description = "List of all option settings configured in the environment. These are a combination of default settings and their overrides from setting in the configuration"
63 | value = module.jenkins.elastic_beanstalk_environment_all_settings
64 | }
65 |
66 | output "elastic_beanstalk_environment_endpoint" {
67 | description = "Fully qualified DNS name for the environment"
68 | value = module.jenkins.elastic_beanstalk_environment_endpoint
69 | }
70 |
71 | output "elastic_beanstalk_environment_autoscaling_groups" {
72 | description = "The autoscaling groups used by this environment"
73 | value = module.jenkins.elastic_beanstalk_environment_autoscaling_groups
74 | }
75 |
76 | output "elastic_beanstalk_environment_instances" {
77 | description = "Instances used by this environment"
78 | value = module.jenkins.elastic_beanstalk_environment_instances
79 | }
80 |
81 | output "elastic_beanstalk_environment_launch_configurations" {
82 | description = "Launch configurations in use by this environment"
83 | value = module.jenkins.elastic_beanstalk_environment_launch_configurations
84 | }
85 |
86 | output "elastic_beanstalk_environment_load_balancers" {
87 | description = "Elastic Load Balancers in use by this environment"
88 | value = module.jenkins.elastic_beanstalk_environment_load_balancers
89 | }
90 |
91 | output "elastic_beanstalk_environment_queues" {
92 | description = "SQS queues in use by this environment"
93 | value = module.jenkins.elastic_beanstalk_environment_queues
94 | }
95 |
96 | output "elastic_beanstalk_environment_triggers" {
97 | description = "Autoscaling triggers in use by this environment"
98 | value = module.jenkins.elastic_beanstalk_environment_triggers
99 | }
100 |
101 | output "ecr_registry_id" {
102 | value = module.jenkins.ecr_registry_id
103 | description = "Registry ID"
104 | }
105 |
106 | output "ecr_repository_url" {
107 | value = module.jenkins.ecr_repository_url
108 | description = "Repository URL"
109 | }
110 |
111 | output "ecr_repository_name" {
112 | value = module.jenkins.ecr_repository_name
113 | description = "Repository name"
114 | }
115 |
116 | output "efs_arn" {
117 | value = module.jenkins.efs_arn
118 | description = "EFS ARN"
119 | }
120 |
121 | output "efs_id" {
122 | value = module.jenkins.efs_id
123 | description = "EFS ID"
124 | }
125 |
126 | output "efs_host" {
127 | value = module.jenkins.efs_host
128 | description = "Route53 DNS hostname for the EFS"
129 | }
130 |
131 | output "efs_dns_name" {
132 | value = module.jenkins.efs_dns_name
133 | description = "EFS DNS name"
134 | }
135 |
136 | output "efs_mount_target_dns_names" {
137 | value = module.jenkins.efs_mount_target_dns_names
138 | description = "List of EFS mount target DNS names"
139 | }
140 |
141 | output "efs_mount_target_ids" {
142 | value = module.jenkins.efs_mount_target_ids
143 | description = "List of EFS mount target IDs (one per Availability Zone)"
144 | }
145 |
146 | output "efs_mount_target_ips" {
147 | value = module.jenkins.efs_mount_target_ips
148 | description = "List of EFS mount target IPs (one per Availability Zone)"
149 | }
150 |
151 | output "efs_network_interface_ids" {
152 | value = module.jenkins.efs_network_interface_ids
153 | description = "List of mount target network interface IDs"
154 | }
155 |
156 | output "codebuild_project_name" {
157 | description = "CodeBuild project name"
158 | value = module.jenkins.codebuild_project_name
159 | }
160 |
161 | output "codebuild_project_id" {
162 | description = "CodeBuild project ID"
163 | value = module.jenkins.codebuild_project_id
164 | }
165 |
166 | output "codebuild_role_id" {
167 | description = "CodeBuild IAM Role ID"
168 | value = module.jenkins.codebuild_role_id
169 | }
170 |
171 | output "codebuild_role_arn" {
172 | description = "CodeBuild IAM Role ARN"
173 | value = module.jenkins.codebuild_role_arn
174 | }
175 |
176 | output "codebuild_cache_bucket_name" {
177 | description = "CodeBuild cache S3 bucket name"
178 | value = module.jenkins.codebuild_cache_bucket_name
179 | }
180 |
181 | output "codebuild_cache_bucket_arn" {
182 | description = "CodeBuild cache S3 bucket ARN"
183 | value = module.jenkins.codebuild_cache_bucket_arn
184 | }
185 |
186 | output "codebuild_badge_url" {
187 | description = "The URL of the build badge when badge_enabled is enabled"
188 | value = module.jenkins.codebuild_badge_url
189 | }
190 |
191 | output "codepipeline_id" {
192 | description = "CodePipeline ID"
193 | value = module.jenkins.codepipeline_id
194 | }
195 |
196 | output "codepipeline_arn" {
197 | description = "CodePipeline ARN"
198 | value = module.jenkins.codepipeline_arn
199 | }
200 |
201 | output "efs_backup_vault_id" {
202 | value = module.jenkins.efs_backup_vault_id
203 | description = "Backup Vault ID"
204 | }
205 |
206 | output "efs_backup_vault_arn" {
207 | value = module.jenkins.efs_backup_vault_arn
208 | description = "Backup Vault ARN"
209 | }
210 |
211 | output "efs_backup_plan_arn" {
212 | value = module.jenkins.efs_backup_plan_arn
213 | description = "Backup Plan ARN"
214 | }
215 |
216 | output "efs_backup_plan_version" {
217 | value = module.jenkins.efs_backup_plan_version
218 | description = "Unique, randomly generated, Unicode, UTF-8 encoded string that serves as the version ID of the backup plan"
219 | }
220 |
221 | output "efs_backup_selection_id" {
222 | value = module.jenkins.efs_backup_selection_id
223 | description = "Backup Selection ID"
224 | }
225 |
--------------------------------------------------------------------------------
/examples/complete/variables.tf:
--------------------------------------------------------------------------------
1 | variable "region" {
2 | type = string
3 | description = "AWS region in which to provision the AWS resources"
4 | }
5 |
6 | variable "availability_zones" {
7 | type = list(string)
8 | description = "List of Availability Zones for EFS"
9 | }
10 |
11 | variable "description" {
12 | type = string
13 | description = "Will be used as Elastic Beanstalk application description"
14 | }
15 |
16 | # https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html
17 | # https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.docker
18 | variable "solution_stack_name" {
19 | type = string
20 | description = "Elastic Beanstalk stack, e.g. Docker, Go, Node, Java, IIS. For more info: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/concepts.platforms.html"
21 | }
22 |
23 | variable "master_instance_type" {
24 | type = string
25 | description = "EC2 instance type for Jenkins master, e.g. 't2.medium'"
26 | }
27 |
28 | variable "healthcheck_url" {
29 | type = string
30 | description = "Application Health Check URL. Elastic Beanstalk will call this URL to check the health of the application running on EC2 instances"
31 | }
32 |
33 | variable "loadbalancer_type" {
34 | type = string
35 | description = "Load Balancer type, e.g. 'application' or 'classic'"
36 | }
37 |
38 | variable "loadbalancer_certificate_arn" {
39 | type = string
40 | description = "Load Balancer SSL certificate ARN. The certificate must be present in AWS Certificate Manager"
41 | default = ""
42 | }
43 |
44 | variable "availability_zone_selector" {
45 | type = string
46 | description = "Availability Zone selector"
47 | }
48 |
49 | variable "environment_type" {
50 | type = string
51 | description = "Environment type, e.g. 'LoadBalanced' or 'SingleInstance'. If setting to 'SingleInstance', `rolling_update_type` must be set to 'Time' or `Immutable`, and `loadbalancer_subnets` will be unused (it applies to the ELB, which does not exist in SingleInstance environments)"
52 | }
53 |
54 | # https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options-general.html#command-options-general-autoscalingupdatepolicyrollingupdate
55 | variable "rolling_update_type" {
56 | type = string
57 | description = "`Health`, `Time` or `Immutable`. Set it to `Immutable` to apply the configuration change to a fresh group of instances. For more details, see https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options-general.html#command-options-general-autoscalingupdatepolicyrollingupdate"
58 | }
59 |
60 | variable "dns_zone_id" {
61 | type = string
62 | description = "Route53 parent zone ID. The module will create sub-domain DNS records in the parent zone for the EB environment and EFS"
63 | }
64 |
65 | variable "github_oauth_token" {
66 | type = string
67 | description = "GitHub Oauth Token"
68 | }
69 |
70 | variable "github_organization" {
71 | type = string
72 | description = "GitHub organization, e.g. 'cloudposse'. By default, this module will deploy 'https://github.com/cloudposse/jenkins' repository"
73 | }
74 |
75 | variable "github_repo_name" {
76 | type = string
77 | description = "GitHub repository name, e.g. 'jenkins'. By default, this module will deploy 'https://github.com/cloudposse/jenkins' repository"
78 | }
79 |
80 | variable "github_branch" {
81 | type = string
82 | description = "GitHub repository branch, e.g. 'master'. By default, this module will deploy 'https://github.com/cloudposse/jenkins' master branch"
83 | }
84 |
85 | # https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html
86 | variable "build_image" {
87 | type = string
88 | description = "CodeBuild build image, e.g. 'aws/codebuild/amazonlinux2-x86_64-standard:1.0'. For more info: https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html"
89 | }
90 |
91 | # https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html
92 | variable "build_compute_type" {
93 | type = string
94 | description = "CodeBuild compute type, e.g. 'BUILD_GENERAL1_SMALL'. For more info: https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html"
95 | }
96 |
97 | variable "aws_account_id" {
98 | type = string
99 | description = "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"
100 | }
101 |
102 | variable "image_tag" {
103 | type = string
104 | description = "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"
105 | }
106 |
107 | variable "efs_backup_schedule" {
108 | type = string
109 | description = "A CRON expression specifying when AWS Backup initiates a backup job"
110 | }
111 |
112 | variable "efs_backup_start_window" {
113 | type = number
114 | description = "The amount of time in minutes before beginning a backup. Minimum value is 60 minutes"
115 | }
116 |
117 | variable "efs_backup_completion_window" {
118 | type = number
119 | description = "The amount of time AWS Backup attempts a backup before canceling the job and returning an error. Must be at least 60 minutes greater than `start_window`"
120 | }
121 |
122 | variable "efs_backup_cold_storage_after" {
123 | type = number
124 | description = "Specifies the number of days after creation that a recovery point is moved to cold storage"
125 | }
126 |
127 | variable "efs_backup_delete_after" {
128 | type = number
129 | description = "Specifies the number of days after creation that a recovery point is deleted. Must be 90 days greater than `cold_storage_after`"
130 | }
131 |
132 | variable "jenkins_username" {
133 | type = string
134 | description = "Jenkins username"
135 | }
136 |
137 | variable "jenkins_password" {
138 | type = string
139 | description = "Jenkins password"
140 | }
141 |
142 | variable "jenkins_num_executors" {
143 | type = number
144 | description = "Number of Jenkins executors (slave instances)"
145 | }
146 |
147 | variable "loadbalancer_logs_bucket_force_destroy" {
148 | type = bool
149 | description = "Force destroy the S3 bucket for load balancer logs"
150 | }
151 |
152 | variable "cicd_bucket_force_destroy" {
153 | type = bool
154 | description = "Force destroy the CI/CD S3 bucket even if it's not empty"
155 | }
156 |
--------------------------------------------------------------------------------
/examples/complete/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.14.0"
3 |
4 | required_providers {
5 | aws = {
6 | source = "hashicorp/aws"
7 | version = ">= 2.0"
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/examples/existing_vpc_existing_subnets/main.tf:
--------------------------------------------------------------------------------
1 | provider "aws" {
2 | region = "us-east-2"
3 | }
4 |
5 | variable "max_availability_zones" {
6 | default = 2
7 | }
8 |
9 | data "aws_availability_zones" "available" {}
10 |
11 | module "jenkins" {
12 | source = "../../"
13 | namespace = "eg"
14 | stage = "test"
15 | name = "jenkins"
16 | description = "Jenkins server as Docker container running on Elastic Beanstalk"
17 |
18 | master_instance_type = "t2.medium"
19 | aws_account_id = "000111222333"
20 | region = "us-west-2"
21 | availability_zones = slice(data.aws_availability_zones.available.names, 0, var.max_availability_zones)
22 | vpc_id = "vpc-a22222ee"
23 | dns_zone_id = "ZXXXXXXXXXXX"
24 | loadbalancer_subnets = ["subnet-e63f82cb", "subnet-e66f44ab", "subnet-e88f42bd"]
25 | application_subnets = ["subnet-e99d23eb", "subnet-e77e12bb", "subnet-e58a52bc"]
26 | loadbalancer_certificate_arn = "XXXXXXXXXXXXXXXXX"
27 | ssh_key_pair = "ssh-key-jenkins"
28 |
29 | github_oauth_token = ""
30 | github_organization = "cloudposse"
31 | github_repo_name = "jenkins"
32 | github_branch = "master"
33 |
34 | env_vars = {
35 | JENKINS_USER = "admin"
36 | JENKINS_PASS = "123456"
37 | JENKINS_NUM_EXECUTORS = 4
38 | }
39 |
40 | tags = {
41 | BusinessUnit = "ABC"
42 | Department = "XYZ"
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/examples/existing_vpc_new_subnets/main.tf:
--------------------------------------------------------------------------------
1 | provider "aws" {
2 | region = "us-east-2"
3 | }
4 |
5 | variable "max_availability_zones" {
6 | default = 2
7 | }
8 |
9 | data "aws_availability_zones" "available" {}
10 |
11 | module "jenkins" {
12 | source = "../../"
13 | namespace = "eg"
14 | stage = "test"
15 | name = "jenkins"
16 | description = "Jenkins server as Docker container running on Elastic Beanstalk"
17 |
18 | master_instance_type = "t2.medium"
19 | aws_account_id = "000111222333"
20 | region = "us-east-2"
21 | availability_zones = slice(data.aws_availability_zones.available.names, 0, var.max_availability_zones)
22 | vpc_id = "vpc-a22222ee"
23 | dns_zone_id = "ZXXXXXXXXXXX"
24 | loadbalancer_subnets = module.subnets.public_subnet_ids
25 | application_subnets = module.subnets.private_subnet_ids
26 | loadbalancer_certificate_arn = "XXXXXXXXXXXXXXXXX"
27 | ssh_key_pair = "ssh-key-jenkins"
28 |
29 | github_oauth_token = ""
30 | github_organization = "cloudposse"
31 | github_repo_name = "jenkins"
32 | github_branch = "master"
33 |
34 | env_vars = {
35 | JENKINS_USER = "admin"
36 | JENKINS_PASS = "123456"
37 | JENKINS_NUM_EXECUTORS = 4
38 | }
39 |
40 | tags = {
41 | BusinessUnit = "ABC"
42 | Department = "XYZ"
43 | }
44 | }
45 |
46 | module "subnets" {
47 | source = "git::https://github.com/cloudposse/terraform-aws-dynamic-subnets.git?ref=master"
48 | availability_zones = slice(data.aws_availability_zones.available.names, 0, var.max_availability_zones)
49 | namespace = "eg"
50 | stage = "test"
51 | name = "jenkins"
52 | region = "us-west-2"
53 | vpc_id = "vpc-a22222ee"
54 | igw_id = "igw-s32321vd"
55 | cidr_block = "10.0.0.0/16"
56 | nat_gateway_enabled = "true"
57 |
58 | tags = {
59 | BusinessUnit = "ABC"
60 | Department = "XYZ"
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/examples/new_vpc_new_subnets/main.tf:
--------------------------------------------------------------------------------
1 | provider "aws" {
2 | region = "us-east-2"
3 | }
4 |
5 | variable "max_availability_zones" {
6 | default = 2
7 | }
8 |
9 | data "aws_availability_zones" "available" {}
10 |
11 | module "jenkins" {
12 | source = "../../"
13 | namespace = "eg"
14 | stage = "test"
15 | name = "jenkins"
16 | description = "Jenkins server as Docker container running on Elastic Beanstalk"
17 |
18 | master_instance_type = "t2.medium"
19 | aws_account_id = "000111222333"
20 | region = "us-east-2"
21 | availability_zones = slice(data.aws_availability_zones.available.names, 0, var.max_availability_zones)
22 | vpc_id = module.vpc.vpc_id
23 | dns_zone_id = "ZXXXXXXXXXXX"
24 | loadbalancer_subnets = module.subnets.public_subnet_ids
25 | application_subnets = module.subnets.private_subnet_ids
26 | loadbalancer_certificate_arn = "XXXXXXXXXXXXXXXXX"
27 | ssh_key_pair = "ssh-key-jenkins"
28 |
29 | github_oauth_token = ""
30 | github_organization = "cloudposse"
31 | github_repo_name = "jenkins"
32 | github_branch = "master"
33 |
34 | env_vars = {
35 | JENKINS_USER = "admin"
36 | JENKINS_PASS = "123456"
37 | JENKINS_NUM_EXECUTORS = 4
38 | }
39 |
40 | tags = {
41 | BusinessUnit = "ABC"
42 | Department = "XYZ"
43 | }
44 | }
45 |
46 | module "vpc" {
47 | source = "git::https://github.com/cloudposse/terraform-aws-vpc.git?ref=master"
48 | namespace = "eg"
49 | stage = "test"
50 | name = "jenkins"
51 | cidr_block = "10.0.0.0/16"
52 |
53 | tags = {
54 | BusinessUnit = "ABC"
55 | Department = "XYZ"
56 | }
57 | }
58 |
59 | module "subnets" {
60 | source = "git::https://github.com/cloudposse/terraform-aws-dynamic-subnets.git?ref=master"
61 | availability_zones = slice(data.aws_availability_zones.available.names, 0, var.max_availability_zones)
62 | namespace = "eg"
63 | stage = "test"
64 | name = "jenkins"
65 | region = "us-east-2"
66 | vpc_id = module.vpc.vpc_id
67 | igw_id = module.vpc.igw_id
68 | cidr_block = module.vpc.vpc_cidr_block
69 | nat_gateway_enabled = true
70 |
71 | tags = {
72 | BusinessUnit = "ABC"
73 | Department = "XYZ"
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/main.tf:
--------------------------------------------------------------------------------
1 | # Elastic Beanstalk Application
2 | module "elastic_beanstalk_application" {
3 | source = "cloudposse/elastic-beanstalk-application/aws"
4 | version = "0.11.1"
5 | description = var.description
6 | attributes = ["app"]
7 |
8 | context = module.this.context
9 | }
10 |
11 | # Elastic Beanstalk Environment
12 | module "elastic_beanstalk_environment" {
13 | source = "cloudposse/elastic-beanstalk-environment/aws"
14 | version = "0.46.0"
15 | attributes = ["env"]
16 |
17 | region = var.region
18 | dns_zone_id = var.dns_zone_id
19 | elastic_beanstalk_application_name = module.elastic_beanstalk_application.elastic_beanstalk_application_name
20 | instance_type = var.master_instance_type
21 |
22 | tier = "WebServer"
23 | environment_type = var.environment_type
24 | loadbalancer_type = var.loadbalancer_type
25 | loadbalancer_certificate_arn = var.loadbalancer_certificate_arn
26 | availability_zone_selector = var.availability_zone_selector
27 | rolling_update_type = var.rolling_update_type
28 |
29 | # Set `min` and `max` number of running EC2 instances to `1` since we want only one Jenkins master running at any time
30 | autoscale_min = 1
31 | autoscale_max = 1
32 |
33 | # Since we set `autoscale_min = autoscale_max`, we need to set `updating_min_in_service` to 0 for the AutoScaling Group to work.
34 | # Elastic Beanstalk will terminate the master instance and replace it with a new one in case of any issues with it.
35 | # It's OK since we store all Jenkins state (settings, jobs, etc.) on the EFS.
36 | # If the instance gets replaced or rebooted, Jenkins will find all the data on the EFS after restart.
37 | updating_min_in_service = 0
38 |
39 | updating_max_batch = 1
40 |
41 | healthcheck_url = var.healthcheck_url
42 | vpc_id = var.vpc_id
43 | loadbalancer_subnets = var.loadbalancer_subnets
44 | application_subnets = var.application_subnets
45 | keypair = var.ssh_key_pair
46 | solution_stack_name = var.solution_stack_name
47 | force_destroy = var.loadbalancer_logs_bucket_force_destroy
48 | loadbalancer_ssl_policy = var.loadbalancer_ssl_policy
49 |
50 | associated_security_group_ids = var.associated_security_group_ids
51 |
52 | # Provide EFS DNS name to EB in the `EFS_HOST` ENV var. EC2 instance will mount to the EFS filesystem and use it to store Jenkins state
53 | # Add slaves Security Group `JENKINS_SLAVE_SECURITY_GROUPS` (comma-separated if more than one). Will be used by Jenkins to init the EC2 plugin to launch slaves inside the Security Group
54 | env_vars = merge(
55 | {
56 | "EFS_HOST" = var.use_efs_ip_address ? module.efs.mount_target_ips[0] : module.efs.dns_name
57 | "USE_EFS_IP" = var.use_efs_ip_address
58 | "JENKINS_SLAVE_SECURITY_GROUPS" = aws_security_group.slaves.id
59 | },
60 | var.env_vars
61 | )
62 |
63 | context = module.this.context
64 | }
65 |
66 | # Elastic Container Registry Docker Repository
67 | module "ecr" {
68 | source = "cloudposse/ecr/aws"
69 | version = "0.34.0"
70 |
71 | context = module.this.context
72 | }
73 |
74 | # EFS to store Jenkins state (settings, jobs, etc.)
75 | module "efs" {
76 | source = "cloudposse/efs/aws"
77 | version = "0.32.7"
78 | attributes = ["efs"]
79 | region = var.region
80 | vpc_id = var.vpc_id
81 | subnets = var.application_subnets
82 | zone_id = [var.dns_zone_id]
83 |
84 | # EC2 instances (from `elastic_beanstalk_environment`) are allowed to connect to the EFS
85 | security_groups = [module.elastic_beanstalk_environment.security_group_id]
86 |
87 | context = module.this.context
88 | }
89 |
90 | # EFS backup
91 | module "efs_backup" {
92 | source = "cloudposse/backup/aws"
93 | version = "0.14.0"
94 | attributes = ["efs"]
95 | backup_resources = [module.efs.arn]
96 | schedule = var.efs_backup_schedule
97 | start_window = var.efs_backup_start_window
98 | completion_window = var.efs_backup_completion_window
99 | cold_storage_after = var.efs_backup_cold_storage_after
100 | delete_after = var.efs_backup_delete_after
101 |
102 | context = module.this.context
103 | }
104 |
105 | # CodePipeline/CodeBuild to build Jenkins Docker image, store it to a ECR repo, and deploy it to Elastic Beanstalk running Docker stack
106 | module "cicd" {
107 | source = "cloudposse/cicd/aws"
108 | version = "0.19.5"
109 | attributes = ["cicd"]
110 | elastic_beanstalk_application_name = module.elastic_beanstalk_application.elastic_beanstalk_application_name
111 | elastic_beanstalk_environment_name = module.elastic_beanstalk_environment.name
112 | enabled = true
113 | github_oauth_token = var.github_oauth_token
114 | repo_owner = var.github_organization
115 | repo_name = var.github_repo_name
116 | branch = var.github_branch
117 | build_image = var.build_image
118 | build_compute_type = var.build_compute_type
119 | privileged_mode = true
120 | region = var.region
121 | aws_account_id = var.aws_account_id
122 | image_repo_name = module.ecr.repository_name
123 | image_tag = var.image_tag
124 | poll_source_changes = true
125 | force_destroy = var.cicd_bucket_force_destroy
126 |
127 | context = module.this.context
128 | }
129 |
130 | # Label for EC2 slaves
131 | module "label_slaves" {
132 | source = "cloudposse/label/null"
133 | version = "0.25.0"
134 | attributes = ["slaves"]
135 |
136 | context = module.this.context
137 | }
138 |
139 | # Security Group for EC2 slaves
140 | resource "aws_security_group" "slaves" {
141 | name = module.label_slaves.id
142 | description = "Security Group for Jenkins EC2 slaves"
143 | vpc_id = var.vpc_id
144 |
145 | # Allow the provided Security Groups to connect to Jenkins slave instances
146 | ingress {
147 | from_port = 0
148 | to_port = 0
149 | protocol = -1
150 | security_groups = var.associated_security_group_ids
151 | }
152 |
153 | # Allow Jenkins master instance to communicate with Jenkins slave instances on SSH port 22
154 | ingress {
155 | from_port = 22
156 | to_port = 22
157 | protocol = "tcp"
158 | security_groups = [module.elastic_beanstalk_environment.security_group_id]
159 | }
160 |
161 | egress {
162 | from_port = 0
163 | to_port = 0
164 | protocol = "-1"
165 | cidr_blocks = ["0.0.0.0/0"]
166 | }
167 |
168 | tags = module.label_slaves.tags
169 | }
170 |
171 | # Policy document with permissions to launch new EC2 instances
172 | # https://wiki.jenkins.io/display/JENKINS/Amazon+EC2+Plugin
173 | data "aws_iam_policy_document" "slaves" {
174 | statement {
175 | sid = "AllowLaunchingEC2Instances"
176 |
177 | actions = [
178 | "ec2:DescribeSpotInstanceRequests",
179 | "ec2:CancelSpotInstanceRequests",
180 | "ec2:GetConsoleOutput",
181 | "ec2:RequestSpotInstances",
182 | "ec2:RunInstances",
183 | "ec2:StartInstances",
184 | "ec2:StopInstances",
185 | "ec2:TerminateInstances",
186 | "ec2:CreateTags",
187 | "ec2:DeleteTags",
188 | "ec2:DescribeInstances",
189 | "ec2:DescribeKeyPairs",
190 | "ec2:DescribeRegions",
191 | "ec2:DescribeImages",
192 | "ec2:DescribeAvailabilityZones",
193 | "ec2:DescribeSecurityGroups",
194 | "ec2:DescribeSubnets",
195 | "iam:PassRole"
196 | ]
197 |
198 | resources = ["*"]
199 | effect = "Allow"
200 | }
201 | }
202 |
203 | # Policy for the EB EC2 instance profile to allow launching Jenkins slaves
204 | resource "aws_iam_policy" "slaves" {
205 | name = module.label_slaves.id
206 | path = "/"
207 | description = "Policy for EC2 instance profile to allow launching Jenkins slaves"
208 | policy = data.aws_iam_policy_document.slaves.json
209 | tags = module.label_slaves.tags
210 | }
211 |
212 | # Attach Policy to the EC2 instance profile to allow Jenkins master to launch and control slave EC2 instances
213 | resource "aws_iam_role_policy_attachment" "slaves" {
214 | role = module.elastic_beanstalk_environment.ec2_instance_profile_role_name
215 | policy_arn = aws_iam_policy.slaves.arn
216 | }
217 |
--------------------------------------------------------------------------------
/outputs.tf:
--------------------------------------------------------------------------------
1 | output "elastic_beanstalk_application_name" {
2 | value = module.elastic_beanstalk_application.elastic_beanstalk_application_name
3 | description = "Elastic Beanstalk Application name"
4 | }
5 |
6 | output "elastic_beanstalk_environment_hostname" {
7 | value = module.elastic_beanstalk_environment.hostname
8 | description = "DNS hostname"
9 | }
10 |
11 | output "elastic_beanstalk_environment_id" {
12 | description = "ID of the Elastic Beanstalk environment"
13 | value = module.elastic_beanstalk_environment.id
14 | }
15 |
16 | output "elastic_beanstalk_environment_name" {
17 | value = module.elastic_beanstalk_environment.name
18 | description = "Name"
19 | }
20 |
21 | output "elastic_beanstalk_environment_security_group_id" {
22 | value = module.elastic_beanstalk_environment.security_group_id
23 | description = "Security group id"
24 | }
25 |
26 | output "elastic_beanstalk_environment_elb_zone_id" {
27 | value = module.elastic_beanstalk_environment.elb_zone_id
28 | description = "ELB zone id"
29 | }
30 |
31 | output "elastic_beanstalk_environment_ec2_instance_profile_role_name" {
32 | value = module.elastic_beanstalk_environment.ec2_instance_profile_role_name
33 | description = "Instance IAM role name"
34 | }
35 |
36 | output "elastic_beanstalk_environment_tier" {
37 | description = "The environment tier"
38 | value = module.elastic_beanstalk_environment.tier
39 | }
40 |
41 | output "elastic_beanstalk_environment_application" {
42 | description = "The Elastic Beanstalk Application specified for this environment"
43 | value = module.elastic_beanstalk_environment.application
44 | }
45 |
46 | output "elastic_beanstalk_environment_setting" {
47 | description = "Settings specifically set for this environment"
48 | value = module.elastic_beanstalk_environment.setting
49 | }
50 |
51 | output "elastic_beanstalk_environment_all_settings" {
52 | description = "List of all option settings configured in the environment. These are a combination of default settings and their overrides from setting in the configuration"
53 | value = module.elastic_beanstalk_environment.all_settings
54 | }
55 |
56 | output "elastic_beanstalk_environment_endpoint" {
57 | description = "Fully qualified DNS name for the environment"
58 | value = module.elastic_beanstalk_environment.endpoint
59 | }
60 |
61 | output "elastic_beanstalk_environment_autoscaling_groups" {
62 | description = "The autoscaling groups used by this environment"
63 | value = module.elastic_beanstalk_environment.autoscaling_groups
64 | }
65 |
66 | output "elastic_beanstalk_environment_instances" {
67 | description = "Instances used by this environment"
68 | value = module.elastic_beanstalk_environment.instances
69 | }
70 |
71 | output "elastic_beanstalk_environment_launch_configurations" {
72 | description = "Launch configurations in use by this environment"
73 | value = module.elastic_beanstalk_environment.launch_configurations
74 | }
75 |
76 | output "elastic_beanstalk_environment_load_balancers" {
77 | description = "Elastic Load Balancers in use by this environment"
78 | value = module.elastic_beanstalk_environment.load_balancers
79 | }
80 |
81 | output "elastic_beanstalk_environment_queues" {
82 | description = "SQS queues in use by this environment"
83 | value = module.elastic_beanstalk_environment.queues
84 | }
85 |
86 | output "elastic_beanstalk_environment_triggers" {
87 | description = "Autoscaling triggers in use by this environment"
88 | value = module.elastic_beanstalk_environment.triggers
89 | }
90 |
91 | output "ecr_registry_id" {
92 | value = module.ecr.registry_id
93 | description = "Registry ID"
94 | }
95 |
96 | output "ecr_repository_url" {
97 | value = module.ecr.repository_url
98 | description = "Repository URL"
99 | }
100 |
101 | output "ecr_repository_name" {
102 | value = module.ecr.repository_name
103 | description = "Repository name"
104 | }
105 |
106 | output "efs_arn" {
107 | value = module.efs.arn
108 | description = "EFS ARN"
109 | }
110 |
111 | output "efs_id" {
112 | value = module.efs.id
113 | description = "EFS ID"
114 | }
115 |
116 | output "efs_host" {
117 | value = module.efs.host
118 | description = "Route53 DNS hostname for the EFS"
119 | }
120 |
121 | output "efs_dns_name" {
122 | value = module.efs.dns_name
123 | description = "EFS DNS name"
124 | }
125 |
126 | output "efs_mount_target_dns_names" {
127 | value = module.efs.mount_target_dns_names
128 | description = "List of EFS mount target DNS names"
129 | }
130 |
131 | output "efs_mount_target_ids" {
132 | value = module.efs.mount_target_ids
133 | description = "List of EFS mount target IDs (one per Availability Zone)"
134 | }
135 |
136 | output "efs_mount_target_ips" {
137 | value = module.efs.mount_target_ips
138 | description = "List of EFS mount target IPs (one per Availability Zone)"
139 | }
140 |
141 | output "efs_network_interface_ids" {
142 | value = module.efs.network_interface_ids
143 | description = "List of mount target network interface IDs"
144 | }
145 |
146 | output "codebuild_project_name" {
147 | description = "CodeBuild project name"
148 | value = module.cicd.codebuild_project_name
149 | }
150 |
151 | output "codebuild_project_id" {
152 | description = "CodeBuild project ID"
153 | value = module.cicd.codebuild_project_id
154 | }
155 |
156 | output "codebuild_role_id" {
157 | description = "CodeBuild IAM Role ID"
158 | value = module.cicd.codebuild_role_id
159 | }
160 |
161 | output "codebuild_role_arn" {
162 | description = "CodeBuild IAM Role ARN"
163 | value = module.cicd.codebuild_role_arn
164 | }
165 |
166 | output "codebuild_cache_bucket_name" {
167 | description = "CodeBuild cache S3 bucket name"
168 | value = module.cicd.codebuild_cache_bucket_name
169 | }
170 |
171 | output "codebuild_cache_bucket_arn" {
172 | description = "CodeBuild cache S3 bucket ARN"
173 | value = module.cicd.codebuild_cache_bucket_arn
174 | }
175 |
176 | output "codebuild_badge_url" {
177 | description = "The URL of the build badge when badge_enabled is enabled"
178 | value = module.cicd.codebuild_badge_url
179 | }
180 |
181 | output "codepipeline_id" {
182 | description = "CodePipeline ID"
183 | value = module.cicd.codepipeline_id
184 | }
185 |
186 | output "codepipeline_arn" {
187 | description = "CodePipeline ARN"
188 | value = module.cicd.codepipeline_arn
189 | }
190 |
191 | output "efs_backup_vault_id" {
192 | value = module.efs_backup.backup_vault_id
193 | description = "Backup Vault ID"
194 | }
195 |
196 | output "efs_backup_vault_arn" {
197 | value = module.efs_backup.backup_vault_arn
198 | description = "Backup Vault ARN"
199 | }
200 |
201 | output "efs_backup_plan_arn" {
202 | value = module.efs_backup.backup_plan_arn
203 | description = "Backup Plan ARN"
204 | }
205 |
206 | output "efs_backup_plan_version" {
207 | value = module.efs_backup.backup_plan_version
208 | description = "Unique, randomly generated, Unicode, UTF-8 encoded string that serves as the version ID of the backup plan"
209 | }
210 |
211 | output "efs_backup_selection_id" {
212 | value = module.efs_backup.backup_selection_id
213 | description = "Backup Selection ID"
214 | }
215 |
--------------------------------------------------------------------------------
/test/.gitignore:
--------------------------------------------------------------------------------
1 | .test-harness
--------------------------------------------------------------------------------
/test/Makefile:
--------------------------------------------------------------------------------
1 | TEST_HARNESS ?= https://github.com/cloudposse/test-harness.git
2 | TEST_HARNESS_BRANCH ?= master
3 | TEST_HARNESS_PATH = $(realpath .test-harness)
4 | BATS_ARGS ?= --tap
5 | BATS_LOG ?= test.log
6 |
7 | # Define a macro to run the tests
8 | define RUN_TESTS
9 | @echo "Running tests in $(1)"
10 | @cd $(1) && bats $(BATS_ARGS) $(addsuffix .bats,$(addprefix $(TEST_HARNESS_PATH)/test/terraform/,$(TESTS)))
11 | endef
12 |
13 | default: all
14 |
15 | -include Makefile.*
16 |
17 | ## Provision the test-harnesss
18 | .test-harness:
19 | [ -d $@ ] || git clone --depth=1 -b $(TEST_HARNESS_BRANCH) $(TEST_HARNESS) $@
20 |
21 | ## Initialize the tests
22 | init: .test-harness
23 |
24 | ## Install all dependencies (OS specific)
25 | deps::
26 | @exit 0
27 |
28 | ## Clean up the test harness
29 | clean:
30 | [ "$(TEST_HARNESS_PATH)" == "/" ] || rm -rf $(TEST_HARNESS_PATH)
31 |
32 | ## Run all tests
33 | all: module examples/complete
34 |
35 | ## Run basic sanity checks against the module itself
36 | module: export TESTS ?= installed lint get-modules module-pinning get-plugins provider-pinning validate terraform-docs input-descriptions output-descriptions
37 | module: deps
38 | $(call RUN_TESTS, ../)
39 |
40 | ## Run tests against example
41 | examples/complete: export TESTS ?= installed lint get-modules get-plugins validate
42 | examples/complete: deps
43 | $(call RUN_TESTS, ../$@)
44 |
--------------------------------------------------------------------------------
/test/Makefile.alpine:
--------------------------------------------------------------------------------
1 | ifneq (,$(wildcard /sbin/apk))
2 | ## Install all dependencies for alpine
3 | deps:: init
4 | @apk add --update terraform-docs@cloudposse json2hcl@cloudposse
5 | endif
6 |
--------------------------------------------------------------------------------
/test/src/.gitignore:
--------------------------------------------------------------------------------
1 | .gopath
2 | vendor/
--------------------------------------------------------------------------------
/test/src/Makefile:
--------------------------------------------------------------------------------
1 | export TF_CLI_ARGS_init ?= -get-plugins=true
2 | export TERRAFORM_VERSION ?= $(shell curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r -M '.current_version' | cut -d. -f1-2)
3 |
4 | .DEFAULT_GOAL : all
5 |
6 | .PHONY: all
7 | ## Default target
8 | all: test
9 |
10 | .PHONY : init
11 | ## Initialize tests
12 | init:
13 | @exit 0
14 |
15 | .PHONY : test
16 | ## Run tests
17 | test: init
18 | go mod download
19 | go test -v -timeout 60m -run TestExamplesComplete
20 |
21 | ## Run tests in docker container
22 | docker/test:
23 | docker run --name terratest --rm -it -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN -e GITHUB_TOKEN \
24 | -e PATH="/usr/local/terraform/$(TERRAFORM_VERSION)/bin:/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \
25 | -v $(CURDIR)/../../:/module/ cloudposse/test-harness:latest -C /module/test/src test
26 |
27 | .PHONY : clean
28 | ## Clean up files
29 | clean:
30 | rm -rf ../../examples/complete/*.tfstate*
--------------------------------------------------------------------------------
/test/src/examples_complete_test.go:
--------------------------------------------------------------------------------
1 | package test
2 |
3 | import (
4 | "strings"
5 | "testing"
6 |
7 | "github.com/gruntwork-io/terratest/modules/random"
8 | "github.com/gruntwork-io/terratest/modules/terraform"
9 | "github.com/stretchr/testify/assert"
10 | )
11 |
12 | // Test the Terraform module in examples/complete using Terratest.
13 | func TestExamplesComplete(t *testing.T) {
14 | t.Parallel()
15 | randID := strings.ToLower(random.UniqueId())
16 | attributes := []string{randID}
17 | varFiles := []string{"fixtures.us-east-2.tfvars"}
18 |
19 | terraformOptions := &terraform.Options{
20 | // The path to where our Terraform code is located
21 | TerraformDir: "../../examples/complete",
22 | Upgrade: true,
23 | // Variables to pass to our Terraform code using -var-file options
24 | VarFiles: varFiles,
25 | Vars: map[string]interface{}{
26 | "attributes": attributes,
27 | },
28 | }
29 |
30 | // At the end of the test, run `terraform destroy` to clean up any resources that were created
31 | defer terraform.Destroy(t, terraformOptions)
32 |
33 | // This will run `terraform init` and `terraform apply`
34 | _, err := terraform.InitAndApplyE(t, terraformOptions)
35 |
36 | /*
37 | We need to apply twice because of the current bug with `dynamic` blocks in terraform `aws` provider:
38 |
39 | Error: Provider produced inconsistent final plan
40 | When expanding the plan for
41 | module.jenkins.module.elastic_beanstalk_environment.aws_elastic_beanstalk_environment.default
42 | to include new values learned so far during apply, provider "aws" produced an
43 | invalid new value for .setting: block set length changed from 72 to 77.
44 | This is a bug in the provider, which should be reported in the provider's own issue tracker.
45 |
46 | https://github.com/terraform-providers/terraform-provider-aws/issues/10297
47 | https://github.com/terraform-providers/terraform-provider-aws/issues/7987
48 | https://github.com/hashicorp/terraform/issues/20517
49 | */
50 |
51 | if err != nil {
52 | terraform.Apply(t, terraformOptions)
53 | }
54 |
55 | // Run `terraform output` to get the value of an output variable
56 | vpcCidr := terraform.Output(t, terraformOptions, "vpc_cidr")
57 | // Verify we're getting back the outputs we expect
58 | assert.Equal(t, "172.16.0.0/16", vpcCidr)
59 |
60 | // Run `terraform output` to get the value of an output variable
61 | privateSubnetCidrs := terraform.OutputList(t, terraformOptions, "private_subnet_cidrs")
62 | // Verify we're getting back the outputs we expect
63 | assert.Equal(t, []string{"172.16.0.0/19", "172.16.32.0/19"}, privateSubnetCidrs)
64 |
65 | // Run `terraform output` to get the value of an output variable
66 | publicSubnetCidrs := terraform.OutputList(t, terraformOptions, "public_subnet_cidrs")
67 | // Verify we're getting back the outputs we expect
68 | assert.Equal(t, []string{"172.16.96.0/19", "172.16.128.0/19"}, publicSubnetCidrs)
69 |
70 | // Run `terraform output` to get the value of an output variable
71 | elasticBeanstalkApplicationName := terraform.Output(t, terraformOptions, "elastic_beanstalk_application_name")
72 | // Verify we're getting back the outputs we expect
73 | assert.Equal(t, "eg-test-jenkins-"+randID+"-app", elasticBeanstalkApplicationName)
74 |
75 | // Run `terraform output` to get the value of an output variable
76 | elasticBeanstalkEnvironmentName := terraform.Output(t, terraformOptions, "elastic_beanstalk_environment_name")
77 | // Verify we're getting back the outputs we expect
78 | assert.Equal(t, "eg-test-jenkins-"+randID+"-env", elasticBeanstalkEnvironmentName)
79 |
80 | // Run `terraform output` to get the value of an output variable
81 | elasticBeanstalkEnvironmentHostname := terraform.Output(t, terraformOptions, "elastic_beanstalk_environment_hostname")
82 | // Verify we're getting back the outputs we expect
83 | assert.Equal(t, "jenkins.testing.cloudposse.co", elasticBeanstalkEnvironmentHostname)
84 |
85 | // Run `terraform output` to get the value of an output variable
86 | ecrRepositoryName := terraform.Output(t, terraformOptions, "ecr_repository_name")
87 | // Verify we're getting back the outputs we expect
88 | assert.Equal(t, "eg-test-jenkins-"+randID, ecrRepositoryName)
89 |
90 | // Run `terraform output` to get the value of an output variable
91 | codebuildProjectName := terraform.Output(t, terraformOptions, "codebuild_project_name")
92 | // Verify we're getting back the outputs we expect
93 | assert.Equal(t, "eg-test-jenkins-"+randID+"-cicd-build", codebuildProjectName)
94 |
95 | // Run `terraform output` to get the value of an output variable
96 | codebuildCacheBucketName := terraform.Output(t, terraformOptions, "codebuild_cache_bucket_name")
97 | // Verify we're getting back the outputs we expect
98 | assert.Contains(t, codebuildCacheBucketName, "eg-test-jenkins-"+randID+"-cicd-build")
99 |
100 | // Run `terraform output` to get the value of an output variable
101 | codepipelineId := terraform.Output(t, terraformOptions, "codepipeline_id")
102 | // Verify we're getting back the outputs we expect
103 | assert.Equal(t, "eg-test-jenkins-"+randID+"-cicd", codepipelineId)
104 |
105 | // Run `terraform output` to get the value of an output variable
106 | efsArn := terraform.Output(t, terraformOptions, "efs_arn")
107 | // Verify we're getting back the outputs we expect
108 | assert.Contains(t, efsArn, "arn:aws:elasticfilesystem:us-east-2:126450723953:file-system")
109 |
110 | // Run `terraform output` to get the value of an output variable
111 | efsBackupPlanArn := terraform.Output(t, terraformOptions, "efs_backup_plan_arn")
112 | // Verify we're getting back the outputs we expect
113 | assert.Contains(t, efsBackupPlanArn, "arn:aws:backup:us-east-2:126450723953:backup-plan")
114 |
115 | // Run `terraform output` to get the value of an output variable
116 | efsBackupVaultArn := terraform.Output(t, terraformOptions, "efs_backup_vault_arn")
117 | // Verify we're getting back the outputs we expect
118 | assert.Equal(t, "arn:aws:backup:us-east-2:126450723953:backup-vault:eg-test-jenkins-"+randID+"-efs", efsBackupVaultArn)
119 |
120 | // Run `terraform output` to get the value of an output variable
121 | efsBackupVaultId := terraform.Output(t, terraformOptions, "efs_backup_vault_id")
122 | // Verify we're getting back the outputs we expect
123 | assert.Equal(t, "eg-test-jenkins-"+randID+"-efs", efsBackupVaultId)
124 | }
125 |
--------------------------------------------------------------------------------
/test/src/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/cloudposse/terraform-aws-jenkins
2 |
3 | go 1.17
4 |
5 | require (
6 | github.com/gruntwork-io/terratest v0.40.16
7 | github.com/stretchr/testify v1.7.0
8 | )
9 |
10 | require (
11 | cloud.google.com/go v0.83.0 // indirect
12 | cloud.google.com/go/storage v1.10.0 // indirect
13 | github.com/agext/levenshtein v1.2.3 // indirect
14 | github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
15 | github.com/aws/aws-sdk-go v1.40.56 // indirect
16 | github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
17 | github.com/davecgh/go-spew v1.1.1 // indirect
18 | github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
19 | github.com/golang/protobuf v1.5.2 // indirect
20 | github.com/golang/snappy v0.0.3 // indirect
21 | github.com/googleapis/gax-go/v2 v2.0.5 // indirect
22 | github.com/hashicorp/errwrap v1.0.0 // indirect
23 | github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
24 | github.com/hashicorp/go-getter v1.6.1 // indirect
25 | github.com/hashicorp/go-multierror v1.1.0 // indirect
26 | github.com/hashicorp/go-safetemp v1.0.0 // indirect
27 | github.com/hashicorp/go-version v1.3.0 // indirect
28 | github.com/hashicorp/hcl/v2 v2.9.1 // indirect
29 | github.com/hashicorp/terraform-json v0.13.0 // indirect
30 | github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a // indirect
31 | github.com/jmespath/go-jmespath v0.4.0 // indirect
32 | github.com/jstemmer/go-junit-report v0.9.1 // indirect
33 | github.com/klauspost/compress v1.13.0 // indirect
34 | github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326 // indirect
35 | github.com/mitchellh/go-homedir v1.1.0 // indirect
36 | github.com/mitchellh/go-testing-interface v1.0.0 // indirect
37 | github.com/mitchellh/go-wordwrap v1.0.1 // indirect
38 | github.com/pmezard/go-difflib v1.0.0 // indirect
39 | github.com/tmccombs/hcl2json v0.3.3 // indirect
40 | github.com/ulikunitz/xz v0.5.8 // indirect
41 | github.com/zclconf/go-cty v1.9.1 // indirect
42 | go.opencensus.io v0.23.0 // indirect
43 | golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect
44 | golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
45 | golang.org/x/mod v0.4.2 // indirect
46 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
47 | golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c // indirect
48 | golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e // indirect
49 | golang.org/x/text v0.3.6 // indirect
50 | golang.org/x/tools v0.1.2 // indirect
51 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
52 | google.golang.org/api v0.47.0 // indirect
53 | google.golang.org/appengine v1.6.7 // indirect
54 | google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect
55 | google.golang.org/grpc v1.38.0 // indirect
56 | google.golang.org/protobuf v1.26.0 // indirect
57 | gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
58 | )
59 |
--------------------------------------------------------------------------------
/variables.tf:
--------------------------------------------------------------------------------
1 | variable "region" {
2 | type = string
3 | description = "AWS region in which to provision the AWS resources"
4 | }
5 |
6 | variable "description" {
7 | type = string
8 | default = "Jenkins server as Docker container running on Elastic Benastalk"
9 | description = "Will be used as Elastic Beanstalk application description"
10 | }
11 |
12 | # https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html
13 | # https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.docker
14 | variable "solution_stack_name" {
15 | type = string
16 | default = "64bit Amazon Linux 2018.03 v2.12.17 running Docker 18.06.1-ce"
17 | description = "Elastic Beanstalk stack, e.g. Docker, Go, Node, Java, IIS. For more info: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/concepts.platforms.html"
18 | }
19 |
20 | variable "master_instance_type" {
21 | type = string
22 | default = "t2.medium"
23 | description = "EC2 instance type for Jenkins master, e.g. 't2.medium'"
24 | }
25 |
26 | variable "vpc_id" {
27 | type = string
28 | description = "ID of the VPC in which to provision the AWS resources"
29 | }
30 |
31 | variable "availability_zones" {
32 | type = list(string)
33 | description = "List of Availability Zones for EFS"
34 | }
35 |
36 | variable "healthcheck_url" {
37 | type = string
38 | default = "/login"
39 | description = "Application Health Check URL. Elastic Beanstalk will call this URL to check the health of the application running on EC2 instances"
40 | }
41 |
42 | variable "loadbalancer_type" {
43 | type = string
44 | default = "application"
45 | description = "Load Balancer type, e.g. 'application' or 'classic'"
46 | }
47 |
48 | variable "loadbalancer_certificate_arn" {
49 | type = string
50 | description = "Load Balancer SSL certificate ARN. The certificate must be present in AWS Certificate Manager"
51 | default = ""
52 | }
53 |
54 | variable "loadbalancer_ssl_policy" {
55 | type = string
56 | default = ""
57 | description = "Specify a security policy to apply to the listener. This option is only applicable to environments with an application load balancer"
58 | }
59 |
60 | variable "loadbalancer_subnets" {
61 | type = list(string)
62 | description = "List of subnets to place Elastic Load Balancer"
63 | }
64 |
65 | variable "application_subnets" {
66 | type = list(string)
67 | description = "List of subnets to place EC2 instances and EFS"
68 | }
69 |
70 | variable "dns_zone_id" {
71 | type = string
72 | description = "Route53 parent zone ID. The module will create sub-domain DNS records in the parent zone for the EB environment and EFS"
73 | }
74 |
75 | variable "associated_security_group_ids" {
76 | type = list(string)
77 | default = []
78 | description = "List of security groups to be allowed to connect to Jenkins master EC2 instances"
79 | }
80 |
81 | variable "ssh_key_pair" {
82 | type = string
83 | default = ""
84 | description = "Name of SSH key that will be deployed on Elastic Beanstalk instances. The key should be present in AWS"
85 | }
86 |
87 | variable "github_oauth_token" {
88 | type = string
89 | description = "GitHub Oauth Token"
90 | }
91 |
92 | variable "github_organization" {
93 | type = string
94 | default = "cloudposse"
95 | description = "GitHub organization, e.g. 'cloudposse'. By default, this module will deploy 'https://github.com/cloudposse/jenkins' repository"
96 | }
97 |
98 | variable "github_repo_name" {
99 | type = string
100 | default = "jenkins"
101 | description = "GitHub repository name, e.g. 'jenkins'. By default, this module will deploy 'https://github.com/cloudposse/jenkins' repository"
102 | }
103 |
104 | variable "github_branch" {
105 | type = string
106 | default = "master"
107 | description = "GitHub repository branch, e.g. 'master'. By default, this module will deploy 'https://github.com/cloudposse/jenkins' master branch"
108 | }
109 |
110 | # https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html
111 | variable "build_image" {
112 | type = string
113 | default = "aws/codebuild/docker:1.12.1"
114 | description = "CodeBuild build image, e.g. 'aws/codebuild/amazonlinux2-x86_64-standard:1.0'. For more info: https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-available.html"
115 | }
116 |
117 | # https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html
118 | variable "build_compute_type" {
119 | type = string
120 | default = "BUILD_GENERAL1_SMALL"
121 | description = "CodeBuild compute type, e.g. 'BUILD_GENERAL1_SMALL'. For more info: https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html"
122 | }
123 |
124 | variable "aws_account_id" {
125 | type = string
126 | description = "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"
127 | }
128 |
129 | variable "availability_zone_selector" {
130 | type = string
131 | default = "Any"
132 | description = "Availability Zone selector"
133 | }
134 |
135 | variable "environment_type" {
136 | type = string
137 | default = "LoadBalanced"
138 | description = "Environment type, e.g. 'LoadBalanced' or 'SingleInstance'. If setting to 'SingleInstance', `rolling_update_type` must be set to 'Time' or `Immutable`, and `loadbalancer_subnets` will be unused (it applies to the ELB, which does not exist in SingleInstance environments)"
139 | }
140 |
141 | # https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options-general.html#command-options-general-autoscalingupdatepolicyrollingupdate
142 | variable "rolling_update_type" {
143 | type = string
144 | default = "Health"
145 | description = "`Health`, `Time` or `Immutable`. Set it to `Immutable` to apply the configuration change to a fresh group of instances. For more details, see https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options-general.html#command-options-general-autoscalingupdatepolicyrollingupdate"
146 | }
147 |
148 | variable "image_tag" {
149 | type = string
150 | description = "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"
151 | default = "latest"
152 | }
153 |
154 | variable "env_vars" {
155 | type = map(string)
156 | default = {}
157 | description = "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' }"
158 | }
159 |
160 | variable "use_efs_ip_address" {
161 | type = bool
162 | default = false
163 | description = "If set to `true`, will provide the EFS IP address instead of DNS name to Jenkins as ENV var"
164 | }
165 |
166 | variable "efs_backup_schedule" {
167 | type = string
168 | description = "A CRON expression specifying when AWS Backup initiates a backup job"
169 | default = null
170 | }
171 |
172 | variable "efs_backup_start_window" {
173 | type = number
174 | description = "The amount of time in minutes before beginning a backup. Minimum value is 60 minutes"
175 | default = null
176 | }
177 |
178 | variable "efs_backup_completion_window" {
179 | type = number
180 | description = "The amount of time AWS Backup attempts a backup before canceling the job and returning an error. Must be at least 60 minutes greater than `start_window`"
181 | default = null
182 | }
183 |
184 | variable "efs_backup_cold_storage_after" {
185 | type = number
186 | description = "Specifies the number of days after creation that a recovery point is moved to cold storage"
187 | default = null
188 | }
189 |
190 | variable "efs_backup_delete_after" {
191 | type = number
192 | description = "Specifies the number of days after creation that a recovery point is deleted. Must be 90 days greater than `cold_storage_after`"
193 | default = null
194 | }
195 |
196 | variable "loadbalancer_logs_bucket_force_destroy" {
197 | type = bool
198 | default = false
199 | description = "Force destroy the S3 bucket for load balancer logs even if it's not empty"
200 | }
201 |
202 | variable "cicd_bucket_force_destroy" {
203 | type = bool
204 | default = false
205 | description = "Force destroy the CI/CD S3 bucket even if it's not empty"
206 | }
207 |
--------------------------------------------------------------------------------
/versions.tf:
--------------------------------------------------------------------------------
1 | terraform {
2 | required_version = ">= 0.14.0"
3 |
4 | required_providers {
5 | aws = {
6 | source = "hashicorp/aws"
7 | version = ">= 2.0"
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------