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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +23 -17
  3. data/README.md +148 -414
  4. data/Rakefile +25 -0
  5. data/lib/ruby_terraform.rb +1365 -41
  6. data/lib/ruby_terraform/commands.rb +0 -2
  7. data/lib/ruby_terraform/commands/apply.rb +78 -4
  8. data/lib/ruby_terraform/commands/base.rb +13 -2
  9. data/lib/ruby_terraform/commands/destroy.rb +71 -4
  10. data/lib/ruby_terraform/commands/force_unlock.rb +33 -3
  11. data/lib/ruby_terraform/commands/format.rb +45 -2
  12. data/lib/ruby_terraform/commands/get.rb +35 -2
  13. data/lib/ruby_terraform/commands/graph.rb +48 -2
  14. data/lib/ruby_terraform/commands/import.rb +98 -3
  15. data/lib/ruby_terraform/commands/init.rb +84 -3
  16. data/lib/ruby_terraform/commands/login.rb +26 -2
  17. data/lib/ruby_terraform/commands/logout.rb +23 -2
  18. data/lib/ruby_terraform/commands/output.rb +34 -2
  19. data/lib/ruby_terraform/commands/plan.rb +72 -3
  20. data/lib/ruby_terraform/commands/providers.rb +30 -2
  21. data/lib/ruby_terraform/commands/providers_lock.rb +72 -3
  22. data/lib/ruby_terraform/commands/providers_mirror.rb +44 -2
  23. data/lib/ruby_terraform/commands/providers_schema.rb +21 -2
  24. data/lib/ruby_terraform/commands/refresh.rb +70 -3
  25. data/lib/ruby_terraform/commands/show.rb +26 -3
  26. data/lib/ruby_terraform/commands/state_list.rb +54 -3
  27. data/lib/ruby_terraform/commands/state_move.rb +64 -6
  28. data/lib/ruby_terraform/commands/state_pull.rb +24 -2
  29. data/lib/ruby_terraform/commands/state_push.rb +49 -3
  30. data/lib/ruby_terraform/commands/state_remove.rb +55 -7
  31. data/lib/ruby_terraform/commands/state_replace_provider.rb +39 -6
  32. data/lib/ruby_terraform/commands/state_show.rb +26 -2
  33. data/lib/ruby_terraform/commands/taint.rb +63 -2
  34. data/lib/ruby_terraform/commands/untaint.rb +55 -2
  35. data/lib/ruby_terraform/commands/validate.rb +51 -6
  36. data/lib/ruby_terraform/commands/workspace_delete.rb +29 -7
  37. data/lib/ruby_terraform/commands/workspace_list.rb +21 -6
  38. data/lib/ruby_terraform/commands/workspace_new.rb +28 -7
  39. data/lib/ruby_terraform/commands/workspace_select.rb +23 -7
  40. data/lib/ruby_terraform/commands/workspace_show.rb +17 -2
  41. data/lib/ruby_terraform/options.rb +1 -1
  42. data/lib/ruby_terraform/options/definition.rb +6 -2
  43. data/lib/ruby_terraform/options/definitions.rb +12 -3
  44. data/lib/ruby_terraform/options/{common.rb → global.rb} +2 -1
  45. data/lib/ruby_terraform/options/types.rb +0 -1
  46. data/lib/ruby_terraform/options/types/flag.rb +8 -4
  47. data/lib/ruby_terraform/options/types/standard.rb +20 -6
  48. data/lib/ruby_terraform/version.rb +1 -1
  49. data/ruby_terraform.gemspec +3 -2
  50. metadata +25 -14
  51. data/lib/ruby_terraform/commands/clean.rb +0 -26
  52. data/lib/ruby_terraform/commands/remote_config.rb +0 -25
  53. data/lib/ruby_terraform/options/types/base.rb +0 -19
@@ -1,21 +1,45 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'base'
4
- require_relative '../options/common'
4
+ require_relative '../options/global'
5
5
 
6
6
  module RubyTerraform
7
7
  module Commands
