ruby-terraform 0.65.0.pre.15 → 1.0.0.pre.1
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 +15 -15
- data/README.md +148 -397
- data/Rakefile +25 -0
- data/lib/ruby_terraform.rb +707 -45
- data/lib/ruby_terraform/commands.rb +0 -2
- data/lib/ruby_terraform/commands/apply.rb +7 -7
- data/lib/ruby_terraform/commands/base.rb +4 -1
- data/lib/ruby_terraform/commands/destroy.rb +6 -5
- data/lib/ruby_terraform/commands/force_unlock.rb +6 -4
- data/lib/ruby_terraform/commands/format.rb +8 -4
- data/lib/ruby_terraform/commands/get.rb +6 -4
- data/lib/ruby_terraform/commands/graph.rb +11 -3
- data/lib/ruby_terraform/commands/import.rb +8 -7
- data/lib/ruby_terraform/commands/init.rb +16 -6
- data/lib/ruby_terraform/commands/login.rb +2 -2
- data/lib/ruby_terraform/commands/logout.rb +2 -2
- data/lib/ruby_terraform/commands/output.rb +2 -2
- data/lib/ruby_terraform/commands/plan.rb +6 -3
- data/lib/ruby_terraform/commands/providers.rb +9 -3
- data/lib/ruby_terraform/commands/providers_lock.rb +10 -7
- data/lib/ruby_terraform/commands/providers_mirror.rb +3 -3
- 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 +3 -1
- data/lib/ruby_terraform/options/definitions.rb +12 -3
- data/lib/ruby_terraform/options/{common.rb → global.rb} +1 -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 +2 -2
- metadata +9 -12
- 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,6 +23,8 @@ module RubyTerraform
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
# rubocop:disable Metrics/ModuleLength
|
27
|
+
|
26
28
|
module ClassMethods
|
27
29
|
# Invokes the +terraform apply+ command which creates or updates
|
28
30
|
# infrastructure according to terraform configuration files in the provided
|
@@ -34,10 +36,11 @@ module RubyTerraform
|
|
34
36
|
# actions described in that plan without any confirmation prompt.
|
35
37
|
#
|
36
38
|
# @param parameters The parameters used to invoke the command
|
37
|
-
# @option parameters [String] :directory The directory containing
|
38
|
-
# configuration
|
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).
|
39
42
|
# @option parameters [String] :plan The path to a pre-computed plan to be
|
40
|
-
# applied
|
43
|
+
# applied.
|
41
44
|
# @option parameters [String] :chdir The path of a working directory to
|
42
45
|
# switch to before executing the given subcommand.
|
43
46
|
# @option parameters [Boolean] :auto_approve (false) If +true+, skips
|
@@ -101,8 +104,9 @@ module RubyTerraform
|
|
101
104
|
# infrastructure.
|
102
105
|
#
|
103
106
|
# @param parameters The parameters used to invoke the command
|
104
|
-
# @option parameters [String] :directory The directory containing
|
105
|
-
# configuration
|
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).
|
106
110
|
# @option parameters [String] :chdir The path of a working directory to
|
107
111
|
# switch to before executing the given subcommand.
|
108
112
|
# @option parameters [Boolean] :auto_approve (false) If +true+, skips
|
@@ -174,6 +178,9 @@ module RubyTerraform
|
|
174
178
|
# @param parameters The parameters used to invoke the command
|
175
179
|
# @option parameters [String] :lock_id The lock ID output when attempting an
|
176
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).
|
177
184
|
# @option parameters [String] :chdir The path of a working directory to
|
178
185
|
# switch to before executing the given subcommand.
|
179
186
|
# @option parameters [Boolean] :force (false) If +true+, does not ask for
|
@@ -199,8 +206,9 @@ module RubyTerraform
|
|
199
206
|
# terraform language native syntax; JSON is not supported.
|
200
207
|
#
|
201
208
|
# @param parameters The parameters used to invoke the command
|
202
|
-
# @option parameters [String] :directory The directory containing
|
203
|
-
# configuration.
|
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).
|
204
212
|
# @option parameters [String] :chdir The path of a working directory to
|
205
213
|
# switch to before executing the given subcommand.
|
206
214
|
# @option parameters [Boolean] :list (false) If +true+, lists files whose
|
@@ -212,6 +220,8 @@ module RubyTerraform
|
|
212
220
|
# @option parameters [Boolean] :check (false) If +true+, checks if the input
|
213
221
|
# is formatted; if any input is not properly formatted, an
|
214
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.
|
215
225
|
# @option parameters [Boolean] :recursive (false) If +true+, also processes
|
216
226
|
# files in subdirectories; by default, only the provided +:directory+ is
|
217
227
|
# processed.
|
@@ -223,6 +233,7 @@ module RubyTerraform
|
|
223
233
|
def format(parameters = {})
|
224
234
|
exec(RubyTerraform::Commands::Format, parameters)
|
225
235
|
end
|
236
|
+
alias fmt format
|
226
237
|
|
227
238
|
# Invokes the +terraform get+ command which downloads and installs modules
|
228
239
|
# needed for the given configuration.
|
@@ -236,8 +247,9 @@ module RubyTerraform
|
|
236
247
|
# separately.
|
237
248
|
#
|
238
249
|
# @param parameters The parameters used to invoke the command
|
239
|
-
# @option parameters [String] :directory The directory containing
|
240
|
-
# configuration
|
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).
|
241
253
|
# @option parameters [String] :chdir The path of a working directory to
|
242
254
|
# switch to before executing the given subcommand.
|
243
255
|
# @option parameters [Boolean] :update (false) If +true+, checks
|
@@ -269,6 +281,9 @@ module RubyTerraform
|
|
269
281
|
# passed as an argument.
|
270
282
|
#
|
271
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).
|
272
287
|
# @option parameters [String] :chdir The path of a working directory to
|
273
288
|
# switch to before executing the given subcommand.
|
274
289
|
# @option parameters [String] :plan Render the graph using the specified
|
@@ -317,10 +332,9 @@ module RubyTerraform
|
|
317
332
|
# being imported.
|
318
333
|
#
|
319
334
|
# @param parameters The parameters used to invoke the command
|
320
|
-
# @option parameters [String] :directory The path to a directory
|
321
|
-
# terraform configuration
|
322
|
-
#
|
323
|
-
# provided via the input prompts or env vars.
|
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).
|
324
338
|
# @option parameters [String] :address The address to import the resource
|
325
339
|
# to; required.
|
326
340
|
# @option parameters [String] :id The resource-specific ID identifying the
|
@@ -331,6 +345,8 @@ module RubyTerraform
|
|
331
345
|
# file before modifying; defaults to the +:state_out+ path with
|
332
346
|
# +".backup"+ extension; set +:no_backup+ to +true+ to skip backups
|
333
347
|
# entirely (legacy).
|
348
|
+
# @option parameters [Boolean] :allow_missing_config (false) Whether or not
|
349
|
+
# to allow import when no resource configuration block exists.
|
334
350
|
# @option parameters [Boolean] :input (true) When +false+, will not ask for
|
335
351
|
# input for variables not directly set.
|
336
352
|
# @option parameters [Boolean] :lock (true) When +true+, locks the state
|
@@ -397,7 +413,8 @@ module RubyTerraform
|
|
397
413
|
#
|
398
414
|
# @param parameters The parameters used to invoke the command
|
399
415
|
# @option parameters [String] :path The path to initialize; defaults to the
|
400
|
-
# current directory.
|
416
|
+
# current directory (deprecated in terraform 0.14, removed in terraform
|
417
|
+
# 0.15, use +:chdir+ instead).
|
401
418
|
# @option parameters [String] :chdir The path of a working directory to
|
402
419
|
# switch to before executing the given subcommand.
|
403
420
|
# @option parameters [Boolean] :backend (true) Whether or not to configure
|
@@ -424,7 +441,14 @@ module RubyTerraform
|
|
424
441
|
# from the command should be in color.
|
425
442
|
# @option parameters [String] :plugin_dir The path to a directory containing
|
426
443
|
# plugin binaries; this overrides all default search paths for plugins,
|
427
|
-
# and prevents the automatic installation of 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.
|
428
452
|
# @option parameters [Boolean] :reconfigure (false) If +true+, reconfigures
|
429
453
|
# the backend, ignoring any saved configuration.
|
430
454
|
# @option parameters [Boolean] :upgrade (false) If +true+, when installing
|
@@ -433,6 +457,8 @@ module RubyTerraform
|
|
433
457
|
# @option parameters [Boolean] :verify_plugins (true) Whether or not to
|
434
458
|
# verify plugins for this configuration (deprecated, removed in terraform
|
435
459
|
# 0.15).
|
460
|
+
# @option parameters [String] :lockfile Sets a dependency lockfile mode;
|
461
|
+
# currently only "readonly" is valid.
|
436
462
|
#
|
437
463
|
# @example Basic Invocation
|
438
464
|
# RubyTerraform.init(
|
@@ -520,8 +546,9 @@ module RubyTerraform
|
|
520
546
|
# the {#apply} command to perform exactly the actions described in the plan.
|
521
547
|
#
|
522
548
|
# @param parameters The parameters used to invoke the command
|
523
|
-
# @option parameters [String] :plan The path to
|
524
|
-
#
|
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).
|
525
552
|
# @option parameters [String] :chdir The path of a working directory to
|
526
553
|
# switch to before executing the given subcommand.
|
527
554
|
# @option parameters [Boolean] :compact_warnings (false) When +true+, if
|
@@ -587,6 +614,9 @@ module RubyTerraform
|
|
587
614
|
# plugins are needed and why particular versions are selected.
|
588
615
|
#
|
589
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).
|
590
620
|
# @option parameters [String] :chdir The path of a working directory to
|
591
621
|
# switch to before executing the given subcommand.
|
592
622
|
#
|
@@ -619,6 +649,13 @@ module RubyTerraform
|
|
619
649
|
# more provider source addresses on the command line.
|
620
650
|
#
|
621
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.
|
622
659
|
# @option parameters [String] :providers The provider source addresses for
|
623
660
|
# which the lock file should be updated.
|
624
661
|
# @option parameters [String] :chdir The path of a working directory to
|
@@ -654,7 +691,7 @@ module RubyTerraform
|
|
654
691
|
# RubyTerraform.providers_lock(
|
655
692
|
# fs_mirror: "/usr/local/terraform/providers",
|
656
693
|
# platforms: ["windows_amd64", "darwin_amd64", "linux_amd64"],
|
657
|
-
#
|
694
|
+
# provider: "tf.example.com/ourcompany/ourplatform")
|
658
695
|
#
|
659
696
|
def providers_lock(parameters = {})
|
660
697
|
exec(RubyTerraform::Commands::ProvidersLock, parameters)
|
@@ -693,7 +730,7 @@ module RubyTerraform
|
|
693
730
|
# to Terraform.
|
694
731
|
#
|
695
732
|
# @example Basic Invocation
|
696
|
-
# RubyTerraform.
|
733
|
+
# RubyTerraform.providers_mirror(
|
697
734
|
# directory: './plugins',
|
698
735
|
# platforms: ["windows_amd64", "darwin_amd64", "linux_amd64"])
|
699
736
|
#
|
@@ -701,34 +738,654 @@ module RubyTerraform
|
|
701
738
|
exec(RubyTerraform::Commands::ProvidersMirror, parameters)
|
702
739
|
end
|
703
740
|
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
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)
|
1010
|
+
end
|
1011
|
+
|
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)
|
729
1179
|
end
|
730
1180
|
|
731
|
-
|
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 = {})
|
732
1389
|
case parameters[:operation]
|
733
1390
|
when nil, 'list'
|
734
1391
|
exec(RubyTerraform::Commands::WorkspaceList, parameters)
|
@@ -747,12 +1404,17 @@ module RubyTerraform
|
|
747
1404
|
end
|
748
1405
|
end
|
749
1406
|
|
1407
|
+
# rubocop:enable Metrics/MethodLength
|
1408
|
+
|
750
1409
|
private
|
751
1410
|
|
752
1411
|
def exec(command_class, parameters)
|
753
1412
|
command_class.new.execute(parameters)
|
754
1413
|
end
|
755
1414
|
end
|
1415
|
+
|
1416
|
+
# rubocop:enable Metrics/ModuleLength
|
1417
|
+
|
756
1418
|
extend ClassMethods
|
757
1419
|
|
758
1420
|
def self.included(other)
|