terradactyl 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/workflows/build-and-release.yml +58 -0
- data/.github/workflows/build-status.yml +26 -0
- data/.github/workflows/validate-pullrequest.yml +29 -0
- data/.gitignore +18 -0
- data/.rubocop.yml +18 -0
- data/CHANGELOG.md +244 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +8 -0
- data/README.md +325 -0
- data/Rakefile +61 -0
- data/examples/multi-tf-version/stacks/tfv11/example.tf +1 -0
- data/examples/multi-tf-version/stacks/tfv11/terradactyl.yaml +3 -0
- data/examples/multi-tf-version/stacks/tfv12/example.tf +1 -0
- data/examples/multi-tf-version/stacks/tfv12/terradactyl.yaml +3 -0
- data/examples/multi-tf-version/stacks/tfv13/example.tf +1 -0
- data/examples/multi-tf-version/stacks/tfv13/terradactyl.yaml +3 -0
- data/examples/multi-tf-version/terradactyl.yaml +3 -0
- data/examples/simple/stacks/demo/example.tf +1 -0
- data/examples/simple/terradactyl.yaml +1 -0
- data/exe/td +1 -0
- data/exe/terradactyl +11 -0
- data/lib/terradactyl.rb +23 -0
- data/lib/terradactyl/cli.rb +335 -0
- data/lib/terradactyl/commands.rb +161 -0
- data/lib/terradactyl/common.rb +85 -0
- data/lib/terradactyl/config.rb +167 -0
- data/lib/terradactyl/filters.rb +100 -0
- data/lib/terradactyl/stack.rb +127 -0
- data/lib/terradactyl/stacks.rb +90 -0
- data/lib/terradactyl/version.rb +5 -0
- data/terradactyl.gemspec +43 -0
- metadata +234 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d021330dd8abb5ec42bff25987aba0388ed7879364141a3597ad8c7df890633b
|
4
|
+
data.tar.gz: ec0e8a4c9d6716b43c49b96a163cefffefa7c616668f7bb4522df4b284ae3917
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 010b919b8f831b6ead77629ce1a94d6afbcc8a37ee5e6ec7c543474e79da0662a7a19144cb969e2b02ebeaa569486195155f4cbdae721b333e8dd0a4e9ffa41c
|
7
|
+
data.tar.gz: a9863ff1d88e0bdc8e7ccb897b54206dde56d8355f85f4bf07bbaf5c7326dcee1a480dc9f0502f20413afe95917f22ff11c4e2fed0c234530d73946b34d7653b
|
@@ -0,0 +1,58 @@
|
|
1
|
+
name: Build and Release
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
paths:
|
8
|
+
- lib/terradactyl/version.rb
|
9
|
+
|
10
|
+
# Using the Ruby teams https://github.com/ruby/setup-ruby, not the Github
|
11
|
+
# team's https://github.com/actions/setup-ruby
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
release:
|
15
|
+
env:
|
16
|
+
GEM_NAME: terradactyl
|
17
|
+
VERSION_FILE: lib/terradactyl/version.rb
|
18
|
+
CHANGELOG: CHANGELOG.md
|
19
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
20
|
+
GEM_HOST_API_KEY: ${{ secrets.VCILABS_GEM_HOST_API_KEY }}
|
21
|
+
runs-on: ubuntu-latest
|
22
|
+
steps:
|
23
|
+
- name: Checkout Code
|
24
|
+
uses: actions/checkout@v2
|
25
|
+
- name: Setup Ruby
|
26
|
+
uses: ruby/setup-ruby@v1
|
27
|
+
with:
|
28
|
+
ruby-version: '2.7'
|
29
|
+
bundler-cache: true
|
30
|
+
- name: Build Gem
|
31
|
+
id: build
|
32
|
+
run: |
|
33
|
+
RELEASE_VERSION=$(grep VERSION ${VERSION_FILE} | tr -d "VERSION= \'")
|
34
|
+
RELEASE_BODY_PATH=body.md
|
35
|
+
echo RELEASE_VERSION=${RELEASE_VERSION} >> $GITHUB_ENV
|
36
|
+
echo RELEASE_BODY_PATH=${RELEASE_BODY_PATH} >> $GITHUB_ENV
|
37
|
+
sed -ne "/## ${RELEASE_VERSION}.*/,/#/p" ${CHANGELOG} | sed -e '$d' > $RELEASE_BODY_PATH
|
38
|
+
gem build
|
39
|
+
- name: Create Release
|
40
|
+
id: release
|
41
|
+
uses: actions/create-release@v1
|
42
|
+
with:
|
43
|
+
tag_name: v${{ env.RELEASE_VERSION }}
|
44
|
+
release_name: v${{ env.RELEASE_VERSION }}
|
45
|
+
body_path: ${{ env.RELEASE_BODY_PATH }}
|
46
|
+
draft: false
|
47
|
+
prerelease: false
|
48
|
+
- name: Upload Asset
|
49
|
+
id: asset
|
50
|
+
uses: actions/upload-release-asset@v1
|
51
|
+
with:
|
52
|
+
upload_url: ${{ steps.release.outputs.upload_url }}
|
53
|
+
asset_path: ${{ env.GEM_NAME }}-${{ env.RELEASE_VERSION}}.gem
|
54
|
+
asset_name: ${{ env.GEM_NAME }}-${{ env.RELEASE_VERSION}}.gem
|
55
|
+
asset_content_type: application/x-tar
|
56
|
+
- name: Publish Gem
|
57
|
+
id: publish
|
58
|
+
run: gem push ${{ env.GEM_NAME }}-${{ env.RELEASE_VERSION}}.gem
|
@@ -0,0 +1,26 @@
|
|
1
|
+
name: Build Status
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
|
8
|
+
# Using the Ruby teams https://github.com/ruby/setup-ruby, not the Github
|
9
|
+
# team's https://github.com/actions/setup-ruby
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
validate:
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
steps:
|
15
|
+
- name: Git clone
|
16
|
+
uses: actions/checkout@v2
|
17
|
+
with:
|
18
|
+
fetch-depth: 2
|
19
|
+
- name: Setup Ruby
|
20
|
+
uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: '2.7'
|
23
|
+
bundler-cache: true
|
24
|
+
- name: Run tests
|
25
|
+
id: test
|
26
|
+
run: bundle exec rake spec
|
@@ -0,0 +1,29 @@
|
|
1
|
+
name: Validate Pull Request
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
paths:
|
6
|
+
- '**.rb'
|
7
|
+
|
8
|
+
# Using the Ruby teams https://github.com/ruby/setup-ruby, not the Github
|
9
|
+
# team's https://github.com/actions/setup-ruby
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
validate:
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
steps:
|
15
|
+
- name: Git clone
|
16
|
+
uses: actions/checkout@v2
|
17
|
+
with:
|
18
|
+
fetch-depth: 2
|
19
|
+
- name: Setup Ruby
|
20
|
+
uses: ruby/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: '2.7'
|
23
|
+
bundler-cache: true
|
24
|
+
- name: Run lint
|
25
|
+
id: lint
|
26
|
+
run: bundle exec rake lint
|
27
|
+
- name: Run tests
|
28
|
+
id: test
|
29
|
+
run: bundle exec rake spec
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.5
|
3
|
+
Documentation:
|
4
|
+
Enabled: false
|
5
|
+
Metrics/LineLength:
|
6
|
+
Max: 100
|
7
|
+
Metrics/MethodLength:
|
8
|
+
Max: 20
|
9
|
+
Metrics/CyclomaticComplexity:
|
10
|
+
Max: 10
|
11
|
+
Metrics/ClassLength:
|
12
|
+
Max: 115
|
13
|
+
Naming/UncommunicativeMethodParamName:
|
14
|
+
MinNameLength: 2
|
15
|
+
Style/IfUnlessModifier:
|
16
|
+
Enabled: false
|
17
|
+
Style/GuardClause:
|
18
|
+
Enabled: false
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,244 @@
|
|
1
|
+
# CHANGELOG
|
2
|
+
|
3
|
+
## 0.13.0 (2020-11-26)
|
4
|
+
|
5
|
+
NEW FEATURES:
|
6
|
+
|
7
|
+
* update Gem version string to match supported Terraform revision
|
8
|
+
* adds support for Terraform version 0.13.x
|
9
|
+
* adds implicit Terraform version management
|
10
|
+
- (i.e. pessimistic operator, ~> 0.12.1)
|
11
|
+
* adds `defaults` sub-command
|
12
|
+
|
13
|
+
BUG FIXES:
|
14
|
+
|
15
|
+
* remove poor and non-critical defaults
|
16
|
+
* add CHANGELOG, LICENSE
|
17
|
+
* update README and provide examples
|
18
|
+
* fix/refactor/re-org tests and
|
19
|
+
|
20
|
+
## 0.11.0 (2019-09-12)
|
21
|
+
|
22
|
+
NEW FEATURES:
|
23
|
+
|
24
|
+
* overhaul Terradactyl::Commands
|
25
|
+
- create dynamic Module mix-in for Stack
|
26
|
+
- ensure command revision module prepends Commands
|
27
|
+
* overhaul Stack#plan and related code to use new Terraform::PlanFile class
|
28
|
+
|
29
|
+
## 0.10.0 (2019-09-06)
|
30
|
+
|
31
|
+
NEW FEATURES:
|
32
|
+
|
33
|
+
* update to work with `terradactyl-terraform`, `0.3.1`
|
34
|
+
* trap SIGINT to quell stack dumps on ^C
|
35
|
+
* hyphenate meta-subcommands, like `clean-all`
|
36
|
+
* add CLI subcommands `validate` and `validate-all`
|
37
|
+
* modularize Terraform subcommands by revision
|
38
|
+
- add Terradactyl::Commands and revision sub-modules
|
39
|
+
- add spec tests for both major revs
|
40
|
+
* refactor method decoration routine
|
41
|
+
|
42
|
+
## 0.9.2 (2019-09-06)
|
43
|
+
|
44
|
+
BUG FIXES:
|
45
|
+
|
46
|
+
* update Filter classes
|
47
|
+
- ensure all git-related ops are performed on relative path
|
48
|
+
- conform the default class by giving it a `git_cmd`
|
49
|
+
* update Stack
|
50
|
+
- allow `decorate_cmds` to handle method args
|
51
|
+
- make `validate_stack_name` err msg more generic
|
52
|
+
* make Stacks target filter accessible via ivar
|
53
|
+
|
54
|
+
## 0.9.1 (2019-09-05)
|
55
|
+
|
56
|
+
BUG FIXES:
|
57
|
+
|
58
|
+
* add Stack#validation and Stack#checklist
|
59
|
+
* update Stack filter classes with names and descriptions
|
60
|
+
|
61
|
+
## 0.9.0 (2019-09-03)
|
62
|
+
|
63
|
+
NEW FEATURES:
|
64
|
+
|
65
|
+
* update to work with supporting gem (`terradactyl-terraform`, `0.3.0`)
|
66
|
+
- implement autoinstall (removed from supporting gem)
|
67
|
+
- fix some spec tests
|
68
|
+
* refactor `Stack` command methods; DRY code
|
69
|
+
* cleanup some Rubocop violations
|
70
|
+
|
71
|
+
## 0.8.1 (2019-07-26)
|
72
|
+
|
73
|
+
BUG FIXES:
|
74
|
+
|
75
|
+
* rename method `has_plan?` to `planned?`
|
76
|
+
* add method: `plan_file_obj`; refactor plan file related methods
|
77
|
+
* refactor `common` and `config`
|
78
|
+
- factor out early config loading for `String.disable_colorization`
|
79
|
+
- fixes load failure when requiring the gem
|
80
|
+
* fix & refactor `Stack` and `Stacks` validation
|
81
|
+
- fix bug when `td audit` is passed a stack path
|
82
|
+
- move the path to stack name conversion into `Stacks.validate`
|
83
|
+
|
84
|
+
## 0.8.0 (2019-07-19)
|
85
|
+
|
86
|
+
NEW FEATURES:
|
87
|
+
|
88
|
+
* jettison code that migrated to `terradactyl-terraform` gem
|
89
|
+
* make `terradactyl-terraform` a dependency
|
90
|
+
|
91
|
+
## 0.6.1 (2019-03-12)
|
92
|
+
|
93
|
+
BUG FIXES:
|
94
|
+
|
95
|
+
* we can't parse "JSON-like" templates because they contain bare tokens
|
96
|
+
* rescue `JSON::ParserError` on misidentified blobs in `TerraformPlan#normalize_line`
|
97
|
+
|
98
|
+
## 0.6.0 (2019-03-04)
|
99
|
+
|
100
|
+
NEW FEATURES:
|
101
|
+
|
102
|
+
* re-organize terraform related code into component files
|
103
|
+
* add Gemfile.lock to .gitignore
|
104
|
+
|
105
|
+
## 0.5.9 (2019-02-05)
|
106
|
+
|
107
|
+
NEW FEATURES:
|
108
|
+
|
109
|
+
* add report feature to `auditall`
|
110
|
+
|
111
|
+
## 0.5.8 (2019-02-04)
|
112
|
+
|
113
|
+
BUG FIXES:
|
114
|
+
|
115
|
+
* re-classify stacks that error as errors, not dirty
|
116
|
+
* only abort on errors, not dirty stacks
|
117
|
+
|
118
|
+
## 0.5.7 (2019-01-31)
|
119
|
+
|
120
|
+
BUG FIXES:
|
121
|
+
|
122
|
+
* mark stacks as `dirty` on error or changed
|
123
|
+
* remove early exits (abort); throw `:error` as required
|
124
|
+
* add `at_exit` handler to catch dirty/error stacks
|
125
|
+
* new feature: support relative path to stack (tab-complete friendly), example: `td quickplan global/my-stack`
|
126
|
+
* add validation routine to stack names; better error message
|
127
|
+
* fix documentation
|
128
|
+
|
129
|
+
## 0.5.6 (2019-01-18)
|
130
|
+
|
131
|
+
BUG FIXES:
|
132
|
+
|
133
|
+
* change bundler pin posture to `>=`
|
134
|
+
|
135
|
+
## 0.5.5 (2018-07-09)
|
136
|
+
|
137
|
+
BUG FIXES:
|
138
|
+
|
139
|
+
* cosmetic: replace bold markdown with h4 header; better viz in Slack
|
140
|
+
|
141
|
+
## 0.5.4 (2018-07-05)
|
142
|
+
|
143
|
+
BUG FIXES:
|
144
|
+
|
145
|
+
* fix erroneous audit reporting
|
146
|
+
|
147
|
+
## 0.5.3 (2018-07-05)
|
148
|
+
|
149
|
+
BUG FIXES:
|
150
|
+
|
151
|
+
* fix CLI#auditall, rescue individual abort from CLI#audit
|
152
|
+
* update README
|
153
|
+
|
154
|
+
## 0.5.2 (2018-07-04)
|
155
|
+
|
156
|
+
BUG FIXES:
|
157
|
+
|
158
|
+
* fix Stack#execute, full IO buffer bug
|
159
|
+
|
160
|
+
## 0.5.1 (2018-06-30)
|
161
|
+
|
162
|
+
BUG FIXES:
|
163
|
+
|
164
|
+
* add base_folder attribute to TerraformPlan class
|
165
|
+
* fix JSON normalization routine in TerraformPlan class
|
166
|
+
- was not handling lines that contained a mix of JSON blobs and regular Strings
|
167
|
+
- refine the regex to add plain string handling
|
168
|
+
|
169
|
+
## 0.5.0 (2018-06-24)
|
170
|
+
|
171
|
+
NEW FEATURES:
|
172
|
+
|
173
|
+
* abandon Rake tasks as an interface
|
174
|
+
* replace with Thor CLI
|
175
|
+
* add `quickplan[NAME]` meta-task, per `terraenv`
|
176
|
+
|
177
|
+
## 0.4.1 (2018-06-18)
|
178
|
+
|
179
|
+
BUG FIXES:
|
180
|
+
|
181
|
+
* don't abort on empty Stacks for terradactyl:smartplan, just warn
|
182
|
+
|
183
|
+
## 0.4.0 (2018-06-18)
|
184
|
+
|
185
|
+
NEW FEATURES:
|
186
|
+
|
187
|
+
* permit cub-commands to be individually configured
|
188
|
+
* make state locking a per-operation config
|
189
|
+
|
190
|
+
## 0.3.9 (2018-06-18)
|
191
|
+
|
192
|
+
BUG FIXES:
|
193
|
+
|
194
|
+
* do not lock state during an init operation
|
195
|
+
|
196
|
+
## 0.3.8 (2018-06-18)
|
197
|
+
|
198
|
+
BUG FIXES:
|
199
|
+
|
200
|
+
* fix JSON unescape operation
|
201
|
+
|
202
|
+
## 0.3.7 (2018-06-16)
|
203
|
+
|
204
|
+
BUG FIXES:
|
205
|
+
|
206
|
+
* fix condition inversion
|
207
|
+
|
208
|
+
## 0.3.6 (2018-06-16)
|
209
|
+
|
210
|
+
BUG FIXES:
|
211
|
+
|
212
|
+
* fix Git diff filters stack_name extrapolation
|
213
|
+
|
214
|
+
## 0.3.5 (2018-06-16)
|
215
|
+
|
216
|
+
NEW FEATURES:
|
217
|
+
|
218
|
+
* add plan filter: StackPlanFilterDiffOriginBranch
|
219
|
+
* use new filter in PR planning operations
|
220
|
+
|
221
|
+
## 0.3.4 (2018-06-16)
|
222
|
+
|
223
|
+
BUG FIXES:
|
224
|
+
|
225
|
+
* fix missing dependency
|
226
|
+
* flag plan object as modified when there are changes
|
227
|
+
|
228
|
+
## 0.3.3 (2018-06-15)
|
229
|
+
|
230
|
+
BUG FIXES:
|
231
|
+
|
232
|
+
* do not lock state during a plan operation
|
233
|
+
|
234
|
+
## 0.3.2 (2018-06-14)
|
235
|
+
|
236
|
+
BUG FIXES:
|
237
|
+
|
238
|
+
* add JSON normalization routine to TerraformPlan class that will hopefully prevent checksum drift from plan to plan
|
239
|
+
|
240
|
+
## 0.3.1 (2018-06-12)
|
241
|
+
|
242
|
+
BUG FIXES:
|
243
|
+
|
244
|
+
* fix missing summary condition
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
Copyright (c) 2020 Alida, (Vision Critical Communications Inc.)
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
|
+
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
7
|
+
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,325 @@
|
|
1
|
+
# Terradactyl
|
2
|
+
|
3
|
+
[](https://badge.fury.io/rb/terradactyl)
|
4
|
+

|
5
|
+
|
6
|
+
CLI tooling for managing a Terraform monorepo.
|
7
|
+
|
8
|
+
## Overview
|
9
|
+
|
10
|
+
Terradactyl simplifies managing large heterogeneous Terraform monorepos by introducing hierarchical configuration and automatic management of Terraform versions on a per-stack basis.
|
11
|
+
|
12
|
+
## Features
|
13
|
+
|
14
|
+
* hierarchical configuration
|
15
|
+
* automatic Terraform binary installation
|
16
|
+
* "meta-commands" for consistent CI and development workflows
|
17
|
+
|
18
|
+
## Requirements
|
19
|
+
|
20
|
+
Requires Ruby 2.5 or greater.
|
21
|
+
|
22
|
+
NOTE: Terraform sub-command operations are only supported between stable versions `~> 0.11.x` and `~> 0.13.x`.
|
23
|
+
|
24
|
+
## Installation
|
25
|
+
|
26
|
+
### Bundler
|
27
|
+
|
28
|
+
Add this line to your application's Gemfile ...
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
gem 'terradactyl'
|
32
|
+
```
|
33
|
+
|
34
|
+
And then execute:
|
35
|
+
|
36
|
+
$ bundle install
|
37
|
+
|
38
|
+
### Manual
|
39
|
+
|
40
|
+
$ gem install terradactyl
|
41
|
+
|
42
|
+
## Quick Setup
|
43
|
+
|
44
|
+
Terradactyl repos rely on two simple organizational conventions:
|
45
|
+
|
46
|
+
* a single project-level `terradactly.yaml`
|
47
|
+
* a single subdirectory for your stacks
|
48
|
+
|
49
|
+
```sh
|
50
|
+
.
|
51
|
+
├── stacks
|
52
|
+
│ └── demo
|
53
|
+
│ └── example.tf
|
54
|
+
└── terradactyl.yaml
|
55
|
+
```
|
56
|
+
|
57
|
+
That's it! In fact, if you use the default subdirectory name of `stacks`, all your configuration file need contain is:
|
58
|
+
|
59
|
+
```yaml
|
60
|
+
terradactyl:
|
61
|
+
```
|
62
|
+
|
63
|
+
All other configuration, including `autoinstall` (default: `true`) are optional.
|
64
|
+
|
65
|
+
When your config file and `base_folder` are setup, try executing:
|
66
|
+
|
67
|
+
`terradactyl stacks` OR `td stacks`
|
68
|
+
|
69
|
+
See [examples](examples) for different setups.
|
70
|
+
|
71
|
+
## Quick Tutorial
|
72
|
+
|
73
|
+
##### NOTE: this will require an active internet connection so that the various Terraform binaries for each individual stack may be fetched and installed in the background.
|
74
|
+
|
75
|
+
#### set your working directory
|
76
|
+
|
77
|
+
$ cd examples/multi-tf-stacks
|
78
|
+
|
79
|
+
#### execute terradactyl
|
80
|
+
|
81
|
+
The Terradactyl CLI is installed with a symlink so it may be called by its full name or its shortened name, `td`:
|
82
|
+
|
83
|
+
$ terradactyl help
|
84
|
+
$ td help
|
85
|
+
|
86
|
+
#### quickplan a single stack
|
87
|
+
|
88
|
+
You can specify the relative path to the stack OR the just the stack name. These two commands are equivalent:
|
89
|
+
|
90
|
+
$ terradactyl quickplan tfv11
|
91
|
+
$ terradactyl quickplan stacks/tfv11
|
92
|
+
|
93
|
+
#### apply a single stack
|
94
|
+
|
95
|
+
$ terradactyl apply stacks/tfv11
|
96
|
+
|
97
|
+
#### audit and report
|
98
|
+
|
99
|
+
$ terradactyl audit-all --report
|
100
|
+
|
101
|
+
When complete, you should have a JSON report that you can pass to other processes.
|
102
|
+
|
103
|
+
$ cat stacks.audit.json
|
104
|
+
|
105
|
+
#### quickplan ALL stacks
|
106
|
+
|
107
|
+
$ terradactyl plan-all
|
108
|
+
|
109
|
+
#### apply ANY stacks that have a plan file
|
110
|
+
|
111
|
+
$ terradactyl smartapply
|
112
|
+
|
113
|
+
#### clean all the stacks
|
114
|
+
|
115
|
+
$ terradactyl clean-all
|
116
|
+
|
117
|
+
NOTE: `*.tfstate*` files are not cleaned up by default for obvious reasons, so clean them up manually:
|
118
|
+
|
119
|
+
`git clean -fD` OR `find . -name "*.tfstate*" --delete`
|
120
|
+
|
121
|
+
See the [Configuration](#configuration) section for more info on how to control which files get removed during a `clean <stack>` or `clean-all` operation.
|
122
|
+
|
123
|
+
## Operation
|
124
|
+
|
125
|
+
NOTE: `terradactyl` (symlinked as `td`) ONLY operates in the root of your monorepo. In order to execute any sub-commands, your working directory must contain your project-level configuration file, otherwise you will receive this:
|
126
|
+
|
127
|
+
FATAL: Could not load project file: `terradactyl.yaml`, No such file or directory @ rb_sysopen - terradactyl.yaml
|
128
|
+
|
129
|
+
### General
|
130
|
+
|
131
|
+
Generally speaking, Terradactyl operates on the principle of **plan file** (`*.tfout`) generation. This can be reduced to the following tenets:
|
132
|
+
|
133
|
+
1. You _MUST_ perform a `plan` operation on a stack before an `apply`
|
134
|
+
2. You _CANNOT_ `apply` a stack that does not contain a plan file
|
135
|
+
|
136
|
+
In some cases, this might seem onerous, but it pays dividends in team workflow and CI/CD contexts.
|
137
|
+
|
138
|
+
### Supported sub-commands
|
139
|
+
|
140
|
+
Terradactyl was created to facilitate the using Terraform in a CI environment. As such, some of the more exotic ad hoc user-focused sub-commands have not received any effort in integration. The following is a list of the supported Terraform sub-commands:
|
141
|
+
|
142
|
+
* apply
|
143
|
+
* destroy
|
144
|
+
* fmt
|
145
|
+
* init
|
146
|
+
* plan
|
147
|
+
* refresh
|
148
|
+
* validate
|
149
|
+
|
150
|
+
### Meta-commands
|
151
|
+
|
152
|
+
Terradactyl provides a few useful meta-commands that can help you avoid repetitive multi-phase Terraform operations. Here are a few ...
|
153
|
+
|
154
|
+
#### quickplan
|
155
|
+
|
156
|
+
Clean, initialize and plan a single stack in one operation.
|
157
|
+
|
158
|
+
terradactly quickplan <stack>
|
159
|
+
|
160
|
+
#### smartapply/smartrefresh
|
161
|
+
|
162
|
+
Apply or Refresh _ANY_ stack containing a plan file.
|
163
|
+
|
164
|
+
terradactly smartapply <stack>
|
165
|
+
terradactly smartrefresh <stack>
|
166
|
+
|
167
|
+
### Getting Help
|
168
|
+
|
169
|
+
For a list of available sub-commands do:
|
170
|
+
|
171
|
+
$ terradactyl help
|
172
|
+
|
173
|
+
For help on any individual sub-command do:
|
174
|
+
|
175
|
+
$ terradactyl help <sub-command>
|
176
|
+
|
177
|
+
## Configuration
|
178
|
+
|
179
|
+
As previously mentioned, configuration is hierarchical. This means you may specify:
|
180
|
+
|
181
|
+
* one project-level configuration for ALL stacks
|
182
|
+
* an overriding stack-level configuration for each independent stack
|
183
|
+
|
184
|
+
See [examples](examples) for different setups.
|
185
|
+
|
186
|
+
##### NOTE: all project-level configurations are valid at the stack level except `base_folder` which is ignored.
|
187
|
+
|
188
|
+
You can dump the compiled configuration for your project using the `defaults` sub-command:
|
189
|
+
|
190
|
+
terradactyl defaults
|
191
|
+
td defaults
|
192
|
+
|
193
|
+
### Descriptions
|
194
|
+
|
195
|
+
```yaml
|
196
|
+
terradactyl: <Object, Terradactyl config>
|
197
|
+
base_folder: <String, the sub-directory for all your Terraform stacks, default=stacks>
|
198
|
+
terraform: <Object, configuration to Terraform sub-commands and binaries>
|
199
|
+
binary: <String, path to the Terraform binary you wish to use, default=nil>
|
200
|
+
version: <String, explicit or implict Terraform version, default=nil>
|
201
|
+
autoinstall: <Bool, perform automatic Terraform installations, default=true>
|
202
|
+
install_dir: <String, path to Terraform installations, default=$HOME/bin>
|
203
|
+
echo: <Bool, print currently executing terraform command, default=false>
|
204
|
+
quiet: <Bool, suppress currently executing terraform stdout, default=true>
|
205
|
+
init: <Object, CLI options to sub-command init>
|
206
|
+
lock: <Bool, lock the state file when locking is supported, default=false>
|
207
|
+
force_copy: <Bool, suppress prompts about copying state data, default=true>
|
208
|
+
plan: <Object, CLI options to sub-command plan>
|
209
|
+
lock: <Bool, lock the state file when locking is supported, default=false>
|
210
|
+
parallelism: <Int, limit the number of concurrent operations, default=5>
|
211
|
+
detailed_exitcode: <Bool, lock the state file when locking is supported, default=true>
|
212
|
+
apply: <Object, CLI options to sub-command apply>
|
213
|
+
parallelism: <Int, limit the number of concurrent operations, default=5>
|
214
|
+
refresh: <Object, CLI options to sub-command refresh>
|
215
|
+
input: <Bool, ask for input for variables if not directly set, default=false>
|
216
|
+
destroy: <Object, CLI options to sub-command destroy>
|
217
|
+
parallelism: <Int, limit the number of concurrent operations, default=5>
|
218
|
+
force: <Bool, skip interactive approval before destroying, default=true>
|
219
|
+
environment: <Object, shell environment variables>
|
220
|
+
TF_PLUGIN_CACHE_DIR: <String, path to common Terraform plugin directory, default=$HOME/.terraform.d/plugins>
|
221
|
+
misc: <Object, misc Terradactyl settings>
|
222
|
+
utf8: <Bool, use utf8 in stdout, default=true>
|
223
|
+
disable_color: <Bool, disable color in stdout, default=false>
|
224
|
+
cleanup: <Object, Terradactyl cleanup settings>
|
225
|
+
empty: <Bool, remove empty directories, default=true>
|
226
|
+
match: <Array, list of shell globs to match, default=["*.tfout", "*.tflock", "*.zip", ".terraform"]>
|
227
|
+
```
|
228
|
+
|
229
|
+
### Terraform sub-command arguments
|
230
|
+
|
231
|
+
Note that the config above contains config for Terraform sub-commands. for example:
|
232
|
+
|
233
|
+
```yaml
|
234
|
+
terradactyl:
|
235
|
+
terraform:
|
236
|
+
plan:
|
237
|
+
lock: false
|
238
|
+
parallelism: 5
|
239
|
+
detailed_exitcode: true
|
240
|
+
```
|
241
|
+
|
242
|
+
Each of the keys in the `plan` object correspond to an argument passed to the `terraform` binary. For example, the config above would equate to ...
|
243
|
+
|
244
|
+
terraform -lock=false -parallelism=5 -detailed-exitcode
|
245
|
+
|
246
|
+
There are two conventions to keep in mind when configuring sub-commands:
|
247
|
+
|
248
|
+
1. any sub-command option which toggles behaviour (i.e. `-detailed-exitcode`) requires a specific Boolean value of `true` OR `false`
|
249
|
+
2. any sub-command option that is hyphenated (i.e. `-detailed-exitcode`) is set in the config using an **underscore** (i.e `detailed_exitcode`)
|
250
|
+
|
251
|
+
If you need to tweak or augment any of the default arguments passed to any of the supported Terraform sub-commands, you can do so by adding them to the config.
|
252
|
+
|
253
|
+
Example:
|
254
|
+
|
255
|
+
```yaml
|
256
|
+
terradactyl:
|
257
|
+
terraform:
|
258
|
+
refresh:
|
259
|
+
lock: false
|
260
|
+
backup: /tmp/tfbackup
|
261
|
+
```
|
262
|
+
|
263
|
+
In addition, you can override the `echo` and `quiet` settings for any of the Terraform sub-commands:
|
264
|
+
|
265
|
+
```yaml
|
266
|
+
terradactyl:
|
267
|
+
terraform:
|
268
|
+
echo: false
|
269
|
+
quiet: true
|
270
|
+
apply:
|
271
|
+
echo: true
|
272
|
+
quiet: false
|
273
|
+
destroy:
|
274
|
+
echo: true
|
275
|
+
quiet: false
|
276
|
+
```
|
277
|
+
|
278
|
+
This can assist in debugging.
|
279
|
+
|
280
|
+
### Terraform version management
|
281
|
+
|
282
|
+
#### Explicit versions
|
283
|
+
|
284
|
+
By default, Terradactyl will always use the **latest** stable version of Terraform. If you do not specify a version, you will always get the latest stable version of Terraform available.
|
285
|
+
|
286
|
+
But, as part of Terradactyl's configuration, you can specify a **project** Terraform version, making it the default for _your_ monorepo:
|
287
|
+
|
288
|
+
```yaml
|
289
|
+
terradactyl:
|
290
|
+
terraform:
|
291
|
+
version: 0.12.29
|
292
|
+
```
|
293
|
+
|
294
|
+
Still, because Terradactyl's configuration is hierarchic, in addition the default version you specify at the project level, **each stack** may also specify a different version of Terraform.
|
295
|
+
|
296
|
+
See [examples/multi-tf-version](examples/multi-tf-version) for this setup.
|
297
|
+
|
298
|
+
#### Implicit versions
|
299
|
+
|
300
|
+
Also, there is no need to pin a project or a stack to an explicit version. Instead, you can use a pessimistic operator to ensure you always have the most up-to-date version of a minor Terraform revision.
|
301
|
+
|
302
|
+
Example:
|
303
|
+
|
304
|
+
```yaml
|
305
|
+
terradactyl:
|
306
|
+
terraform:
|
307
|
+
version: ~> 0.13.5
|
308
|
+
```
|
309
|
+
|
310
|
+
That way, when the next Terraform `0.13` is released, you can begin using it immediately, but you will never have to worry about upgrading to `0.14` unsuspectingly.
|
311
|
+
|
312
|
+
In fact, there are a number of ways to express implicit versions ...
|
313
|
+
|
314
|
+
~> 0.11.14
|
315
|
+
~> 0.11
|
316
|
+
>= 0.12
|
317
|
+
< 0.12
|
318
|
+
|
319
|
+
## Contributing
|
320
|
+
|
321
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/vcilabs/terradactyl.
|
322
|
+
|
323
|
+
## License
|
324
|
+
|
325
|
+
This code is released under the MIT License. See [LICENSE.txt](LICENSE.txt).
|