8
+ # Wraps the +terraform state show+ command which shows the attributes of a
9
+ # resource in the Terraform state.
10
+ #
11
+ # This command shows the attributes of a single resource in the Terraform
12
+ # state. The +:address+ argument must be used to specify a single resource.
13
+ # You can view the list of available resources with {StateList}.
14
+ #
15
+ # For options accepted on construction, see {#initialize}.
16
+ #
17
+ # When executing an instance of {StateShow} via {#execute}, the following
18
+ # options are supported:
19
+ #
20
+ # * +:address+: the module address or absolute resource address of the
21
+ # resource instance to show; required.
22
+ # * +:chdir+: the path of a working directory to switch to before executing
23
+ # the given subcommand.
24
+ #
25
+ # @example Basic Invocation
26
+ # RubyTerraform::Commands::StateShow.new.execute(
27
+ # address: 'packet_device.worker')
28
+ #
8
29
  class StateShow < Base
9
- include RubyTerraform::Options::Common
30
+ include RubyTerraform::Options::Global
10
31
 
32
+ # @!visibility private
11
33
  def subcommands
12
34
  %w[state show]
13
35
  end
14
36
 
37
+ # @!visibility private
15
38
  def options
16
39
  %w[-state] + super
17
40
  end
18
41
 
42
+ # @!visibility private
19
43
  def arguments(parameters)
20
44
  [parameters[:address]]
21
45
  end
@@ -1,17 +1,76 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'base'
4
- require_relative '../options/common'
4
+ require_relative '../options/global'
5
5
 
6
6
  module RubyTerraform
7
7
  module Commands
8
+ # Wraps the +terraform taint+ command which marks a resource instance as not
9
+ # fully functional.
10
+ #
11
+ # Terraform uses the term "tainted" to describe a resource instance which
12
+ # may not be fully functional, either because its creation partially failed
13
+ # or because you've manually marked it as such using this command.
14
+ #
15
+ # This will not modify your infrastructure directly, but subsequent
16
+ # Terraform plans will include actions to destroy the remote object and
17
+ # create a new object to replace it.
18
+ #
19
+ # You can remove the "taint" state from a resource instance using the
20
+ # {Untaint} command.
21
+ #
22
+ # The address is in the usual resource address syntax, such as:
23
+ #
24
+ # * +aws_instance.foo+
25
+ # * <tt>aws_instance.bar[1]</tt>
26
+ # * +module.foo.module.bar.aws_instance.baz+
27
+ #
28
+ # Use your shell's quoting or escaping syntax to ensure that the address
29
+ # will reach Terraform correctly, without any special interpretation.
30
+ #
31
+ # For options accepted on construction, see {#initialize}.
32
+ #
33
+ # When executing an instance of {Taint} via {#execute}, the following
34
+ # options are supported:
35
+ #
36
+ # * +:address+: the module address or absolute resource address of the
37
+ # resource instance to taint; required.
38
+ # * +:chdir+: the path of a working directory to switch to before executing
39
+ # the given subcommand.
40
+ # * +:allow_missing+: if +true+, the command will succeed (i.e., will not
41
+ # throw an {RubyTerraform::Errors::ExecutionError}) even if the resource
42
+ # is missing; defaults to +false+.
43
+ # * +:backup+: the path to backup the existing state file before modifying;
44
+ # defaults to the +:state_out+ path with +".backup"+ extension; set
45
+ # +:no_backup+ to +true+ to skip backups entirely.
46
+ # * +:lock+: when +true+, locks the state file when locking is supported;
47
+ # when +false+, does not lock the state file; defaults to +true+.
48
+ # * +:lock_timeout+: the duration to retry a state lock; defaults to +"0s"+.
49
+ # * +:no_backup+: when +true+, no backup file will be written; defaults to
50
+ # +false+.
51
+ # * +:state+: the path to the state file from which to read state and in
52
+ # which to store state (unless +:state_out+ is specified); defaults to
53
+ # +"terraform.tfstate"+.
54
+ # * +:state_out+: the path to write state to that is different than
55
+ # +:state+; this can be used to preserve the old state.
56
+ # * +:ignore_remote_version+: whether or not to continue even if remote and
57
+ # local Terraform versions are incompatible; this may result in an
58
+ # unusable workspace, and should be used with extreme caution; defaults to
59
+ # +false+.
60
+ #
61
+ # @example Basic Invocation
62
+ # RubyTerraform::Commands::Taint.new.execute(
63
+ # address: 'aws_security_group.allow_all')
64
+ #
8
65
  class Taint < Base
9
- include RubyTerraform::Options::Common
66
+ include RubyTerraform::Options::Global
10
67
 
68
+ # @!visibility private
11
69
  def subcommands
12
70
  %w[taint]
13
71
  end
