ruby-terraform 0.65.0.pre.12 → 1.0.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 +4 -4
- data/Gemfile.lock +23 -17
- data/README.md +148 -414
- data/Rakefile +25 -0
- data/lib/ruby_terraform.rb +1365 -41
- data/lib/ruby_terraform/commands.rb +0 -2
- data/lib/ruby_terraform/commands/apply.rb +78 -4
- data/lib/ruby_terraform/commands/base.rb +13 -2
- data/lib/ruby_terraform/commands/destroy.rb +71 -4
- data/lib/ruby_terraform/commands/force_unlock.rb +33 -3
- data/lib/ruby_terraform/commands/format.rb +45 -2
- data/lib/ruby_terraform/commands/get.rb +35 -2
- data/lib/ruby_terraform/commands/graph.rb +48 -2
- data/lib/ruby_terraform/commands/import.rb +98 -3
- data/lib/ruby_terraform/commands/init.rb +84 -3
- data/lib/ruby_terraform/commands/login.rb +26 -2
- data/lib/ruby_terraform/commands/logout.rb +23 -2
- data/lib/ruby_terraform/commands/output.rb +34 -2
- data/lib/ruby_terraform/commands/plan.rb +72 -3
- data/lib/ruby_terraform/commands/providers.rb +30 -2
- data/lib/ruby_terraform/commands/providers_lock.rb +72 -3
- data/lib/ruby_terraform/commands/providers_mirror.rb +44 -2
- data/lib/ruby_terraform/commands/providers_schema.rb +21 -2
- data/lib/ruby_terraform/commands/refresh.rb +70 -3
- data/lib/ruby_terraform/commands/show.rb +26 -3
- data/lib/ruby_terraform/commands/state_list.rb +54 -3
- data/lib/ruby_terraform/commands/state_move.rb +64 -6
- data/lib/ruby_terraform/commands/state_pull.rb +24 -2
- data/lib/ruby_terraform/commands/state_push.rb +49 -3
- data/lib/ruby_terraform/commands/state_remove.rb +55 -7
- data/lib/ruby_terraform/commands/state_replace_provider.rb +39 -6
- data/lib/ruby_terraform/commands/state_show.rb +26 -2
- data/lib/ruby_terraform/commands/taint.rb +63 -2
- data/lib/ruby_terraform/commands/untaint.rb +55 -2
- data/lib/ruby_terraform/commands/validate.rb +51 -6
- data/lib/ruby_terraform/commands/workspace_delete.rb +29 -7
- data/lib/ruby_terraform/commands/workspace_list.rb +21 -6
- data/lib/ruby_terraform/commands/workspace_new.rb +28 -7
- data/lib/ruby_terraform/commands/workspace_select.rb +23 -7
- data/lib/ruby_terraform/commands/workspace_show.rb +17 -2
- data/lib/ruby_terraform/options.rb +1 -1
- data/lib/ruby_terraform/options/definition.rb +6 -2
- data/lib/ruby_terraform/options/definitions.rb +12 -3
- data/lib/ruby_terraform/options/{common.rb → global.rb} +2 -1
- data/lib/ruby_terraform/options/types.rb +0 -1
- data/lib/ruby_terraform/options/types/flag.rb +8 -4
- data/lib/ruby_terraform/options/types/standard.rb +20 -6
- data/lib/ruby_terraform/version.rb +1 -1
- data/ruby_terraform.gemspec +3 -2
- metadata +25 -14
- data/lib/ruby_terraform/commands/clean.rb +0 -26
- data/lib/ruby_terraform/commands/remote_config.rb +0 -25
- data/lib/ruby_terraform/options/types/base.rb +0 -19
data/Rakefile
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'yaml'
|
4
|
+
require 'yard'
|
4
5
|
require 'rake_circle_ci'
|
5
6
|
require 'rake_github'
|
6
7
|
require 'rake_ssh'
|
@@ -46,6 +47,11 @@ end
|
|
46
47
|
|
47
48
|
RuboCop::RakeTask.new
|
48
49
|
|
50
|
+
YARD::Rake::YardocTask.new do |t|
|
51
|
+
t.files = ['lib/**/*.rb']
|
52
|
+
t.options = ['--embed-mixins', '--output-dir', 'docs']
|
53
|
+
end
|
54
|
+
|
49
55
|
namespace :library do
|
50
56
|
desc 'Run all checks of the library'
|
51
57
|
task check: [:rubocop]
|
@@ -54,6 +60,25 @@ namespace :library do
|
|
54
60
|
task fix: [:'rubocop:auto_correct']
|
55
61
|
end
|
56
62
|
|
63
|
+
namespace :documentation do
|
64
|
+
desc 'Generate documentation'
|
65
|
+
task generate: [:yard]
|
66
|
+
|
67
|
+
desc 'Commit documentation'
|
68
|
+
task :commit, [:skip] do |_, args|
|
69
|
+
args.with_defaults(skip: 'true')
|
70
|
+
|
71
|
+
skip_ci = args.skip == 'true'
|
72
|
+
|
73
|
+
sh('git', 'commit',
|
74
|
+
'-a',
|
75
|
+
'-m', "Generate latest documentation#{skip_ci ? ' [ci skip]' : ''}")
|
76
|
+
end
|
77
|
+
|
78
|
+
desc 'Update documentation'
|
79
|
+
task update: %i[generate commit]
|
80
|
+
end
|
81
|
+
|
57
82
|
namespace :test do
|
58
83
|
RSpec::Core::RakeTask.new(:unit)
|
59
84
|
end
|
data/lib/ruby_terraform.rb
CHANGED
@@ -23,50 +23,1369 @@ module RubyTerraform
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
# rubocop:disable Metrics/ModuleLength
|
27
|
+
|
26
28
|
module ClassMethods
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
29
|
+
# Invokes the +terraform apply+ command which creates or updates
|
30
|
+
# infrastructure according to terraform configuration files in the provided
|
31
|
+
# directory.
|
32
|
+
#
|
33
|
+
# By default, terraform will generate a new plan and present it for approval
|
34
|
+
# before taking any action. Alternatively, the command accepts a plan file
|
35
|
+
# created by a previous invocation, in which case terraform will take the
|
36
|
+
# actions described in that plan without any confirmation prompt.
|
37
|
+
#
|
38
|
+
# @param parameters The parameters used to invoke the command
|
39
|
+
# @option parameters [String] :directory The path to a directory containing
|
40
|
+
# terraform configuration (deprecated in terraform 0.14, removed in
|
41
|
+
# terraform 0.15, use +:chdir+ instead).
|
42
|
+
# @option parameters [String] :plan The path to a pre-computed plan to be
|
43
|
+
# applied.
|
44
|
+
# @option parameters [String] :chdir The path of a working directory to
|
45
|
+
# switch to before executing the given subcommand.
|
46
|
+
# @option parameters [Boolean] :auto_approve (false) If +true+, skips
|
47
|
+
# interactive approval of the generated plan before applying.
|
48
|
+
# @option parameters [String] :backup The path to backup the existing state
|
49
|
+
# file before modifying; defaults to the +:state_out+ path with
|
50
|
+
# +".backup"+ extension; set +:no_backup+ to +true+ to skip backups
|
51
|
+
# entirely.
|
52
|
+
# @option parameters [Boolean] :compact_warnings (false) When +true+, if
|
53
|
+
# terraform produces any warnings that are not accompanied by errors,
|
54
|
+
# they are shown in a more compact form that includes only the summary
|
55
|
+
# messages.
|
56
|
+
# @option parameters [Boolean] :input (true) When +false+, will not ask for
|
57
|
+
# input for variables not directly set.
|
58
|
+
# @option parameters [Boolean] :lock (true) When +true+, locks the state
|
59
|
+
# file when locking is supported; when +false+, does not lock the state
|
60
|
+
# file.
|
61
|
+
# @option parameters [String] :lock_timeout ("0s") The duration to retry a
|
62
|
+
# state lock.
|
63
|
+
# @option parameters [Boolean] :no_backup (false) When +true+, no backup
|
64
|
+
# file will be written.
|
65
|
+
# @option parameters [Boolean] :no_color (false) Whether or not the output
|
66
|
+
# from the command should be in color.
|
67
|
+
# @option parameters [Integer] :parallelism (10) The number of parallel
|
68
|
+
# resource operations.
|
69
|
+
# @option parameters [Boolean] :refresh (true) When +true+, updates state
|
70
|
+
# prior to checking for differences; when +false+ uses locally available
|
71
|
+
# state; this has no effect when +:plan+ is provided.
|
72
|
+
# @option parameters [String] :state ("terraform.tfstate") The path to the
|
73
|
+
# state file from which to read state and in which to store state (unless
|
74
|
+
# +:state_out+ is specified).
|
75
|
+
# @option parameters [String] :state_out The path to write state to that is
|
76
|
+
# different than +:state+; this can be used to preserve the old state.
|
77
|
+
# @option parameters [String] :target The address of a resource to target;
|
78
|
+
# if both +:target+ and +:targets+ are provided, all targets will be
|
79
|
+
# passed to terraform.
|
80
|
+
# @option parameters [Array<String>] :targets An array of resource addresses
|
81
|
+
# to target; if both +:target+ and +:targets+ are provided, all targets
|
82
|
+
# will be passed to terraform.
|
83
|
+
# @option parameters [Hash<String, Object>] :vars A map of variables to be
|
84
|
+
# passed to the terraform configuration.
|
85
|
+
# @option parameters [String] :var_file The path to a terraform var file;
|
86
|
+
# if both +:var_file+ and +:var_files+ are provided, all var files will be
|
87
|
+
# passed to terraform.
|
88
|
+
# @option parameters [Array<String>] :var_files An array of paths to
|
89
|
+
# terraform var files; if both +:var_file+ and +:var_files+ are provided,
|
90
|
+
# all var files will be passed to terraform.
|
91
|
+
#
|
92
|
+
# @example Basic Invocation
|
93
|
+
# RubyTerraform.apply(
|
94
|
+
# directory: 'infra/networking',
|
95
|
+
# vars: {
|
96
|
+
# region: 'eu-central'
|
97
|
+
# })
|
98
|
+
#
|
99
|
+
def apply(parameters = {})
|
100
|
+
exec(RubyTerraform::Commands::Apply, parameters)
|
101
|
+
end
|
102
|
+
|
103
|
+
# Invokes the +terraform destroy+ command which destroys terraform managed
|
104
|
+
# infrastructure.
|
105
|
+
#
|
106
|
+
# @param parameters The parameters used to invoke the command
|
107
|
+
# @option parameters [String] :directory The path to a directory containing
|
108
|
+
# terraform configuration (deprecated in terraform 0.14, removed in
|
109
|
+
# terraform 0.15, use +:chdir+ instead).
|
110
|
+
# @option parameters [String] :chdir The path of a working directory to
|
111
|
+
# switch to before executing the given subcommand.
|
112
|
+
# @option parameters [Boolean] :auto_approve (false) If +true+, skips
|
113
|
+
# interactive approval before destroying.
|
114
|
+
# @option parameters [String] :backup The path to backup the existing state
|
115
|
+
# file before modifying; defaults to the +:state_out+ path with
|
116
|
+
# +".backup"+ extension; set +:no_backup+ to +true+ to skip backups
|
117
|
+
# entirely (legacy).
|
118
|
+
# @option parameters [Boolean] :compact_warnings (false) When +true+, if
|
119
|
+
# terraform produces any warnings that are not accompanied by errors,
|
120
|
+
# they are shown in a more compact form that includes only the summary
|
121
|
+
# messages.
|
122
|
+
# @option parameters [Boolean] :input (true) When +false+, will not ask for
|
123
|
+
# input for variables not directly set.
|
124
|
+
# @option parameters [Boolean] :lock (true) When +true+, locks the state
|
125
|
+
# file when locking is supported; when +false+, does not lock the state
|
126
|
+
# file.
|
127
|
+
# @option parameters [String] :lock_timeout ("0s") The duration to retry a
|
128
|
+
# state lock.
|
129
|
+
# @option parameters [Boolean] :no_backup (false) When +true+, no backup
|
130
|
+
# file will be written (legacy).
|
131
|
+
# @option parameters [Boolean] :no_color (false) Whether or not the output
|
132
|
+
# from the command should be in color.
|
133
|
+
# @option parameters [Integer] :parallelism (10) The number of parallel
|
134
|
+
# resource operations.
|
135
|
+
# @option parameters [Boolean] :refresh (true) When +true+, updates state
|
136
|
+
# prior to checking for differences; when +false+ uses locally available
|
137
|
+
# state.
|
138
|
+
# @option parameters [String] :state ("terraform.tfstate") The path to the
|
139
|
+
# state file from which to read state and in which to store state (unless
|
140
|
+
# +:state_out+ is specified) (legacy).
|
141
|
+
# @option parameters [String] :state_out The path to write state to that is
|
142
|
+
# different than +:state+; this can be used to preserve the old state
|
143
|
+
# (legacy).
|
144
|
+
# @option parameters [String] :target The address of a resource to target;
|
145
|
+
# if both +:target+ and +:targets+ are provided, all targets will be
|
146
|
+
# passed to terraform.
|
147
|
+
# @option parameters [Array<String>] :targets An array of resource addresses
|
148
|
+
# to target; if both +:target+ and +:targets+ are provided, all targets
|
149
|
+
# will be passed to terraform.
|
150
|
+
# @option parameters [Hash<String, Object>] :vars A map of variables to be
|
151
|
+
# passed to the terraform configuration.
|
152
|
+
# @option parameters [String] :var_file The path to a terraform var file;
|
153
|
+
# if both +:var_file+ and +:var_files+ are provided, all var files will be
|
154
|
+
# passed to terraform.
|
155
|
+
# @option parameters [Array<String>] :var_files An array of paths to
|
156
|
+
# terraform var files; if both +:var_file+ and +:var_files+ are provided,
|
157
|
+
# all var files will be passed to terraform.
|
158
|
+
#
|
159
|
+
# @example Basic Invocation
|
160
|
+
# RubyTerraform.destroy(
|
161
|
+
# directory: 'infra/networking',
|
162
|
+
# vars: {
|
163
|
+
# region: 'eu-central'
|
164
|
+
# })
|
165
|
+
#
|
166
|
+
def destroy(parameters = {})
|
167
|
+
exec(RubyTerraform::Commands::Destroy, parameters)
|
168
|
+
end
|
169
|
+
|
170
|
+
# Invokes the +terraform force-unlock+ command which manually unlocks the
|
171
|
+
# state for the defined configuration.
|
172
|
+
#
|
173
|
+
# This will not modify your infrastructure. This command removes the lock on
|
174
|
+
# the state for the current workspace. The behavior of this lock is
|
175
|
+
# dependent on the backend being used. Local state files cannot be unlocked
|
176
|
+
# by another process.
|
177
|
+
#
|
178
|
+
# @param parameters The parameters used to invoke the command
|
179
|
+
# @option parameters [String] :lock_id The lock ID output when attempting an
|
180
|
+
# operation that failed due to a lock; required.
|
181
|
+
# @option parameters [String] :directory The path to a directory containing
|
182
|
+
# terraform configuration (deprecated in terraform 0.14, removed in
|
183
|
+
# terraform 0.15, use +:chdir+ instead).
|
184
|
+
# @option parameters [String] :chdir The path of a working directory to
|
185
|
+
# switch to before executing the given subcommand.
|
186
|
+
# @option parameters [Boolean] :force (false) If +true+, does not ask for
|
187
|
+
# input for unlock confirmation.
|
188
|
+
#
|
189
|
+
# @example Basic Invocation
|
190
|
+
# RubyTerraform.force_unlock(
|
191
|
+
# lock_id: '50e844a7-ebb0-fcfd-da85-5cce5bd1ec90')
|
192
|
+
#
|
193
|
+
def force_unlock(parameters = {})
|
194
|
+
exec(RubyTerraform::Commands::ForceUnlock, parameters)
|
195
|
+
end
|
196
|
+
|
197
|
+
# Invokes the +terraform fmt+ command which rewrites all terraform
|
198
|
+
# configuration files to a canonical format.
|
199
|
+
#
|
200
|
+
# Both configuration files (.tf) and variables files (.tfvars) are updated.
|
201
|
+
# JSON files (.tf.json or .tfvars.json) are not modified.
|
202
|
+
#
|
203
|
+
# If +:directory+ is not specified in the parameters map then the current
|
204
|
+
# working directory will be used. If +:directory+ is +"-"+ then content will
|
205
|
+
# be read from the standard input. The given content must be in the
|
206
|
+
# terraform language native syntax; JSON is not supported.
|
207
|
+
#
|
208
|
+
# @param parameters The parameters used to invoke the command
|
209
|
+
# @option parameters [String] :directory The path to a directory containing
|
210
|
+
# terraform configuration (deprecated in terraform 0.14, removed in
|
211
|
+
# terraform 0.15, use +:chdir+ instead).
|
212
|
+
# @option parameters [String] :chdir The path of a working directory to
|
213
|
+
# switch to before executing the given subcommand.
|
214
|
+
# @option parameters [Boolean] :list (false) If +true+, lists files whose
|
215
|
+
# formatting differs; always disabled if using standard input.
|
216
|
+
# @option parameters [Boolean] :write (false) If +true+, writes to source
|
217
|
+
# files; always disabled if using standard input or +:check+ is +true+.
|
218
|
+
# @option parameters [Boolean] :diff (false) If +true+, displays diffs of
|
219
|
+
# formatting changes.
|
220
|
+
# @option parameters [Boolean] :check (false) If +true+, checks if the input
|
221
|
+
# is formatted; if any input is not properly formatted, an
|
222
|
+
# {RubyTerraform::Errors::ExecutionError} will be thrown.
|
223
|
+
# @option parameters [Boolean] :no_color (false) Whether or not the output
|
224
|
+
# from the command should be in color.
|
225
|
+
# @option parameters [Boolean] :recursive (false) If +true+, also processes
|
226
|
+
# files in subdirectories; by default, only the provided +:directory+ is
|
227
|
+
# processed.
|
228
|
+
#
|
229
|
+
# @example Basic Invocation
|
230
|
+
# RubyTerraform.format(
|
231
|
+
# directory: 'infra/networking')
|
232
|
+
#
|
233
|
+
def format(parameters = {})
|
234
|
+
exec(RubyTerraform::Commands::Format, parameters)
|
235
|
+
end
|
236
|
+
alias fmt format
|
237
|
+
|
238
|
+
# Invokes the +terraform get+ command which downloads and installs modules
|
239
|
+
# needed for the given configuration.
|
240
|
+
#
|
241
|
+
# This recursively downloads all modules needed, such as modules imported by
|
242
|
+
# the root and so on. If a module is already downloaded, it will not be
|
243
|
+
# redownloaded or checked for updates unless +:update+ is +true+.
|
244
|
+
#
|
245
|
+
# Module installation also happens automatically by default as part of
|
246
|
+
# the {.init} command, so you should rarely need to run this command
|
247
|
+
# separately.
|
248
|
+
#
|
249
|
+
# @param parameters The parameters used to invoke the command
|
250
|
+
# @option parameters [String] :directory The path to a directory containing
|
251
|
+
# terraform configuration (deprecated in terraform 0.14, removed in
|
252
|
+
# terraform 0.15, use +:chdir+ instead).
|
253
|
+
# @option parameters [String] :chdir The path of a working directory to
|
254
|
+
# switch to before executing the given subcommand.
|
255
|
+
# @option parameters [Boolean] :update (false) If +true+, checks
|
256
|
+
# already-downloaded modules for available updates and installs the
|
257
|
+
# newest versions available.
|
258
|
+
# @option parameters [Boolean] :no_color (false) Whether or not the output
|
259
|
+
# from the command should be in color.
|
260
|
+
#
|
261
|
+
# @example Basic Invocation
|
262
|
+
# RubyTerraform.get(
|
263
|
+
# directory: 'infra/networking')
|
264
|
+
#
|
265
|
+
def get(parameters = {})
|
266
|
+
exec(RubyTerraform::Commands::Get, parameters)
|
267
|
+
end
|
268
|
+
|
269
|
+
# Invokes the +terraform graph+ command which outputs the visual execution
|
270
|
+
# graph of terraform resources according to either the current configuration
|
271
|
+
# or an execution plan.
|
272
|
+
#
|
273
|
+
# The graph is outputted in DOT format. The typical program that can
|
274
|
+
# read this format is GraphViz, but many web services are also available to
|
275
|
+
# read this format.
|
276
|
+
#
|
277
|
+
# The +:type+ option can be used to control the type of graph shown.
|
278
|
+
# Terraform creates different graphs for different operations. See the
|
279
|
+
# options below for the list of types supported. The default type is
|
280
|
+
# +"plan"+ if a configuration is given, and +"apply"+ if a plan file is
|
281
|
+
# passed as an argument.
|
282
|
+
#
|
283
|
+
# @param parameters The parameters used to invoke the command
|
284
|
+
# @option parameters [String] :directory The path to a directory containing
|
285
|
+
# terraform configuration (deprecated in terraform 0.14, removed in
|
286
|
+
# terraform 0.15, use +:chdir+ instead).
|
287
|
+
# @option parameters [String] :chdir The path of a working directory to
|
288
|
+
# switch to before executing the given subcommand.
|
289
|
+
# @option parameters [String] :plan Render the graph using the specified
|
290
|
+
# plan file instead of the configuration in the current directory.
|
291
|
+
# @option parameters [Boolean] :draw_cycles (false) If +true+, highlights
|
292
|
+
# any cycles in the graph with colored edges; this helps when diagnosing
|
293
|
+
# cycle errors.
|
294
|
+
# @option parameters [String] :type The type of graph to output; can be:
|
295
|
+
# +"plan"+, +"plan-destroy"+, +"apply"+, +"validate"+, +"input"+,
|
296
|
+
# +"refresh"+; defaults to +"apply"+ if +:plan+ is provided, +"plan"+
|
297
|
+
# otherwise.
|
298
|
+
# @option parameters [Integer] :module_depth In prior versions of terraform,
|
299
|
+
# specified the depth of modules to show in the output (deprecated).
|
300
|
+
#
|
301
|
+
# @example Basic Invocation
|
302
|
+
# RubyTerraform.graph
|
303
|
+
#
|
304
|
+
def graph(parameters = {})
|
305
|
+
exec(RubyTerraform::Commands::Graph, parameters)
|
306
|
+
end
|
307
|
+
|
308
|
+
# Invokes the +terraform import+ command which imports existing
|
309
|
+
# infrastructure into your terraform state.
|
310
|
+
#
|
311
|
+
# This will find and import the specified resource into your terraform
|
312
|
+
# state, allowing existing infrastructure to come under terraform
|
313
|
+
# management without having to be initially created by terraform.
|
314
|
+
#
|
315
|
+
# The +:address+ specified is the address to import the resource to. Please
|
316
|
+
# see the documentation online for resource addresses. The +:id+ is a
|
317
|
+
# resource-specific ID to identify that resource being imported. Please
|
318
|
+
# reference the documentation for the resource type you're importing to
|
319
|
+
# determine the ID syntax to use. It typically matches directly to the ID
|
320
|
+
# that the provider uses.
|
321
|
+
#
|
322
|
+
# The current implementation of terraform import can only import resources
|
323
|
+
# into the state. It does not generate configuration. A future version of
|
324
|
+
# terraform will also generate configuration.
|
325
|
+
#
|
326
|
+
# Because of this, prior to running terraform import it is necessary to
|
327
|
+
# write a resource configuration block for the resource manually, to which
|
328
|
+
# the imported object will be attached.
|
329
|
+
#
|
330
|
+
# This command will not modify your infrastructure, but it will make network
|
331
|
+
# requests to inspect parts of your infrastructure relevant to the resource
|
332
|
+
# being imported.
|
333
|
+
#
|
334
|
+
# @param parameters The parameters used to invoke the command
|
335
|
+
# @option parameters [String] :directory The path to a directory containing
|
336
|
+
# terraform configuration (deprecated in terraform 0.14, removed in
|
337
|
+
# terraform 0.15, use +:chdir+ instead).
|
338
|
+
# @option parameters [String] :address The address to import the resource
|
339
|
+
# to; required.
|
340
|
+
# @option parameters [String] :id The resource-specific ID identifying the
|
341
|
+
# resource being imported; required.
|
342
|
+
# @option parameters [String] :chdir The path of a working directory to
|
343
|
+
# switch to before executing the given subcommand.
|
344
|
+
# @option parameters [String] :backup The path to backup the existing state
|
345
|
+
# file before modifying; defaults to the +:state_out+ path with
|
346
|
+
# +".backup"+ extension; set +:no_backup+ to +true+ to skip backups
|
347
|
+
# entirely (legacy).
|
348
|
+
# @option parameters [Boolean] :allow_missing_config (false) Whether or not
|
349
|
+
# to allow import when no resource configuration block exists.
|
350
|
+
# @option parameters [Boolean] :input (true) When +false+, will not ask for
|
351
|
+
# input for variables not directly set.
|
352
|
+
# @option parameters [Boolean] :lock (true) When +true+, locks the state
|
353
|
+
# file when locking is supported; when +false+, does not lock the state
|
354
|
+
# file.
|
355
|
+
# @option parameters [String] :lock_timeout ("0s") The duration to retry a
|
356
|
+
# state lock.
|
357
|
+
# @option parameters [Boolean] :no_backup (false) When +true+, no backup
|
358
|
+
# file will be written (legacy).
|
359
|
+
# @option parameters [Boolean] :no_color (false) Whether or not the output
|
360
|
+
# from the command should be in color.
|
361
|
+
# @option parameters [Integer] :parallelism (10) The number of parallel
|
362
|
+
# resource operations.
|
363
|
+
# @option parameters [String] :provider The provider configuration to use
|
364
|
+
# when importing the object; by default, terraform uses the provider
|
365
|
+
# specified in the configuration for the target resource, and that is the
|
366
|
+
# best behavior in most cases (deprecated).
|
367
|
+
# @option parameters [String] :state ("terraform.tfstate") The path to the
|
368
|
+
# state file from which to read state and in which to store state (unless
|
369
|
+
# +:state_out+ is specified) (legacy).
|
370
|
+
# @option parameters [String] :state_out The path to write state to that is
|
371
|
+
# different than +:state+; this can be used to preserve the old state
|
372
|
+
# (legacy).
|
373
|
+
# @option parameters [Hash<String, Object>] :vars A map of variables to be
|
374
|
+
# passed to the terraform configuration.
|
375
|
+
# @option parameters [String] :var_file The path to a terraform var file;
|
376
|
+
# if both +:var_file+ and +:var_files+ are provided, all var files will be
|
377
|
+
# passed to terraform.
|
378
|
+
# @option parameters [Array<String>] :var_files An array of paths to
|
379
|
+
# terraform var files; if both +:var_file+ and +:var_files+ are provided,
|
380
|
+
# all var files will be passed to terraform.
|
381
|
+
# @option parameters [Boolean] :ignore_remote_version (false) If +true+,
|
382
|
+
# when using the enhanced remote backend with Terraform Cloud, continue
|
383
|
+
# even if remote and local Terraform versions differ; this may result in
|
384
|
+
# an unusable Terraform Cloud workspace, and should be used with extreme
|
385
|
+
# caution.
|
386
|
+
#
|
387
|
+
# @example Basic Invocation
|
388
|
+
# RubyTerraform.import(
|
389
|
+
# directory: 'infra/networking',
|
390
|
+
# address: 'a.resource.address',
|
391
|
+
# id: 'a-resource-id',
|
392
|
+
# vars: {
|
393
|
+
# region: 'eu-central'
|
394
|
+
# })
|
395
|
+
#
|
396
|
+
def import(parameters = {})
|
397
|
+
exec(RubyTerraform::Commands::Import, parameters)
|
398
|
+
end
|
399
|
+
|
400
|
+
# Invokes the +terraform init+ command which initializes a new or existing
|
401
|
+
# Terraform working directory by creating initial files, loading any remote
|
402
|
+
# state, downloading modules, etc.
|
403
|
+
#
|
404
|
+
# This is the first command that should be run for any new or existing
|
405
|
+
# Terraform configuration per machine. This sets up all the local data
|
406
|
+
# necessary to run Terraform that is typically not committed to version
|
407
|
+
# control.
|
408
|
+
#
|
409
|
+
# This command is always safe to run multiple times. Though subsequent runs
|
410
|
+
# may give errors, this command will never delete your configuration or
|
411
|
+
# state. Even so, if you have important information, please back it up prior
|
412
|
+
# to running this command, just in case.
|
413
|
+
#
|
414
|
+
# @param parameters The parameters used to invoke the command
|
415
|
+
# @option parameters [String] :path The path to initialize; defaults to the
|
416
|
+
# current directory (deprecated in terraform 0.14, removed in terraform
|
417
|
+
# 0.15, use +:chdir+ instead).
|
418
|
+
# @option parameters [String] :chdir The path of a working directory to
|
419
|
+
# switch to before executing the given subcommand.
|
420
|
+
# @option parameters [Boolean] :backend (true) Whether or not to configure
|
421
|
+
# the backend for this configuration.
|
422
|
+
# @option parameters [Hash<String,Object>] :backend_config A map of backend
|
423
|
+
# specific configuration parameters.
|
424
|
+
# @option parameters [Boolean] :force_copy (false) If +true+, suppresses
|
425
|
+
# prompts about copying state data; this is equivalent to providing a
|
426
|
+
# "yes" to all confirmation prompts.
|
427
|
+
# @option parameters [String] :from_module copies the contents of the given
|
428
|
+
# module into the target directory before initialization.
|
429
|
+
# @option parameters [Boolean] :get (true) Whether or not to download any
|
430
|
+
# modules for this configuration.
|
431
|
+
# @option parameters [Boolean] :get_plugins (true) Whether or not to install
|
432
|
+
# plugins for this configuration (deprecated, removed in terraform 0.15).
|
433
|
+
# @option parameters [Boolean] :input (true) When +false+, will not ask for
|
434
|
+
# input for variables not directly set.
|
435
|
+
# @option parameters [Boolean] :lock (true) When +true+, locks the state
|
436
|
+
# file when locking is supported; when +false+, does not lock the state
|
437
|
+
# file (deprecated, removed in terraform 0.15).
|
438
|
+
# @option parameters [String] :lock_timeout ("0s") The duration to retry a
|
439
|
+
# state lock (deprecated, removed in terraform 0.15).
|
440
|
+
# @option parameters [Boolean] :no_color (false) Whether or not the output
|
441
|
+
# from the command should be in color.
|
442
|
+
# @option parameters [String] :plugin_dir The path to a directory containing
|
443
|
+
# plugin binaries; this overrides all default search paths for plugins,
|
444
|
+
# and prevents the automatic installation of plugins; if both
|
445
|
+
# +:plugin_dir+ and +:plugin_dirs+ are provided, all plugin directories
|
446
|
+
# will be passed to Terraform.
|
447
|
+
# @option parameters [Array<String>] :plugin_dirs+: An array of paths to
|
448
|
+
# directories containing plugin binaries; this overrides all default
|
449
|
+
# search paths for plugins, and prevents the automatic installation of
|
450
|
+
# plugins; if both +:plugin_dir+ and +:plugin_dirs+ are provided, all
|
451
|
+
# plugin directories will be passed to Terraform.
|
452
|
+
# @option parameters [Boolean] :reconfigure (false) If +true+, reconfigures
|
453
|
+
# the backend, ignoring any saved configuration.
|
454
|
+
# @option parameters [Boolean] :upgrade (false) If +true+, when installing
|
455
|
+
# modules or plugins, ignores previously-downloaded objects and installs
|
456
|
+
# the latest version allowed within configured constraints.
|
457
|
+
# @option parameters [Boolean] :verify_plugins (true) Whether or not to
|
458
|
+
# verify plugins for this configuration (deprecated, removed in terraform
|
459
|
+
# 0.15).
|
460
|
+
# @option parameters [String] :lockfile Sets a dependency lockfile mode;
|
461
|
+
# currently only "readonly" is valid.
|
462
|
+
#
|
463
|
+
# @example Basic Invocation
|
464
|
+
# RubyTerraform.init(
|
465
|
+
# from_module: 'some/module/path',
|
466
|
+
# path: 'infra/module')
|
467
|
+
#
|
468
|
+
def init(parameters = {})
|
469
|
+
exec(RubyTerraform::Commands::Init, parameters)
|
470
|
+
end
|
471
|
+
|
472
|
+
# Invokes the +terraform login+ command which retrieves an authentication
|
473
|
+
# token for the given hostname, if it supports automatic login, and saves it
|
474
|
+
# in a credentials file in your home directory.
|
475
|
+
#
|
476
|
+
# If no hostname is provided, the default hostname is app.terraform.io, to
|
477
|
+
# log in to Terraform Cloud.
|
478
|
+
#
|
479
|
+
# If not overridden by credentials helper settings in the CLI configuration,
|
480
|
+
# the credentials will be written to the following local file:
|
481
|
+
# ~/.terraform.d/credentials.tfrc.json
|
482
|
+
#
|
483
|
+
# @param parameters The parameters used to invoke the command
|
484
|
+
# @option parameters [String] :chdir The path of a working directory to
|
485
|
+
# switch to before executing the given subcommand.
|
486
|
+
#
|
487
|
+
# @example Basic Invocation
|
488
|
+
# RubyTerraform.login
|
489
|
+
#
|
490
|
+
def login(parameters = {})
|
491
|
+
exec(RubyTerraform::Commands::Login, parameters)
|
492
|
+
end
|
493
|
+
|
494
|
+
# Invokes the +terraform logout+ command which removes locally-stored
|
495
|
+
# credentials for specified hostname.
|
496
|
+
#
|
497
|
+
# Note: the API token is only removed from local storage, not destroyed on
|
498
|
+
# the remote server, so it will remain valid until manually revoked.
|
499
|
+
#
|
500
|
+
# If no hostname is provided, the default hostname is app.terraform.io.
|
501
|
+
#
|
502
|
+
# @param parameters The parameters used to invoke the command
|
503
|
+
# @option parameters [String] :chdir The path of a working directory to
|
504
|
+
# switch to before executing the given subcommand.
|
505
|
+
#
|
506
|
+
# @example Basic Invocation
|
507
|
+
# RubyTerraform.logout
|
508
|
+
#
|
509
|
+
def logout(parameters = {})
|
510
|
+
exec(RubyTerraform::Commands::Logout, parameters)
|
511
|
+
end
|
512
|
+
|
513
|
+
# Invokes the +terraform output+ command which reads an output variable from
|
514
|
+
# a Terraform state file and prints the value. With no additional arguments,
|
515
|
+
# output will display all the outputs for the root module. If +:name+ is not
|
516
|
+
# specified, all outputs are printed.
|
517
|
+
#
|
518
|
+
# @param parameters The parameters used to invoke the command
|
519
|
+
# @option parameters [String] :name The name of the output to read.
|
520
|
+
# @option parameters [String] :chdir The path of a working directory to
|
521
|
+
# switch to before executing the given subcommand.
|
522
|
+
# @option parameters [String] :state The path to the state file to read;
|
523
|
+
# defaults to +"terraform.tfstate"+.
|
524
|
+
# @option parameters [Boolean] :no_color (false) Whether or not the output
|
525
|
+
# from the command should be in color.
|
526
|
+
# @option parameters [Boolean] :json (false) If +true+, machine readable
|
527
|
+
# output will be printed in JSON format.
|
528
|
+
# @option parameters [Boolean] :raw (false) If +true+, for value types that
|
529
|
+
# can be automatically converted to a string, will print the raw string
|
530
|
+
# directly, rather than a human-oriented representation of the value.
|
531
|
+
#
|
532
|
+
# @example Basic Invocation
|
533
|
+
# RubyTerraform.output(
|
534
|
+
# name: 'vpc_id')
|
535
|
+
#
|
536
|
+
def output(parameters = {})
|
537
|
+
exec(RubyTerraform::Commands::Output, parameters)
|
538
|
+
end
|
539
|
+
|
540
|
+
# Invokes the +terraform plan+ command which generates a speculative
|
541
|
+
# execution plan, showing what actions Terraform would take to apply the
|
542
|
+
# current configuration. This command will not actually perform the planned
|
543
|
+
# actions.
|
544
|
+
#
|
545
|
+
# You can optionally save the plan to a file, which you can then pass to
|
546
|
+
# the {#apply} command to perform exactly the actions described in the plan.
|
547
|
+
#
|
548
|
+
# @param parameters The parameters used to invoke the command
|
549
|
+
# @option parameters [String] :plan The path to a directory containing
|
550
|
+
# terraform configuration (deprecated in terraform 0.14, removed in
|
551
|
+
# terraform 0.15, use +:chdir+ instead).
|
552
|
+
# @option parameters [String] :chdir The path of a working directory to
|
553
|
+
# switch to before executing the given subcommand.
|
554
|
+
# @option parameters [Boolean] :compact_warnings (false) When +true+, if
|
555
|
+
# terraform produces any warnings that are not accompanied by errors,
|
556
|
+
# they are shown in a more compact form that includes only the summary
|
557
|
+
# messages.
|
558
|
+
# @option parameters [Boolean] :destroy (false) When +true+, a plan will be
|
559
|
+
# generated to destroy all resources managed by the given configuration
|
560
|
+
# and state.
|
561
|
+
# @option parameters [Boolean] :detailed_exitcode (false) Whether or not to
|
562
|
+
# return detailed exit codes when the command exits; this will change the
|
563
|
+
# meaning of exit codes to: 0 - Succeeded, diff is empty (no changes); 1 -
|
564
|
+
# Errored; 2 - Succeeded, there is a diff.
|
565
|
+
# @option parameters [Boolean] :input (true) When +false+, will not ask for
|
566
|
+
# input for variables not directly set.
|
567
|
+
# @option parameters [Boolean] :lock (true) When +true+, locks the state
|
568
|
+
# file when locking is supported; when +false+, does not lock the state
|
569
|
+
# file.
|
570
|
+
# @option parameters [String] :lock_timeout ("0s") The duration to retry a
|
571
|
+
# state lock.
|
572
|
+
# @option parameters [Boolean] :no_color (false) Whether or not the output
|
573
|
+
# from the command should be in color.
|
574
|
+
# @option parameters [Integer] :parallelism (10) The number of parallel
|
575
|
+
# resource operations.
|
576
|
+
# @option parameters [Boolean] :refresh (true) When +true+, updates state
|
577
|
+
# prior to checking for differences; when +false+ uses locally available
|
578
|
+
# state; this has no effect when +:plan+ is provided.
|
579
|
+
# @option parameters [String] :state ("terraform.tfstate") The path to the
|
580
|
+
# state file from which to read state and in which to store state (unless
|
581
|
+
# +:state_out+ is specified).
|
582
|
+
# @option parameters [String] :target The address of a resource to target;
|
583
|
+
# if both +:target+ and +:targets+ are provided, all targets will be
|
584
|
+
# passed to terraform.
|
585
|
+
# @option parameters [Array<String>] :targets An array of resource addresses
|
586
|
+
# to target; if both +:target+ and +:targets+ are provided, all targets
|
587
|
+
# will be passed to terraform.
|
588
|
+
# @option parameters [Hash<String, Object>] :vars A map of variables to be
|
589
|
+
# passed to the terraform configuration.
|
590
|
+
# @option parameters [String] :var_file The path to a terraform var file;
|
591
|
+
# if both +:var_file+ and +:var_files+ are provided, all var files will be
|
592
|
+
# passed to terraform.
|
593
|
+
# @option parameters [Array<String>] :var_files An array of paths to
|
594
|
+
# terraform var files; if both +:var_file+ and +:var_files+ are provided,
|
595
|
+
# all var files will be passed to terraform.
|
596
|
+
#
|
597
|
+
# @example Basic Invocation
|
598
|
+
# RubyTerraform.plan(
|
599
|
+
# directory: 'infra/networking',
|
600
|
+
# vars: {
|
601
|
+
# region: 'eu-central'
|
602
|
+
# })
|
603
|
+
#
|
604
|
+
def plan(parameters = {})
|
605
|
+
exec(RubyTerraform::Commands::Plan, parameters)
|
606
|
+
end
|
607
|
+
|
608
|
+
# Invokes the +terraform providers+ command which prints out a tree of
|
609
|
+
# modules in the referenced configuration annotated with their provider
|
610
|
+
# requirements.
|
611
|
+
#
|
612
|
+
# This provides an overview of all of the provider requirements across all
|
613
|
+
# referenced modules, as an aid to understanding why particular provider
|
614
|
+
# plugins are needed and why particular versions are selected.
|
615
|
+
#
|
616
|
+
# @param parameters The parameters used to invoke the command
|
617
|
+
# @option parameters [String] :directory The path to a directory containing
|
618
|
+
# terraform configuration (deprecated in terraform 0.14, removed in
|
619
|
+
# terraform 0.15, use +:chdir+ instead).
|
620
|
+
# @option parameters [String] :chdir The path of a working directory to
|
621
|
+
# switch to before executing the given subcommand.
|
622
|
+
#
|
623
|
+
# @example Basic Invocation
|
624
|
+
# RubyTerraform.providers
|
625
|
+
#
|
626
|
+
def providers(parameters = {})
|
627
|
+
exec(RubyTerraform::Commands::Providers, parameters)
|
628
|
+
end
|
629
|
+
|
630
|
+
# Invokes the +terraform providers lock+ command which writes out dependency
|
631
|
+
# locks for the configured providers.
|
632
|
+
#
|
633
|
+
# Normally the dependency lock file (.terraform.lock.hcl) is updated
|
634
|
+
# automatically by "terraform init", but the information available to the
|
635
|
+
# normal provider installer can be constrained when you're installing
|
636
|
+
# providers from filesystem or network mirrors, and so the generated lock
|
637
|
+
# file can end up incomplete.
|
638
|
+
#
|
639
|
+
# The "providers lock" subcommand addresses that by updating the lock file
|
640
|
+
# based on the official packages available in the origin registry, ignoring
|
641
|
+
# the currently-configured installation strategy.
|
642
|
+
#
|
643
|
+
# After this command succeeds, the lock file will contain suitable checksums
|
644
|
+
# to allow installation of the providers needed by the current configuration
|
645
|
+
# on all of the selected platforms.
|
646
|
+
#
|
647
|
+
# By default this command updates the lock file for every provider declared
|
648
|
+
# in the configuration. You can override that behavior by providing one or
|
649
|
+
# more provider source addresses on the command line.
|
650
|
+
#
|
651
|
+
# @param parameters The parameters used to invoke the command
|
652
|
+
# @option parameters [String] :provider The provider source address for
|
653
|
+
# which the lock file should be updated; if both +:provider+ and
|
654
|
+
# +:providers+ are provided, all providers will be passed to Terraform.
|
655
|
+
# @option parameters [Array<String>] :providers An array of provider source
|
656
|
+
# addresses for which the lock file should be updated; if both +:provider+
|
657
|
+
# and +:providers+ are provided, all providers will be passed to
|
658
|
+
# Terraform.
|
659
|
+
# @option parameters [String] :providers The provider source addresses for
|
660
|
+
# which the lock file should be updated.
|
661
|
+
# @option parameters [String] :chdir The path of a working directory to
|
662
|
+
# switch to before executing the given subcommand.
|
663
|
+
# @option parameters [String] :fs_mirror If provided, consults the given
|
664
|
+
# filesystem mirror directory instead of the origin registry for each of
|
665
|
+
# the given providers; this would be necessary to generate lock file
|
666
|
+
# entries for a provider that is available only via a mirror, and not
|
667
|
+
# published in an upstream registry; in this case, the set of valid
|
668
|
+
# checksums will be limited only to what Terraform can learn from the data
|
669
|
+
# in the mirror directory.
|
670
|
+
# @option parameters [String] :net_mirror If provided, consults the given
|
671
|
+
# network mirror (given as a base URL) instead of the origin registry for
|
672
|
+
# each of the given providers; this would be necessary to generate lock
|
673
|
+
# file entries for a provider that is available only via a mirror, and not
|
674
|
+
# published in an upstream registry; in this case, the set of valid
|
675
|
+
# checksums will be limited only to what Terraform can learn from the data
|
676
|
+
# in the mirror indices.
|
677
|
+
# @option parameters [String] :platform The target platform to request
|
678
|
+
# package checksums for; by default Terraform will request package
|
679
|
+
# checksums suitable only for the platform where you run this command;
|
680
|
+
# target names consist of an operating system and a CPU architecture; for
|
681
|
+
# example, "linux_amd64" selects the Linux operating system running on an
|
682
|
+
# AMD64 or x86_64 CPU; each provider is available only for a limited set
|
683
|
+
# of target platforms; if both +:platform+ and +:platforms+ are provided,
|
684
|
+
# all platforms will be passed to Terraform.
|
685
|
+
# @option parameters [Array<String>] :platforms An array of target platforms
|
686
|
+
# to request package checksums for; see +:platform+ for more details; if
|
687
|
+
# both +:platform+ and +:platforms+ are provided, all platforms will be
|
688
|
+
# passed to Terraform.
|
689
|
+
#
|
690
|
+
# @example Basic Invocation
|
691
|
+
# RubyTerraform.providers_lock(
|
692
|
+
# fs_mirror: "/usr/local/terraform/providers",
|
693
|
+
# platforms: ["windows_amd64", "darwin_amd64", "linux_amd64"],
|
694
|
+
# provider: "tf.example.com/ourcompany/ourplatform")
|
695
|
+
#
|
696
|
+
def providers_lock(parameters = {})
|
697
|
+
exec(RubyTerraform::Commands::ProvidersLock, parameters)
|
698
|
+
end
|
699
|
+
|
700
|
+
# Invokes the +terraform providers mirror+ command which saves local copies
|
701
|
+
# of all required provider plugins.
|
702
|
+
#
|
703
|
+
# Populates a local directory with copies of the provider plugins needed for
|
704
|
+
# the current configuration, so that the directory can be used either
|
705
|
+
# directly as a filesystem mirror or as the basis for a network mirror and
|
706
|
+
# thus obtain those providers without access to their origin registries in
|
707
|
+
# future.
|
708
|
+
#
|
709
|
+
# The mirror directory will contain JSON index files that can be published
|
710
|
+
# along with the mirrored packages on a static HTTP file server to produce a
|
711
|
+
# network mirror. Those index files will be ignored if the directory is used
|
712
|
+
# instead as a local filesystem mirror.
|
713
|
+
#
|
714
|
+
# @param parameters The parameters used to invoke the command
|
715
|
+
# @option parameters [String] :directory The directory to populate with the
|
716
|
+
# mirrored provider plugins.
|
717
|
+
# @option parameters [String] :chdir The path of a working directory to
|
718
|
+
# switch to before executing the given subcommand.
|
719
|
+
# @option parameters [String] :platform The target platform to build a
|
720
|
+
# mirror for; by default Terraform will obtain plugin packages suitable
|
721
|
+
# for the platform where you run this command; target names consist of an
|
722
|
+
# operating system and a CPU architecture; for example, "linux_amd64"
|
723
|
+
# selects the Linux operating system running on an AMD64 or x86_64 CPU;
|
724
|
+
# each provider is available only for a limited set of target platforms;
|
725
|
+
# if both +:platform+ and +:platforms+ are provided, all platforms will be
|
726
|
+
# passed to Terraform.
|
727
|
+
# @option parameters [Array<String>] :platforms An array of target platforms
|
728
|
+
# to build a mirror for for; see +:platform+ for more details; if both
|
729
|
+
# +:platform+ and +:platforms+ are provided, all platforms will be passed
|
730
|
+
# to Terraform.
|
731
|
+
#
|
732
|
+
# @example Basic Invocation
|
733
|
+
# RubyTerraform.providers_mirror(
|
734
|
+
# directory: './plugins',
|
735
|
+
# platforms: ["windows_amd64", "darwin_amd64", "linux_amd64"])
|
736
|
+
#
|
737
|
+
def providers_mirror(parameters = {})
|
738
|
+
exec(RubyTerraform::Commands::ProvidersMirror, parameters)
|
739
|
+
end
|
740
|
+
|
741
|
+
# Invokes the +terraform providers schema+ command which prints out a json
|
742
|
+
# representation of the schemas for all providers used in the current
|
743
|
+
# configuration.
|
744
|
+
#
|
745
|
+
# @param parameters The parameters used to invoke the command
|
746
|
+
# @option parameters [String] :chdir The path of a working directory to
|
747
|
+
# switch to before executing the given subcommand.
|
748
|
+
#
|
749
|
+
# @example Basic Invocation
|
750
|
+
# RubyTerraform.providers_schema(
|
751
|
+
# directory: 'infra/networking')
|
752
|
+
#
|
753
|
+
def providers_schema(parameters = {})
|
754
|
+
exec(RubyTerraform::Commands::ProvidersSchema, parameters)
|
755
|
+
end
|
756
|
+
|
757
|
+
# Invokes the +terraform refresh+ command which updates the state file of
|
758
|
+
# your infrastructure with metadata that matches the physical resources they
|
759
|
+
# are tracking.
|
760
|
+
#
|
761
|
+
# This will not modify your infrastructure, but it can modify your state
|
762
|
+
# file to update metadata. This metadata might cause new changes to occur
|
763
|
+
# when you generate a plan or call apply next.
|
764
|
+
#
|
765
|
+
# @param parameters The parameters used to invoke the command
|
766
|
+
# @option parameters [String] :directory The path to a directory containing
|
767
|
+
# terraform configuration (deprecated in terraform 0.14, removed in
|
768
|
+
# terraform 0.15, use +:chdir+ instead).
|
769
|
+
# @option parameters [String] :chdir The path of a working directory to
|
770
|
+
# switch to before executing the given subcommand.
|
771
|
+
# @option parameters [String] :backup The path to backup the existing state
|
772
|
+
# file before modifying; defaults to the +:state_out+ path with
|
773
|
+
# +".backup"+ extension; set +:no_backup+ to +true+ to skip backups
|
774
|
+
# entirely (legacy).
|
775
|
+
# @option parameters [Boolean] :compact_warnings (false) When +true+, if
|
776
|
+
# terraform produces any warnings that are not accompanied by errors,
|
777
|
+
# they are shown in a more compact form that includes only the summary
|
778
|
+
# messages.
|
779
|
+
# @option parameters [Boolean] :input (true) When +false+, will not ask for
|
780
|
+
# input for variables not directly set.
|
781
|
+
# @option parameters [Boolean] :lock (true) When +true+, locks the state
|
782
|
+
# file when locking is supported; when +false+, does not lock the state
|
783
|
+
# file.
|
784
|
+
# @option parameters [String] :lock_timeout ("0s") The duration to retry a
|
785
|
+
# state lock.
|
786
|
+
# @option parameters [Boolean] :no_backup (false) When +true+, no backup
|
787
|
+
# file will be written (legacy).
|
788
|
+
# @option parameters [Boolean] :no_color (false) Whether or not the output
|
789
|
+
# from the command should be in color.
|
790
|
+
# @option parameters [Integer] :parallelism (10) The number of parallel
|
791
|
+
# resource operations.
|
792
|
+
# @option parameters [Boolean] :refresh (true) When +true+, updates state
|
793
|
+
# prior to checking for differences; when +false+ uses locally available
|
794
|
+
# state; this has no effect when +:plan+ is provided.
|
795
|
+
# @option parameters [String] :state ("terraform.tfstate") The path to the
|
796
|
+
# state file from which to read state and in which to store state (unless
|
797
|
+
# +:state_out+ is specified) (legacy).
|
798
|
+
# @option parameters [String] :state_out The path to write state to that is
|
799
|
+
# different than +:state+; this can be used to preserve the old state
|
800
|
+
# (legacy).
|
801
|
+
# @option parameters [String] :target The address of a resource to target;
|
802
|
+
# if both +:target+ and +:targets+ are provided, all targets will be
|
803
|
+
# passed to terraform.
|
804
|
+
# @option parameters [Array<String>] :targets An array of resource addresses
|
805
|
+
# to target; if both +:target+ and +:targets+ are provided, all targets
|
806
|
+
# will be passed to terraform.
|
807
|
+
# @option parameters [Hash<String, Object>] :vars A map of variables to be
|
808
|
+
# passed to the terraform configuration.
|
809
|
+
# @option parameters [String] :var_file The path to a terraform var file;
|
810
|
+
# if both +:var_file+ and +:var_files+ are provided, all var files will be
|
811
|
+
# passed to terraform.
|
812
|
+
# @option parameters [Array<String>] :var_files An array of paths to
|
813
|
+
# terraform var files; if both +:var_file+ and +:var_files+ are provided,
|
814
|
+
# all var files will be passed to terraform.
|
815
|
+
#
|
816
|
+
# @example Basic Invocation
|
817
|
+
# RubyTerraform.refresh(
|
818
|
+
# directory: 'infra/networking',
|
819
|
+
# vars: {
|
820
|
+
# region: 'eu-central'
|
821
|
+
# })
|
822
|
+
#
|
823
|
+
def refresh(parameters = {})
|
824
|
+
exec(RubyTerraform::Commands::Refresh, parameters)
|
825
|
+
end
|
826
|
+
|
827
|
+
# Invokes the +terraform show+ command which reads and outputs a Terraform
|
828
|
+
# state or plan file in a human-readable form. If no path is specified, the
|
829
|
+
# current state will be shown.
|
830
|
+
#
|
831
|
+
# @param parameters The parameters used to invoke the command
|
832
|
+
# @option parameters [String] :path The path to a state file or plan to
|
833
|
+
# show.
|
834
|
+
# @option parameters [String] :chdir The path of a working directory to
|
835
|
+
# switch to before executing the given subcommand.
|
836
|
+
# @option parameters [Boolean] :no_color (false) Whether or not the output
|
837
|
+
# from the command should be in color.
|
838
|
+
# @option parameters [Boolean] :json (false) If +true+, outputs the
|
839
|
+
# Terraform plan or state in a machine-readable form.
|
840
|
+
#
|
841
|
+
# @example Basic Invocation
|
842
|
+
# RubyTerraform.show
|
843
|
+
#
|
844
|
+
def show(parameters = {})
|
845
|
+
exec(RubyTerraform::Commands::Show, parameters)
|
846
|
+
end
|
847
|
+
|
848
|
+
# Invokes the +terraform state list+ command which lists resources in the
|
849
|
+
# Terraform state.
|
850
|
+
#
|
851
|
+
# This command lists resource instances in the Terraform state. The address
|
852
|
+
# option can be used to filter the instances by resource or module. If no
|
853
|
+
# pattern is given, all resource instances are listed.
|
854
|
+
#
|
855
|
+
# The addresses must either be module addresses or absolute resource
|
856
|
+
# addresses, such as:
|
857
|
+
#
|
858
|
+
# * +aws_instance.example+
|
859
|
+
# * +module.example+
|
860
|
+
# * +module.example.module.child+
|
861
|
+
# * +module.example.aws_instance.example+
|
862
|
+
#
|
863
|
+
# An {RubyTerraform::Errors::ExecutionError} will be raised if any of the
|
864
|
+
# resources or modules given as filter addresses do not exist in the state.
|
865
|
+
#
|
866
|
+
# @param parameters The parameters used to invoke the command
|
867
|
+
# @option parameters [String] :address The module address or absolute
|
868
|
+
# resource address to filter by; if both +:address+ and +:addresses+ are
|
869
|
+
# provided, all addresses will be passed to Terraform.
|
870
|
+
# @option parameters [Array<String>] :addresses An array of module addresses
|
871
|
+
# or absolute resource addresses to filter by; if both +:address+ and
|
872
|
+
# +:addresses+ are provided, all addresses will be passed to Terraform.
|
873
|
+
# @option parameters [String] :chdir The path of a working directory to
|
874
|
+
# switch to before executing the given subcommand.
|
875
|
+
# @option parameters [String] :state The path to a Terraform state file to
|
876
|
+
# use to look up Terraform-managed resources; by default, Terraform will
|
877
|
+
# consult the state of the currently-selected workspace.
|
878
|
+
# @option parameters [String] :id When provided, filters the results to
|
879
|
+
# include only instances whose resource types have an attribute named "id"
|
880
|
+
# whose value equals the given id string.
|
881
|
+
#
|
882
|
+
# @example Basic Invocation
|
883
|
+
# RubyTerraform.state_list
|
884
|
+
#
|
885
|
+
def state_list(parameters = {})
|
886
|
+
exec(RubyTerraform::Commands::StateList, parameters)
|
887
|
+
end
|
888
|
+
|
889
|
+
# Invokes the +terraform state mv+ command which moves an item in the state.
|
890
|
+
#
|
891
|
+
# This command will move an item matched by the address given to the
|
892
|
+
# destination address. This command can also move to a destination address
|
893
|
+
# in a completely different state file.
|
894
|
+
#
|
895
|
+
# This can be used for simple resource renaming, moving items to and from
|
896
|
+
# a module, moving entire modules, and more. And because this command can
|
897
|
+
# also move data to a completely new state, it can also be used for
|
898
|
+
# refactoring one configuration into multiple separately managed Terraform
|
899
|
+
# configurations.
|
900
|
+
#
|
901
|
+
# This command will output a backup copy of the state prior to saving any
|
902
|
+
# changes. The backup cannot be disabled. Due to the destructive nature
|
903
|
+
# of this command, backups are required.
|
904
|
+
#
|
905
|
+
# If you're moving an item to a different state file, a backup will be
|
906
|
+
# created for each state file.
|
907
|
+
#
|
908
|
+
# @param parameters The parameters used to invoke the command
|
909
|
+
# @option parameters [String] :source The source address of the item to
|
910
|
+
# move; required.
|
911
|
+
# @option parameters [String] :destination The destination address to move
|
912
|
+
# the item to; required.
|
913
|
+
# @option parameters [String] :chdir The path of a working directory to
|
914
|
+
# switch to before executing the given subcommand.
|
915
|
+
# @option parameters [Boolean] :dry_run (false) When +true+, prints out what
|
916
|
+
# would've been moved but doesn't actually move anything.
|
917
|
+
# @option parameters [String] :backup The path where Terraform should write
|
918
|
+
# the backup for the original state; this can't be disabled; if not set,
|
919
|
+
# Terraform will write it to the same path as the state file with a
|
920
|
+
# +".backup"+ extension.
|
921
|
+
# @option parameters [String] :backup_out The path where Terraform should
|
922
|
+
# write the backup for the destination state; this can't be disabled; if
|
923
|
+
# not set, Terraform will write it to the same path as the destination
|
924
|
+
# state file with a +".backup"+ extension; this only needs to be specified
|
925
|
+
# if +:state_out+ is set to a different path than +:state+.
|
926
|
+
# @option parameters [Boolean] :lock (true) When +true+, locks the state
|
927
|
+
# file when locking is supported; when +false+, does not lock the state
|
928
|
+
# file.
|
929
|
+
# @option parameters [String] :lock_timeout ("0s") The duration to retry a
|
930
|
+
# state lock.
|
931
|
+
# @option parameters [String] :state the path to the source state file;
|
932
|
+
# defaults to the configured backend, or +"terraform.tfstate"+.
|
933
|
+
# @option parameters [String] :state_out The path to the destination state
|
934
|
+
# file to write to; if this isn't specified, the source state file will be
|
935
|
+
# used; this can be a new or existing path.
|
936
|
+
# @option parameters [Boolean] :ignore_remote_version (false) Whether or not
|
937
|
+
# to continue even if remote and local Terraform versions are
|
938
|
+
# incompatible; this may result in an unusable workspace, and should be
|
939
|
+
# used with extreme caution.
|
940
|
+
#
|
941
|
+
# @example Basic Invocation
|
942
|
+
# RubyTerraform.state_move(
|
943
|
+
# source: 'packet_device.worker',
|
944
|
+
# destination: 'packet_device.helper')
|
945
|
+
#
|
946
|
+
def state_move(parameters = {})
|
947
|
+
exec(RubyTerraform::Commands::StateMove, parameters)
|
948
|
+
end
|
949
|
+
alias state_mv state_move
|
950
|
+
|
951
|
+
# Invokes the +terraform state pull+ command which pulls the state from its
|
952
|
+
# location, upgrades the local copy, and outputs it to stdout.
|
953
|
+
#
|
954
|
+
# This command "pulls" the current state and outputs it to stdout. As part
|
955
|
+
# of this process, Terraform will upgrade the state format of the local copy
|
956
|
+
# to the current version.
|
957
|
+
#
|
958
|
+
# The primary use of this is for state stored remotely. This command will
|
959
|
+
# still work with local state but is less useful for this.
|
960
|
+
#
|
961
|
+
# @param parameters The parameters used to invoke the command
|
962
|
+
# @option parameters [String] :chdir The path of a working directory to
|
963
|
+
# switch to before executing the given subcommand.
|
964
|
+
#
|
965
|
+
# @example Basic Invocation
|
966
|
+
# RubyTerraform.state_pull
|
967
|
+
#
|
968
|
+
def state_pull(parameters = {})
|
969
|
+
exec(RubyTerraform::Commands::StatePull, parameters)
|
970
|
+
end
|
971
|
+
|
972
|
+
# Invokes the +terraform state push+ command which updates remote state from
|
973
|
+
# a local state file.
|
974
|
+
#
|
975
|
+
# This command "pushes" a local state and overwrites remote state with a
|
976
|
+
# local state file. The command will protect you against writing
|
977
|
+
# an older serial or a different state file lineage unless you pass +true+
|
978
|
+
# for the +:force+ option.
|
979
|
+
#
|
980
|
+
# This command works with local state (it will overwrite the local state),
|
981
|
+
# but is less useful for this use case.
|
982
|
+
#
|
983
|
+
# If +:path+ is +"-"+, then this command will read the state to push from
|
984
|
+
# stdin. Data from stdin is not streamed to the backend: it is loaded
|
985
|
+
# completely (until pipe close), verified, and then pushed.
|
986
|
+
#
|
987
|
+
# @param parameters The parameters used to invoke the command
|
988
|
+
# @option parameters [String] :path The path to the state file to push; when
|
989
|
+
# passed +"-"+ will read state from standard input.
|
990
|
+
# @option parameters [String] :chdir The path of a working directory to
|
991
|
+
# switch to before executing the given subcommand.
|
992
|
+
# @option parameters [Boolean] :force (false) When +true+, writes the state
|
993
|
+
# even if lineages don't match or the remote serial is higher.
|
994
|
+
# @option parameters [Boolean] :lock (true) When +true+, locks the state
|
995
|
+
# file when locking is supported; when +false+, does not lock the state
|
996
|
+
# file.
|
997
|
+
# @option parameters [String] :lock_timeout ("0s") The duration to retry a
|
998
|
+
# state lock.
|
999
|
+
# @option parameters [Boolean] :ignore_remote_version Whether or not to
|
1000
|
+
# continue even if remote and local Terraform versions are incompatible;
|
1001
|
+
# this may result in an unusable workspace, and should be used with
|
1002
|
+
# extreme caution.
|
1003
|
+
#
|
1004
|
+
# @example Basic Invocation
|
1005
|
+
# RubyTerraform.state_push(
|
1006
|
+
# path: 'some/statefile.tfstate')
|
1007
|
+
#
|
1008
|
+
def state_push(parameters = {})
|
1009
|
+
exec(RubyTerraform::Commands::StatePush, parameters)
|
67
1010
|
end
|
68
1011
|
|
69
|
-
|
1012
|
+
# Invokes the +terraform state rm+ command which removes one or more items
|
1013
|
+
# from the Terraform state, causing Terraform to "forget" those items
|
1014
|
+
# without first destroying them in the remote system.
|
1015
|
+
#
|
1016
|
+
# This command removes one or more resource instances from the Terraform
|
1017
|
+
# state based on the addresses given. You can view and list the available
|
1018
|
+
# instances with {#state_list}.
|
1019
|
+
#
|
1020
|
+
# If you give the address of an entire module then all of the instances in
|
1021
|
+
# that module and any of its child modules will be removed from the state.
|
1022
|
+
#
|
1023
|
+
# If you give the address of a resource that has "count" or "for_each" set,
|
1024
|
+
# all of the instances of that resource will be removed from the state.
|
1025
|
+
#
|
1026
|
+
# @param parameters The parameters used to invoke the command
|
1027
|
+
# @option parameters [String] :address The module address or absolute
|
1028
|
+
# resource address of the resource instance to remove; required unless
|
1029
|
+
# +:addresses+ is supplied; if both +:address+ and +:addresses+ are
|
1030
|
+
# provided, all addresses will be passed to Terraform.
|
1031
|
+
# @option parameters [Array<String>] :addresses An array of module addresses
|
1032
|
+
# or absolute resource addresses of the resource instances to remove;
|
1033
|
+
# required unless +:address+ is supplied; if both +:address+ and
|
1034
|
+
# +:addresses+ are provided, all addresses will be passed to Terraform.
|
1035
|
+
# @option parameters [String] :chdir The path of a working directory to
|
1036
|
+
# switch to before executing the given subcommand.
|
1037
|
+
# @option parameters [Boolean] :dry+run (false) When +true+, prints out what
|
1038
|
+
# would've been removed but doesn't actually remove anything.
|
1039
|
+
# @option parameters [String] :backup The path where Terraform should
|
1040
|
+
# write the backup state.
|
1041
|
+
# @option parameters [Boolean] :lock (true) When +true+, locks the state
|
1042
|
+
# file when locking is supported; when +false+, does not lock the state
|
1043
|
+
# file.
|
1044
|
+
# @option parameters [String] :lock_timeout ("0s") The duration to retry a
|
1045
|
+
# state lock.
|
1046
|
+
# @option parameters [String] :state The path to the state file to update;
|
1047
|
+
# defaults to the current workspace state.
|
1048
|
+
# @option parameters [Boolean] :ignore_remote_version (false) Whether or not
|
1049
|
+
# to continue even if remote and local Terraform versions are
|
1050
|
+
# incompatible; this may result in an unusable workspace, and should be
|
1051
|
+
# used with extreme caution.
|
1052
|
+
#
|
1053
|
+
# @example Basic Invocation
|
1054
|
+
# RubyTerraform.state_remove(
|
1055
|
+
# address: 'packet_device.worker')
|
1056
|
+
#
|
1057
|
+
def state_remove(parameters = {})
|
1058
|
+
exec(RubyTerraform::Commands::StateRemove, parameters)
|
1059
|
+
end
|
1060
|
+
alias state_rm state_remove
|
1061
|
+
|
1062
|
+
# Invoke the +terraform state replace-provider+ command which replaces
|
1063
|
+
# provider for resources in the Terraform state.
|
1064
|
+
#
|
1065
|
+
# @param parameters The parameters used to invoke the command
|
1066
|
+
# @option parameters [String] :from The fully qualified name of the provider
|
1067
|
+
# to be replaced; required.
|
1068
|
+
# @option parameters [String] :to The fully qualified name of the provider
|
1069
|
+
# to replace with; required.
|
1070
|
+
# @option parameters [String] :chdir The path of a working directory to
|
1071
|
+
# switch to before executing the given subcommand.
|
1072
|
+
# @option parameters [Boolean] :auto_approve (false) If +true+, skips
|
1073
|
+
# interactive approval.
|
1074
|
+
# @option parameters [String] :backup The path where Terraform should write
|
1075
|
+
# the backup for the state file; this can't be disabled; if not set,
|
1076
|
+
# Terraform will write it to the same path as the state file with a
|
1077
|
+
# ".backup" extension.
|
1078
|
+
# @option parameters [Boolean] :lock (true) When +true+, locks the state
|
1079
|
+
# file when locking is supported; when +false+, does not lock the state
|
1080
|
+
# file.
|
1081
|
+
# @option parameters [String] :lock_timeout ("0s") The duration to retry a
|
1082
|
+
# state lock.
|
1083
|
+
# @option parameters [String] :state The path to the state file to update;
|
1084
|
+
# defaults to the current workspace state.
|
1085
|
+
# @option parameters [Boolean] :ignore_remote_version (false) Whether or not
|
1086
|
+
# to continue even if remote and local Terraform versions are
|
1087
|
+
# incompatible; this may result in an unusable workspace, and should be
|
1088
|
+
# used with extreme caution.
|
1089
|
+
#
|
1090
|
+
# @example Basic Invocation
|
1091
|
+
# RubyTerraform.state_replace_provider(
|
1092
|
+
# from: 'hashicorp/aws',
|
1093
|
+
# to: 'registry.acme.corp/acme/aws')
|
1094
|
+
#
|
1095
|
+
def state_replace_provider(parameters = {})
|
1096
|
+
exec(RubyTerraform::Commands::StateReplaceProvider, parameters)
|
1097
|
+
end
|
1098
|
+
|
1099
|
+
# Invokes the +terraform state show+ command which shows the attributes of a
|
1100
|
+
# resource in the Terraform state.
|
1101
|
+
#
|
1102
|
+
# This command shows the attributes of a single resource in the Terraform
|
1103
|
+
# state. The +:address+ argument must be used to specify a single resource.
|
1104
|
+
# You can view the list of available resources with {#state_list}.
|
1105
|
+
#
|
1106
|
+
# @param parameters The parameters used to invoke the command
|
1107
|
+
# @option parameters [String] :address The module address or absolute
|
1108
|
+
# resource address of the resource instance to show; required.
|
1109
|
+
# @option parameters [String] :chdir The path of a working directory to
|
1110
|
+
# switch to before executing the given subcommand.
|
1111
|
+
#
|
1112
|
+
# @example Basic Invocation
|
1113
|
+
# RubyTerraform.state_show(
|
1114
|
+
# address: 'packet_device.worker')
|
1115
|
+
#
|
1116
|
+
def state_show(parameters = {})
|
1117
|
+
exec(RubyTerraform::Commands::StateShow, parameters)
|
1118
|
+
end
|
1119
|
+
|
1120
|
+
# Invokes the +terraform taint+ command which marks a resource instance as
|
1121
|
+
# not fully functional.
|
1122
|
+
#
|
1123
|
+
# Terraform uses the term "tainted" to describe a resource instance which
|
1124
|
+
# may not be fully functional, either because its creation partially failed
|
1125
|
+
# or because you've manually marked it as such using this command.
|
1126
|
+
#
|
1127
|
+
# This will not modify your infrastructure directly, but subsequent
|
1128
|
+
# Terraform plans will include actions to destroy the remote object and
|
1129
|
+
# create a new object to replace it.
|
1130
|
+
#
|
1131
|
+
# You can remove the "taint" state from a resource instance using the
|
1132
|
+
# {#untaint} command.
|
1133
|
+
#
|
1134
|
+
# The address is in the usual resource address syntax, such as:
|
1135
|
+
#
|
1136
|
+
# * +aws_instance.foo+
|
1137
|
+
# * <tt>aws_instance.bar[1]</tt>
|
1138
|
+
# * +module.foo.module.bar.aws_instance.baz+
|
1139
|
+
#
|
1140
|
+
# Use your shell's quoting or escaping syntax to ensure that the address
|
1141
|
+
# will reach Terraform correctly, without any special interpretation.
|
1142
|
+
#
|
1143
|
+
# @param parameters The parameters used to invoke the command
|
1144
|
+
# @option parameters [String] :address The module address or absolute
|
1145
|
+
# resource address of the resource instance to taint; required.
|
1146
|
+
# @option parameters [String] :chdir The path of a working directory to
|
1147
|
+
# switch to before executing the given subcommand.
|
1148
|
+
# @option parameters [Boolean] :allow_missing (false) If +true+, the command
|
1149
|
+
# will succeed (i.e., will not throw an
|
1150
|
+
# {RubyTerraform::Errors::ExecutionError}) even if the resource is
|
1151
|
+
# missing.
|
1152
|
+
# @option parameters [String] :backup The path to backup the existing state
|
1153
|
+
# file before modifying; defaults to the +:state_out+ path with
|
1154
|
+
# +".backup"+ extension; set +:no_backup+ to +true+ to skip backups
|
1155
|
+
# entirely.
|
1156
|
+
# @option parameters [Boolean] :lock (true) When +true+, locks the state
|
1157
|
+
# file when locking is supported; when +false+, does not lock the state
|
1158
|
+
# file.
|
1159
|
+
# @option parameters [String] :lock_timeout ("0s") The duration to retry a
|
1160
|
+
# state lock.
|
1161
|
+
# @option parameters [Boolean] :no_backup (false) When +true+, no backup
|
1162
|
+
# file will be written.
|
1163
|
+
# @option parameters [String] :state The path to the state file from which
|
1164
|
+
# to read state and in which to store state (unless +:state_out+ is
|
1165
|
+
# specified); defaults to +"terraform.tfstate"+.
|
1166
|
+
# @option parameters [String] :state_out The path to write state to that is
|
1167
|
+
# different than +:state+; this can be used to preserve the old state.
|
1168
|
+
# @option parameters [Boolean] :ignore_remote_version (false) Whether or not
|
1169
|
+
# to continue even if remote and local Terraform versions are
|
1170
|
+
# incompatible; this may result in an unusable workspace, and should be
|
1171
|
+
# used with extreme caution.
|
1172
|
+
#
|
1173
|
+
# @example Basic Invocation
|
1174
|
+
# RubyTerraform.taint(
|
1175
|
+
# address: 'aws_security_group.allow_all')
|
1176
|
+
#
|
1177
|
+
def taint(parameters = {})
|
1178
|
+
exec(RubyTerraform::Commands::Taint, parameters)
|
1179
|
+
end
|
1180
|
+
|
1181
|
+
# Invokes the +terraform untaint+ command which removes the 'tainted' state
|
1182
|
+
# from a resource instance.
|
1183
|
+
#
|
1184
|
+
# Terraform uses the term "tainted" to describe a resource instance
|
1185
|
+
# which may not be fully functional, either because its creation partially
|
1186
|
+
# failed or because you've manually marked it as such using the {#taint}
|
1187
|
+
# command.
|
1188
|
+
#
|
1189
|
+
# This command removes that state from a resource instance, causing
|
1190
|
+
# Terraform to see it as fully-functional and not in need of replacement.
|
1191
|
+
#
|
1192
|
+
# This will not modify your infrastructure directly. It only avoids
|
1193
|
+
# Terraform planning to replace a tainted instance in a future operation.
|
1194
|
+
#
|
1195
|
+
# @param parameters The parameters used to invoke the command
|
1196
|
+
# @option parameters [String] :name The name of the resource instance to
|
1197
|
+
# untaint; required.
|
1198
|
+
# @option parameters [String] :chdir The path of a working directory to
|
1199
|
+
# switch to before executing the given subcommand.
|
1200
|
+
# @option parameters [Boolean] :allow_missing (false) If +true+, the command
|
1201
|
+
# will succeed (i.e., will not throw an
|
1202
|
+
# {RubyTerraform::Errors::ExecutionError}) even if the resource is
|
1203
|
+
# missing.
|
1204
|
+
# @option parameters [String] :backup The path to backup the existing state
|
1205
|
+
# file before modifying; defaults to the +:state_out+ path with
|
1206
|
+
# +".backup"+ extension; set +:no_backup+ to +true+ to skip backups
|
1207
|
+
# entirely.
|
1208
|
+
# @option parameters [Boolean] :lock (true) When +true+, locks the state
|
1209
|
+
# file when locking is supported; when +false+, does not lock the state
|
1210
|
+
# file.
|
1211
|
+
# @option parameters [String] :lock_timeout The duration to retry a state
|
1212
|
+
# lock; defaults to +"0s"+.
|
1213
|
+
# @option parameters [Boolean] :no_backup (false) When +true+, no backup
|
1214
|
+
# file will be written.
|
1215
|
+
# @option parameters [Boolean] :no_color (false) Whether or not the output
|
1216
|
+
# from the command should be in color.
|
1217
|
+
# @option parameters [String] :state The path to the state file from which
|
1218
|
+
# to read state and in which to store state (unless +:state_out+ is
|
1219
|
+
# specified); defaults to +"terraform.tfstate"+.
|
1220
|
+
# @option parameters [String] :state_out The path to write state to that is
|
1221
|
+
# different than +:state+; this can be used to preserve the old state.
|
1222
|
+
# @option parameters [Boolean] :ignore_remote_version (false) Whether or not
|
1223
|
+
# to continue even if remote and local Terraform versions are
|
1224
|
+
# incompatible; this may result in an unusable workspace, and should be
|
1225
|
+
# used with extreme caution.
|
1226
|
+
#
|
1227
|
+
# @example Basic Invocation
|
1228
|
+
# RubyTerraform.untaint(
|
1229
|
+
# name: 'aws_security_group.allow_all')
|
1230
|
+
#
|
1231
|
+
def untaint(parameters = {})
|
1232
|
+
exec(RubyTerraform::Commands::Untaint, parameters)
|
1233
|
+
end
|
1234
|
+
|
1235
|
+
# Invokes the +terraform validate+ command which checks whether a
|
1236
|
+
# configuration is valid.
|
1237
|
+
#
|
1238
|
+
# Validates the configuration files in a directory, referring only to the
|
1239
|
+
# configuration and not accessing any remote services such as remote state,
|
1240
|
+
# provider APIs, etc.
|
1241
|
+
#
|
1242
|
+
# Validate runs checks that verify whether a configuration is syntactically
|
1243
|
+
# valid and internally consistent, regardless of any provided variables or
|
1244
|
+
# existing state. It is thus primarily useful for general verification of
|
1245
|
+
# reusable modules, including correctness of attribute names and value
|
1246
|
+
# types.
|
1247
|
+
#
|
1248
|
+
# It is safe to run this command automatically, for example as a post-save
|
1249
|
+
# check in a text editor or as a test step for a re-usable module in a CI
|
1250
|
+
# system.
|
1251
|
+
#
|
1252
|
+
# Validation requires an initialized working directory with any referenced
|
1253
|
+
# plugins and modules installed. To initialize a working directory for
|
1254
|
+
# validation without accessing any configured remote backend, use the
|
1255
|
+
# {#init} command passing +:backend+ as +false+.
|
1256
|
+
#
|
1257
|
+
# To verify configuration in the context of a particular run (a particular
|
1258
|
+
# target workspace, input variable values, etc), use the {#plan} command
|
1259
|
+
# instead, which includes an implied validation check.
|
1260
|
+
#
|
1261
|
+
# @param parameters The parameters used to invoke the command
|
1262
|
+
# @option parameters [String] :directory The path to a directory containing
|
1263
|
+
# terraform configuration (deprecated in terraform 0.14, removed in
|
1264
|
+
# terraform 0.15, use +:chdir+ instead).
|
1265
|
+
# @option parameters [String] :chdir The path of a working directory to
|
1266
|
+
# switch to before executing the given subcommand.
|
1267
|
+
# @option parameters [Boolean] :json (false) Whether or not to produce
|
1268
|
+
# output in a machine-readable JSON format, suitable for use in text
|
1269
|
+
# editor integrations and other automated systems; always disables color.
|
1270
|
+
# @option parameters [Boolean] :no_color (false) Whether or not the output
|
1271
|
+
# from the command should be in color.
|
1272
|
+
#
|
1273
|
+
# @example Basic Invocation
|
1274
|
+
# RubyTerraform.validate(
|
1275
|
+
# directory: 'infra/networking')
|
1276
|
+
#
|
1277
|
+
def validate(parameters = {})
|
1278
|
+
exec(RubyTerraform::Commands::Validate, parameters)
|
1279
|
+
end
|
1280
|
+
|
1281
|
+
# Invokes the +terraform workspace delete+ command which deletes a
|
1282
|
+
# workspace.
|
1283
|
+
#
|
1284
|
+
# @param parameters The parameters used to invoke the command
|
1285
|
+
# @option parameters [String] :name The name of the workspace to delete;
|
1286
|
+
# required.
|
1287
|
+
# @option parameters [String] :directory The path to a directory containing
|
1288
|
+
# terraform configuration (deprecated in terraform 0.14, removed in
|
1289
|
+
# terraform 0.15, use +:chdir+ instead).
|
1290
|
+
# @option parameters [String] :chdir The path of a working directory to
|
1291
|
+
# switch to before executing the given subcommand.
|
1292
|
+
# @option parameters [Boolean] :force (false) Whether or not to remove a
|
1293
|
+
# non-empty workspace; defaults to +false+.
|
1294
|
+
# @option parameters [Boolean] :lock (true) When +true+, locks the state
|
1295
|
+
# file when locking is supported; when +false+, does not lock the state
|
1296
|
+
# file.
|
1297
|
+
# @option parameters [String] :lock_timeout ("0s") The duration to retry a
|
1298
|
+
# state lock.
|
1299
|
+
#
|
1300
|
+
# @example Basic Invocation
|
1301
|
+
# RubyTerraform.workspace_delete(
|
1302
|
+
# name: 'example')
|
1303
|
+
#
|
1304
|
+
def workspace_delete(parameters = {})
|
1305
|
+
exec(RubyTerraform::Commands::WorkspaceDelete, parameters)
|
1306
|
+
end
|
1307
|
+
|
1308
|
+
# Invokes the +terraform workspace list+ command which lists workspaces.
|
1309
|
+
#
|
1310
|
+
# @param parameters The parameters used to invoke the command
|
1311
|
+
# @option parameters [String] :directory The path to a directory containing
|
1312
|
+
# terraform configuration (deprecated in terraform 0.14, removed in
|
1313
|
+
# terraform 0.15, use +:chdir+ instead).
|
1314
|
+
# @option parameters [String] :chdir the path of a working directory to
|
1315
|
+
# switch to before executing the given subcommand.
|
1316
|
+
#
|
1317
|
+
# @example Basic Invocation
|
1318
|
+
# RubyTerraform.workspace_list(
|
1319
|
+
# directory: 'infra/networking')
|
1320
|
+
#
|
1321
|
+
def workspace_list(parameters = {})
|
1322
|
+
exec(RubyTerraform::Commands::WorkspaceList, parameters)
|
1323
|
+
end
|
1324
|
+
|
1325
|
+
# Invokes the +terraform workspace new+ command which creates a new
|
1326
|
+
# workspace.
|
1327
|
+
#
|
1328
|
+
# @param parameters The parameters used to invoke the command
|
1329
|
+
# @option parameters [String] :name The name of the workspace to create;
|
1330
|
+
# required.
|
1331
|
+
# @option parameters [String] :directory The path to a directory containing
|
1332
|
+
# terraform configuration (deprecated in terraform 0.14, removed in
|
1333
|
+
# terraform 0.15, use +:chdir+ instead).
|
1334
|
+
# @option parameters [String] :chdir The path of a working directory to
|
1335
|
+
# switch to before executing the given subcommand.
|
1336
|
+
# @option parameters [Boolean] :lock (true) When +true+, locks the state
|
1337
|
+
# file when locking is supported; when +false+, does not lock the state
|
1338
|
+
# file.
|
1339
|
+
# @option parameters [String] :lock_timeout ("0s") The duration to retry a
|
1340
|
+
# state lock.
|
1341
|
+
# @option parameters [String] :state The path to a state file to copy into
|
1342
|
+
# the new workspace.
|
1343
|
+
#
|
1344
|
+
# @example Basic Invocation
|
1345
|
+
# RubyTerraform.workspace_new(
|
1346
|
+
# name: 'example')
|
1347
|
+
#
|
1348
|
+
def workspace_new(parameters = {})
|
1349
|
+
exec(RubyTerraform::Commands::WorkspaceNew, parameters)
|
1350
|
+
end
|
1351
|
+
|
1352
|
+
# Invokes the +terraform workspace select+ command which selects a
|
1353
|
+
# workspace.
|
1354
|
+
#
|
1355
|
+
# @param parameters The parameters used to invoke the command
|
1356
|
+
# @option parameters [String] :name The name of the workspace to select;
|
1357
|
+
# required.
|
1358
|
+
# @option parameters [String] :directory The path to a directory containing
|
1359
|
+
# terraform configuration (deprecated in terraform 0.14, removed in
|
1360
|
+
# terraform 0.15, use +:chdir+ instead).
|
1361
|
+
# @option parameters [String] :chdir The path of a working directory to
|
1362
|
+
# switch to before executing the given subcommand.
|
1363
|
+
#
|
1364
|
+
# @example BasicInvocation
|
1365
|
+
# RubyTerraform.workspace_select(
|
1366
|
+
# name: 'example')
|
1367
|
+
#
|
1368
|
+
def workspace_select(parameters = {})
|
1369
|
+
exec(RubyTerraform::Commands::WorkspaceSelect, parameters)
|
1370
|
+
end
|
1371
|
+
|
1372
|
+
# Invokes the +terraform workspace show+ command which shows the name of the
|
1373
|
+
# current workspace.
|
1374
|
+
#
|
1375
|
+
# @param parameters The parameters used to invoke the command
|
1376
|
+
# @option parameters [String] :chdir The path of a working directory to
|
1377
|
+
# switch to before executing the given subcommand.
|
1378
|
+
#
|
1379
|
+
# @example Basic Invocation
|
1380
|
+
# RubyTerraform.workspace_show
|
1381
|
+
#
|
1382
|
+
def workspace_show(parameters = {})
|
1383
|
+
exec(RubyTerraform::Commands::WorkspaceShow, parameters)
|
1384
|
+
end
|
1385
|
+
|
1386
|
+
# rubocop:disable Metrics/MethodLength
|
1387
|
+
|
1388
|
+
def workspace(parameters = {})
|
70
1389
|
case parameters[:operation]
|
71
1390
|
when nil, 'list'
|
72
1391
|
exec(RubyTerraform::Commands::WorkspaceList, parameters)
|
@@ -85,12 +1404,17 @@ module RubyTerraform
|
|
85
1404
|
end
|
86
1405
|
end
|
87
1406
|
|
1407
|
+
# rubocop:enable Metrics/MethodLength
|
1408
|
+
|
88
1409
|
private
|
89
1410
|
|
90
1411
|
def exec(command_class, parameters)
|
91
1412
|
command_class.new.execute(parameters)
|
92
1413
|
end
|
93
1414
|
end
|
1415
|
+
|
1416
|
+
# rubocop:enable Metrics/ModuleLength
|
1417
|
+
|
94
1418
|
extend ClassMethods
|
95
1419
|
|
96
1420
|
def self.included(other)
|