14
72
 
73
+ # @!visibility private
15
74
  def options
16
75
  %w[
17
76
  -allow-missing
@@ -24,10 +83,12 @@ module RubyTerraform
24
83
  ] + super
25
84
  end
26
85
 
86
+ # @!visibility private
27
87
  def arguments(parameters)
28
88
  [parameters[:address]]
29
89
  end
30
90
 
91
+ # @!visibility private
31
92
  def parameter_overrides(parameters)
32
93
  { backup: parameters[:no_backup] ? '-' : parameters[:backup] }
33
94
  end
@@ -1,17 +1,68 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'base'
4
- require_relative '../options/common'
4
+ require_relative '../options/global'
5
5
 
6
6
  module RubyTerraform
7
7
  module Commands
8
+ # Wraps the +terraform untaint+ command which removes the 'tainted' state
9
+ # from a resource instance.
10
+ #
11
+ # Terraform uses the term "tainted" to describe a resource instance
12
+ # which may not be fully functional, either because its creation partially
13
+ # failed or because you've manually marked it as such using the {Taint}
14
+ # command.
15
+ #
16
+ # This command removes that state from a resource instance, causing
17
+ # Terraform to see it as fully-functional and not in need of replacement.
18
+ #
19
+ # This will not modify your infrastructure directly. It only avoids
20
+ # Terraform planning to replace a tainted instance in a future operation.
21
+ #
22
+ # For options accepted on construction, see {#initialize}.
23
+ #
24
+ # When executing an instance of {Untaint} via {#execute}, the following
25
+ # options are supported:
26
+ #
27
+ # * +:name+: the name of the resource instance to untaint; required.
28
+ # * +:chdir+: the path of a working directory to switch to before executing
29
+ # the given subcommand.
30
+ # * +:allow_missing+: if +true+, the command will succeed (i.e., will not
31
+ # throw an {RubyTerraform::Errors::ExecutionError}) even if the resource
32
+ # is missing; defaults to +false+.
33
+ # * +:backup+: the path to backup the existing state file before modifying;
34
+ # defaults to the +:state_out+ path with +".backup"+ extension; set
35
+ # +:no_backup+ to +true+ to skip backups entirely.
36
+ # * +:lock+: when +true+, locks the state file when locking is supported;
37
+ # when +false+, does not lock the state file; defaults to +true+.
38
+ # * +:lock_timeout+: the duration to retry a state lock; defaults to +"0s"+.
39
+ # * +:no_backup+: when +true+, no backup file will be written; defaults to
40
+ # +false+.
41
+ # * +:no_color+: whether or not the output from the command should be in
42
+ # color; defaults to +false+.
43
+ # * +:state+: the path to the state file from which to read state and in
44
+ # which to store state (unless +:state_out+ is specified); defaults to
45
+ # +"terraform.tfstate"+.
46
+ # * +:state_out+: the path to write state to that is different than
47
+ # +:state+; this can be used to preserve the old state.
48
+ # * +:ignore_remote_version+: whether or not to continue even if remote and
49
+ # local Terraform versions are incompatible; this may result in an
50
+ # unusable workspace, and should be used with extreme caution; defaults to
51
+ # +false+.
52
+ #
53
+ # @example Basic Invocation
54
+ # RubyTerraform::Commands::Untaint.new.execute(
55
+ # name: 'aws_security_group.allow_all')
56
+ #
8
57
  class Untaint < Base
9
- include RubyTerraform::Options::Common
58
+ include RubyTerraform::Options::Global
10
59
 
60
+ # @!visibility private
11
61
  def subcommands
12
62
  %w[untaint]
13
63
  end
14
64
 
65
+ # @!visibility private
15
66
  def options
16
67
  %w[
17
68
  -allow-missing
@@ -25,10 +76,12 @@ module RubyTerraform
25
76
  ] + super
26
77
  end
27
78
 
79
+ # @!visibility private
28
80
  def arguments(parameters)
29
81
  [parameters[:name]]
30
82
  end
31
83
 
84
+ # @!visibility private
32
85
  def parameter_overrides(parameters)
33
86
  { backup: parameters[:no_backup] ? '-' : parameters[:backup] }
34
87
  end
@@ -1,17 +1,65 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'base'
4
- require_relative '../options/common'
4
+ require_relative '../options/global'
5
5
 
6
6
  module RubyTerraform
7
7
  module Commands
8
+ # Wraps the +terraform validate+ command which checks whether a
9
+ # configuration is valid.
10
+ #
11
+ # Validates the configuration files in a directory, referring only to the
12
+ # configuration and not accessing any remote services such as remote state,
13
+ # provider APIs, etc.
14
+ #
15
+ # Validate runs checks that verify whether a configuration is syntactically
16
+ # valid and internally consistent, regardless of any provided variables or
17
+ # existing state. It is thus primarily useful for general verification of
18
+ # reusable modules, including correctness of attribute names and value
19
+ # types.
20
+ #
21
+ # It is safe to run this command automatically, for example as a post-save
22
+ # check in a text editor or as a test step for a re-usable module in a CI
23
+ # system.
24
+ #
25
+ # Validation requires an initialized working directory with any referenced
26
+ # plugins and modules installed. To initialize a working directory for
27
+ # validation without accessing any configured remote backend, use the {Init}
28
+ # command passing +:backend+ as +false+.
29
+ #
30
+ # To verify configuration in the context of a particular run (a particular
31
+ # target workspace, input variable values, etc), use the {Plan} command
32
+ # instead, which includes an implied validation check.
33
+ #
34
+ # For options accepted on construction, see {#initialize}.
35
+ #
36
+ # When executing an instance of {Validate} via {#execute}, the following
37
+ # options are supported:
38
+ #
39
+ # * +:directory+: the path to a directory containing terraform configuration
40
+ # (deprecated in terraform 0.14, removed in terraform 0.15, use +:chdir+
41
+ # instead).
42
+ # * +:chdir+: the path of a working directory to switch to before executing
43
+ # the given subcommand.
44
+ # * +:json+: whether or not to produce output in a machine-readable JSON
45
+ # format, suitable for use in text editor integrations and other automated
46
+ # systems; always disables color; defaults to +false+.
47
+ # * +:no_color+: whether or not the output from the command should be in
48
+ # color; defaults to +false+.
49
+ #
50
+ # @example Basic Invocation
51
+ # RubyTerraform::Commands::Validate.new.execute(
52
+ # directory: 'infra/networking')
53
+ #
8
54
  class Validate < Base
9
- include RubyTerraform::Options::Common
55
+ include RubyTerraform::Options::Global
10
56
 
57
+ # @!visibility private
11
58
  def subcommands
12
59
  %w[validate]
13
60
  end
14
61
 
62
+ # @!visibility private
15
63
  def options
16
64
  %w[
17
65
  -json
@@ -19,13 +67,10 @@ module RubyTerraform
19
67
  ] + super
20
68
  end
21
69
 
70
+ # @!visibility private
22
71
  def arguments(parameters)
23
72
  [parameters[:directory]]
24
73
  end
25
-
26
- def parameter_defaults(_parameters)
27
- { vars: {}, var_files: [] }
28
- end
29
74
  end
30
75
  end
31
76
  end
@@ -1,17 +1,42 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'base'
4
- require_relative '../options/common'
4
+ require_relative '../options/global'
5
5
 
6
6
  module RubyTerraform
7
7
  module Commands
8
+ # Wraps the +terraform workspace delete+ command which deletes a workspace.
9
+ #
10
+ # For options accepted on construction, see {#initialize}.
11
+ #
12
+ # When executing an instance of {WorkspaceDelete} via {#execute}, the
13
+ # following options are supported:
14
+ #
15
+ # * +:name+: the name of the workspace to delete; required.
16
+ # * +:directory+: the path to a directory containing terraform configuration
17
+ # (deprecated in terraform 0.14, removed in terraform 0.15, use +:chdir+
18
+ # instead).
19
+ # * +:chdir+: the path of a working directory to switch to before executing
20
+ # the given subcommand.
21
+ # * +:force+: whether or not to remove a non-empty workspace; defaults to
22
+ # +false+.
23
+ # * +:lock+: when +true+, locks the state file when locking is supported;
24
+ # when +false+, does not lock the state file; defaults to +true+.
25
+ # * +:lock_timeout+: the duration to retry a state lock; defaults to +"0s"+.
26
+ #
27
+ # @example Basic Invocation
28
+ # RubyTerraform::Commands::WorkspaceDelete.new.execute(
29
+ # name: 'example')
30
+ #
8
31
  class WorkspaceDelete < Base
9
- include RubyTerraform::Options::Common
32
+ include RubyTerraform::Options::Global
10
33
 
34
+ # @!visibility private
11
35
  def subcommands
12
36
  %w[workspace delete]
13
37
  end
14
38
 
39
+ # @!visibility private
15
40
  def options
16
41
  %w[
17
42
  -force
@@ -20,12 +45,9 @@ module RubyTerraform
20
45
  ] + super
21
46
  end
22
47
 
48
+ # @!visibility private
23
49
  def arguments(parameters)
24
- [parameters[:workspace], parameters[:directory]]
25
- end
26
-
27
- def parameter_defaults(_parameters)
28
- { directory: nil }
50
+ [parameters[:name], parameters[:directory]]
29
51
  end
30
52
  end
31
53
  end
@@ -1,24 +1,39 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'base'
4
- require_relative '../options/common'
4
+ require_relative '../options/global'
5
5
 
6
6
  module RubyTerraform
7
7
  module Commands
8
+ # Wraps the +terraform workspace list+ command which lists workspaces.
9
+ #
10
+ # For options accepted on construction, see {#initialize}.
11
+ #
12
+ # When executing an instance of {WorkspaceList} via {#execute}, the
13
+ # following options are supported:
14
+ #
15
+ # * +:directory+: the path to a directory containing terraform configuration
16
+ # (deprecated in terraform 0.14, removed in terraform 0.15, use +:chdir+
17
+ # instead).
18
+ # * +:chdir+: the path of a working directory to switch to before executing
19
+ # the given subcommand.
20
+ #
21
+ # @example Basic Invocation
22
+ # RubyTerraform::Commands::WorkspaceList.new.execute(
23
+ # directory: 'infra/networking')
24
+ #
8
25
  class WorkspaceList < Base
9
- include RubyTerraform::Options::Common
26
+ include RubyTerraform::Options::Global
10
27
 
28
+ # @!visibility private
11
29
  def subcommands
12
30
  %w[workspace list]
13
31
  end
14
32
 
33
+ # @!visibility private
15
34
  def arguments(parameters)
16
35
  [parameters[:directory]]
17
36
  end
18
-
19
- def parameter_defaults(_parameters)
20
- { directory: nil }
21
- end
22
37
  end
23
38
  end
24
39
  end
@@ -1,17 +1,41 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'base'
4
- require_relative '../options/common'
4
+ require_relative '../options/global'
5
5
 
6
6
  module RubyTerraform
7
7
  module Commands
8
+ # Wraps the +terraform workspace new+ command which creates a new workspace.
9
+ #
10
+ # For options accepted on construction, see {#initialize}.
11
+ #
12
+ # When executing an instance of {WorkspaceNew} via {#execute}, the
13
+ # following options are supported:
14
+ #
15
+ # * +:name+: the name of the workspace to create; required.
16
+ # * +:directory+: the path to a directory containing terraform configuration
17
+ # (deprecated in terraform 0.14, removed in terraform 0.15, use +:chdir+
18
+ # instead).
19
+ # * +:chdir+: the path of a working directory to switch to before executing
20
+ # the given subcommand.
21
+ # * +:lock+: when +true+, locks the state file when locking is supported;
22
+ # when +false+, does not lock the state file; defaults to +true+.
23
+ # * +:lock_timeout+: the duration to retry a state lock; defaults to +"0s"+.
24
+ # * +:state+: the path to a state file to copy into the new workspace.
25
+ #
26
+ # @example Basic Invocation
27
+ # RubyTerraform::Commands::WorkspaceNew.new.execute(
28
+ # name: 'example')
29
+ #
8
30
  class WorkspaceNew < Base
9
- include RubyTerraform::Options::Common
31
+ include RubyTerraform::Options::Global
10
32
 
33
+ # @!visibility private
11
34
  def subcommands
12
35
  %w[workspace new]
13
36
  end
14
37
 
38
+ # @!visibility private
15
39
  def options
16
40
  %w[
17
41
  -lock
@@ -20,12 +44,9 @@ module RubyTerraform
20
44
  ] + super
21
45
  end
22
46
 
47
+ # @!visibility private
23
48
  def arguments(parameters)
24
- [parameters[:workspace], parameters[:directory]]
25
- end
26
-
27
- def parameter_defaults(_parameters)
28
- { directory: nil }
49
+ [parameters[:name], parameters[:directory]]
29
50
  end
30
51
  end
31
52
  end