ruby-terraform 0.65.0.pre.14 → 0.65.0.pre.15
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 +1 -1
- data/README.md +2 -19
- data/lib/ruby_terraform.rb +606 -16
- data/lib/ruby_terraform/commands/apply.rb +2 -2
- data/lib/ruby_terraform/commands/destroy.rb +67 -1
- data/lib/ruby_terraform/commands/force_unlock.rb +28 -0
- data/lib/ruby_terraform/commands/format.rb +39 -0
- data/lib/ruby_terraform/commands/get.rb +31 -0
- data/lib/ruby_terraform/commands/graph.rb +38 -0
- data/lib/ruby_terraform/commands/import.rb +95 -1
- data/lib/ruby_terraform/commands/init.rb +72 -1
- data/lib/ruby_terraform/commands/login.rb +24 -0
- data/lib/ruby_terraform/commands/logout.rb +21 -0
- data/lib/ruby_terraform/commands/output.rb +32 -0
- data/lib/ruby_terraform/commands/plan.rb +67 -1
- data/lib/ruby_terraform/commands/providers.rb +22 -0
- data/lib/ruby_terraform/commands/providers_lock.rb +66 -0
- data/lib/ruby_terraform/commands/providers_mirror.rb +42 -0
- data/lib/ruby_terraform/version.rb +1 -1
- metadata +2 -2
@@ -5,14 +5,81 @@ require_relative '../options/common'
|
|
5
5
|
|
6
6
|
module RubyTerraform
|
7
7
|
module Commands
|
8
|
+
# Wraps the +terraform init+ command which initializes a new or existing
|
9
|
+
# Terraform working directory by creating initial files, loading any remote
|
10
|
+
# state, downloading modules, etc.
|
11
|
+
#
|
12
|
+
# This is the first command that should be run for any new or existing
|
13
|
+
# Terraform configuration per machine. This sets up all the local data
|
14
|
+
# necessary to run Terraform that is typically not committed to version
|
15
|
+
# control.
|
16
|
+
#
|
17
|
+
# This command is always safe to run multiple times. Though subsequent runs
|
18
|
+
# may give errors, this command will never delete your configuration or
|
19
|
+
# state. Even so, if you have important information, please back it up prior
|
20
|
+
# to running this command, just in case.
|
21
|
+
#
|
22
|
+
# For options accepted on construction, see {#initialize}.
|
23
|
+
#
|
24
|
+
# When executing an instance of {Init} via {#execute}, the following
|
25
|
+
# options are supported:
|
26
|
+
#
|
27
|
+
# * +:path+: the path to initialize; defaults to the current directory.
|
28
|
+
# * +:chdir+: the path of a working directory to switch to before executing
|
29
|
+
# the given subcommand.
|
30
|
+
# * +:backend+: whether or not to configure the backend for this
|
31
|
+
# configuration; defaults to +true+.
|
32
|
+
# * +:backend_config+: a map of backend specific configuration parameters.
|
33
|
+
# * +:force_copy+: if +true+, suppresses prompts about copying state data;
|
34
|
+
# this is equivalent to providing a "yes" to all confirmation prompts;
|
35
|
+
# defaults to +false+.
|
36
|
+
# * +:from_module+: copies the contents of the given module into the target
|
37
|
+
# directory before initialization.
|
38
|
+
# * +:get+: whether or not to download any modules for this configuration;
|
39
|
+
# defaults to +true+.
|
40
|
+
# * +:get_plugins+: whether or not to install plugins for this
|
41
|
+
# configuration; defaults to +true+ (deprecated, removed in terraform
|
42
|
+
# 0.15).
|
43
|
+
# * +:input+: when +false+, will not ask for input for variables not
|
44
|
+
# directly set; defaults to +true+.
|
45
|
+
# * +:lock+: when +true+, locks the state file when locking is supported;
|
46
|
+
# when +false+, does not lock the state file; defaults to +true+
|
47
|
+
# (deprecated, removed in terraform 0.15).
|
48
|
+
# * +:lock_timeout+: the duration to retry a state lock; defaults to +"0s"+;
|
49
|
+
# (deprecated, removed in terraform 0.15).
|
50
|
+
# * +:no_color+: whether or not the output from the command should be in
|
51
|
+
# color; defaults to +false+.
|
52
|
+
# * +:plugin_dir+: the path to a directory containing plugin binaries; this
|
53
|
+
# overrides all default search paths for plugins, and prevents the
|
54
|
+
# automatic installation of plugins.
|
55
|
+
# * +:reconfigure+: if +true+, reconfigures the backend, ignoring any saved
|
56
|
+
# configuration; defaults to +false+.
|
57
|
+
# * +:upgrade+: if +true+, when installing modules or plugins, ignores
|
58
|
+
# previously-downloaded objects and installs the latest version allowed
|
59
|
+
# within configured constraints; defaults to +false+.
|
60
|
+
# * +:verify_plugins+: whether or not to verify plugins for this
|
61
|
+
# configuration; defaults to +true+ (deprecated, removed in terraform
|
62
|
+
# 0.15).
|
63
|
+
#
|
64
|
+
# @example Basic Invocation
|
65
|
+
# RubyTerraform::Commands::Init.new.execute(
|
66
|
+
# from_module: 'some/module/path',
|
67
|
+
# path: 'infra/module')
|
68
|
+
#
|
8
69
|
class Init < Base
|
9
70
|
include RubyTerraform::Options::Common
|
10
71
|
|
72
|
+
# @!visibility private
|
11
73
|
def subcommands
|
12
74
|
%w[init]
|
13
75
|
end
|
14
76
|
|
15
|
-
|
77
|
+
# rubocop:disable Metrics/MethodLength
|
78
|
+
|
79
|
+
# @!visibility private
|
80
|
+
# @todo Add lockfile option.
|
81
|
+
# @todo Make plugin_dir option plural
|
82
|
+
def options
|
16
83
|
%w[
|
17
84
|
-backend
|
18
85
|
-backend-config
|
@@ -31,10 +98,14 @@ module RubyTerraform
|
|
31
98
|
] + super
|
32
99
|
end
|
33
100
|
|
101
|
+
# rubocop:enable Metrics/MethodLength
|
102
|
+
|
103
|
+
# @!visibility private
|
34
104
|
def arguments(parameters)
|
35
105
|
[parameters[:path]]
|
36
106
|
end
|
37
107
|
|
108
|
+
# @!visibility private
|
38
109
|
def parameter_defaults(_parameters)
|
39
110
|
{ backend_config: {} }
|
40
111
|
end
|
@@ -5,13 +5,37 @@ require_relative '../options/common'
|
|
5
5
|
|
6
6
|
module RubyTerraform
|
7
7
|
module Commands
|
8
|
+
# Wraps the +terraform login+ command which retrieves an authentication
|
9
|
+
# token for the given hostname, if it supports automatic login, and saves it
|
10
|
+
# in a credentials file in your home directory.
|
11
|
+
#
|
12
|
+
# If no hostname is provided, the default hostname is app.terraform.io, to
|
13
|
+
# log in to Terraform Cloud.
|
14
|
+
#
|
15
|
+
# If not overridden by credentials helper settings in the CLI configuration,
|
16
|
+
# the credentials will be written to the following local file:
|
17
|
+
# ~/.terraform.d/credentials.tfrc.json
|
18
|
+
#
|
19
|
+
# For options accepted on construction, see {#initialize}.
|
20
|
+
#
|
21
|
+
# When executing an instance of {Login} via {#execute}, the following
|
22
|
+
# options are supported:
|
23
|
+
#
|
24
|
+
# * +:chdir+: the path of a working directory to switch to before executing
|
25
|
+
# the given subcommand.
|
26
|
+
#
|
27
|
+
# @example Basic Invocation
|
28
|
+
# RubyTerraform::Commands::Login.new.execute
|
29
|
+
#
|
8
30
|
class Login < Base
|
9
31
|
include RubyTerraform::Options::Common
|
10
32
|
|
33
|
+
# @!visibility private
|
11
34
|
def subcommands
|
12
35
|
%w[login]
|
13
36
|
end
|
14
37
|
|
38
|
+
# @!visibility private
|
15
39
|
def arguments(parameters)
|
16
40
|
[parameters[:hostname]]
|
17
41
|
end
|
@@ -5,13 +5,34 @@ require_relative '../options/common'
|
|
5
5
|
|
6
6
|
module RubyTerraform
|
7
7
|
module Commands
|
8
|
+
# Wraps the +terraform logout+ command which removes locally-stored
|
9
|
+
# credentials for specified hostname.
|
10
|
+
#
|
11
|
+
# Note: the API token is only removed from local storage, not destroyed on
|
12
|
+
# the remote server, so it will remain valid until manually revoked.
|
13
|
+
#
|
14
|
+
# If no hostname is provided, the default hostname is app.terraform.io.
|
15
|
+
#
|
16
|
+
# For options accepted on construction, see {#initialize}.
|
17
|
+
#
|
18
|
+
# When executing an instance of {Logout} via {#execute}, the following
|
19
|
+
# options are supported:
|
20
|
+
#
|
21
|
+
# * +:chdir+: the path of a working directory to switch to before executing
|
22
|
+
# the given subcommand.
|
23
|
+
#
|
24
|
+
# @example Basic Invocation
|
25
|
+
# RubyTerraform::Commands::Logout.new.execute
|
26
|
+
#
|
8
27
|
class Logout < Base
|
9
28
|
include RubyTerraform::Options::Common
|
10
29
|
|
30
|
+
# @!visibility private
|
11
31
|
def subcommands
|
12
32
|
%w[logout]
|
13
33
|
end
|
14
34
|
|
35
|
+
# @!visibility private
|
15
36
|
def arguments(parameters)
|
16
37
|
[parameters[:hostname]]
|
17
38
|
end
|
@@ -6,17 +6,47 @@ require_relative '../options/common'
|
|
6
6
|
|
7
7
|
module RubyTerraform
|
8
8
|
module Commands
|
9
|
+
# Wraps the +terraform output+ command which reads an output variable from a
|
10
|
+
# Terraform state file and prints the value. With no additional arguments,
|
11
|
+
# output will display all the outputs for the root module. If +:name+ is not
|
12
|
+
# specified, all outputs are printed.
|
13
|
+
#
|
14
|
+
# For options accepted on construction, see {#initialize}.
|
15
|
+
#
|
16
|
+
# When executing an instance of {Output} via {#execute}, the following
|
17
|
+
# options are supported:
|
18
|
+
#
|
19
|
+
# * +:name+: The name of the output to read.
|
20
|
+
# * +:chdir+: the path of a working directory to switch to before executing
|
21
|
+
# the given subcommand.
|
22
|
+
# * +:state+: the path to the state file to read; defaults to
|
23
|
+
# +"terraform.tfstate"+.
|
24
|
+
# * +:no_color+: whether or not the output from the command should be in
|
25
|
+
# color; defaults to +false+.
|
26
|
+
# * +:json+: If +true+, machine readable output will be printed in JSON
|
27
|
+
# format; defaults to +false+.
|
28
|
+
# * +:raw+: If +true+, for value types that can be automatically converted
|
29
|
+
# to a string, will print the raw string directly, rather than a
|
30
|
+
# human-oriented representation of the value.
|
31
|
+
#
|
32
|
+
# @example Basic Invocation
|
33
|
+
# RubyTerraform::Commands::Output.new.execute(
|
34
|
+
# name: 'vpc_id')
|
35
|
+
#
|
9
36
|
class Output < Base
|
10
37
|
include RubyTerraform::Options::Common
|
11
38
|
|
39
|
+
# @!visibility private
|
12
40
|
def stdout
|
13
41
|
@stdout.respond_to?(:string) ? @stdout : (@stdout = StringIO.new)
|
14
42
|
end
|
15
43
|
|
44
|
+
# @!visibility private
|
16
45
|
def subcommands
|
17
46
|
%w[output]
|
18
47
|
end
|
19
48
|
|
49
|
+
# @!visibility private
|
20
50
|
def options
|
21
51
|
%w[
|
22
52
|
-json
|
@@ -26,10 +56,12 @@ module RubyTerraform
|
|
26
56
|
] + super
|
27
57
|
end
|
28
58
|
|
59
|
+
# @!visibility private
|
29
60
|
def arguments(parameters)
|
30
61
|
[parameters[:name]]
|
31
62
|
end
|
32
63
|
|
64
|
+
# @!visibility private
|
33
65
|
def do_after(parameters)
|
34
66
|
result = stdout.string
|
35
67
|
parameters[:name] ? result.chomp : result
|
@@ -5,14 +5,76 @@ require_relative '../options/common'
|
|
5
5
|
|
6
6
|
module RubyTerraform
|
7
7
|
module Commands
|
8
|
+
# Wraps the +terraform plan+ command which generates a speculative execution
|
9
|
+
# plan, showing what actions Terraform would take to apply the current
|
10
|
+
# configuration. This command will not actually perform the planned actions.
|
11
|
+
#
|
12
|
+
# You can optionally save the plan to a file, which you can then pass to
|
13
|
+
# the {Apply} command to perform exactly the actions described in the plan.
|
14
|
+
#
|
15
|
+
# For options accepted on construction, see {#initialize}.
|
16
|
+
#
|
17
|
+
# When executing an instance of {Plan} via {#execute}, the following
|
18
|
+
# options are supported:
|
19
|
+
#
|
20
|
+
# * +:plan+: the path to output the plan if it should be saved to a file.
|
21
|
+
# * +:chdir+: the path of a working directory to switch to before executing
|
22
|
+
# the given subcommand.
|
23
|
+
# * +:compact_warnings+: when +true+, if terraform produces any warnings
|
24
|
+
# that are not accompanied by errors, they are shown in a more compact
|
25
|
+
# form that includes only the summary messages; defaults to +false+.
|
26
|
+
# * +:destroy+: when +true+, a plan will be generated to destroy all
|
27
|
+
# resources managed by the given configuration and state; defaults to
|
28
|
+
# +false+.
|
29
|
+
# * +:detailed_exitcode+: whether or not to return detailed exit codes when
|
30
|
+
# the command exits; this will change the meaning of exit codes to:
|
31
|
+
# 0 - Succeeded, diff is empty (no changes); 1 - Errored; 2 - Succeeded,
|
32
|
+
# there is a diff; defaults to +false+.
|
33
|
+
# * +:input+: when +false+, will not ask for input for variables not
|
34
|
+
# directly set; defaults to +true+.
|
35
|
+
# * +:lock+: when +true+, locks the state file when locking is supported;
|
36
|
+
# when +false+, does not lock the state file; defaults to +true+.
|
37
|
+
# * +:lock_timeout+: the duration to retry a state lock; defaults to +"0s"+.
|
38
|
+
# * +:no_color+: whether or not the output from the command should be in
|
39
|
+
# color; defaults to +false+.
|
40
|
+
# * +:parallelism+: the number of parallel resource operations; defaults to
|
41
|
+
# +10+.
|
42
|
+
# * +:refresh+: when +true+, updates state prior to checking for
|
43
|
+
# differences; when +false+ uses locally available state; defaults to
|
44
|
+
# +true+; this has no effect when +:plan+ is provided.
|
45
|
+
# * +:state+: the path to the state file from which to read state and in
|
46
|
+
# which to store state (unless +:state_out+ is specified); defaults to
|
47
|
+
# +"terraform.tfstate"+.
|
48
|
+
# * +:target+: the address of a resource to target; if both +:target+ and
|
49
|
+
# +:targets+ are provided, all targets will be passed to terraform.
|
50
|
+
# * +:targets+: an array of resource addresses to target; if both +:target+
|
51
|
+
# and +:targets+ are provided, all targets will be passed to terraform.
|
52
|
+
# * +:vars+: a map of variables to be passed to the terraform configuration.
|
53
|
+
# * +:var_file+: the path to a terraform var file; if both +:var_file+ and
|
54
|
+
# +:var_files+ are provided, all var files will be passed to terraform.
|
55
|
+
# * +:var_files+: an array of paths to terraform var files; if both
|
56
|
+
# +:var_file+ and +:var_files+ are provided, all var files will be passed
|
57
|
+
# to terraform.
|
58
|
+
#
|
59
|
+
# @example Basic Invocation
|
60
|
+
# RubyTerraform::Commands::Plan.new.execute(
|
61
|
+
# directory: 'infra/networking',
|
62
|
+
# vars: {
|
63
|
+
# region: 'eu-central'
|
64
|
+
# })
|
65
|
+
#
|
8
66
|
class Plan < Base
|
9
67
|
include RubyTerraform::Options::Common
|
10
68
|
|
69
|
+
# @!visibility private
|
11
70
|
def subcommands
|
12
71
|
%w[plan]
|
13
72
|
end
|
14
73
|
|
15
|
-
|
74
|
+
# rubocop:disable Metrics/MethodLength
|
75
|
+
|
76
|
+
# @!visibility private
|
77
|
+
def options
|
16
78
|
%w[
|
17
79
|
-compact-warnings
|
18
80
|
-destroy
|
@@ -31,10 +93,14 @@ module RubyTerraform
|
|
31
93
|
] + super
|
32
94
|
end
|
33
95
|
|
96
|
+
# rubocop:enable Metrics/MethodLength
|
97
|
+
|
98
|
+
# @!visibility private
|
34
99
|
def arguments(parameters)
|
35
100
|
[parameters[:directory]]
|
36
101
|
end
|
37
102
|
|
103
|
+
# @!visibility private
|
38
104
|
def parameter_defaults(_parameters)
|
39
105
|
{ vars: {}, var_files: [], targets: [] }
|
40
106
|
end
|
@@ -5,12 +5,34 @@ require_relative '../options/common'
|
|
5
5
|
|
6
6
|
module RubyTerraform
|
7
7
|
module Commands
|
8
|
+
# Wraps the +terraform providers+ command which prints out a tree of modules
|
9
|
+
# in the referenced configuration annotated with their provider
|
10
|
+
# requirements.
|
11
|
+
#
|
12
|
+
# This provides an overview of all of the provider requirements across all
|
13
|
+
# referenced modules, as an aid to understanding why particular provider
|
14
|
+
# plugins are needed and why particular versions are selected.
|
15
|
+
#
|
16
|
+
# For options accepted on construction, see {#initialize}.
|
17
|
+
#
|
18
|
+
# When executing an instance of {Plan} via {#execute}, the following
|
19
|
+
# options are supported:
|
20
|
+
#
|
21
|
+
# * +:chdir+: the path of a working directory to switch to before executing
|
22
|
+
# the given subcommand.
|
23
|
+
#
|
24
|
+
# @example Basic Invocation
|
25
|
+
# RubyTerraform::Commands::Providers.new.execute
|
26
|
+
#
|
8
27
|
class Providers < Base
|
9
28
|
include RubyTerraform::Options::Common
|
10
29
|
|
30
|
+
# @!visibility private
|
11
31
|
def subcommands
|
12
32
|
%w[providers]
|
13
33
|
end
|
34
|
+
|
35
|
+
# @todo Add directory argument
|
14
36
|
end
|
15
37
|
end
|
16
38
|
end
|
@@ -5,13 +5,77 @@ require_relative '../options/common'
|
|
5
5
|
|
6
6
|
module RubyTerraform
|
7
7
|
module Commands
|
8
|
+
# Wraps the +terraform providers lock+ command which writes out dependency
|
9
|
+
# locks for the configured providers.
|
10
|
+
#
|
11
|
+
# Normally the dependency lock file (.terraform.lock.hcl) is updated
|
12
|
+
# automatically by "terraform init", but the information available to the
|
13
|
+
# normal provider installer can be constrained when you're installing
|
14
|
+
# providers from filesystem or network mirrors, and so the generated lock
|
15
|
+
# file can end up incomplete.
|
16
|
+
#
|
17
|
+
# The "providers lock" subcommand addresses that by updating the lock file
|
18
|
+
# based on the official packages available in the origin registry, ignoring
|
19
|
+
# the currently-configured installation strategy.
|
20
|
+
#
|
21
|
+
# After this command succeeds, the lock file will contain suitable checksums
|
22
|
+
# to allow installation of the providers needed by the current configuration
|
23
|
+
# on all of the selected platforms.
|
24
|
+
#
|
25
|
+
# By default this command updates the lock file for every provider declared
|
26
|
+
# in the configuration. You can override that behavior by providing one or
|
27
|
+
# more provider source addresses on the command line.
|
28
|
+
#
|
29
|
+
# For options accepted on construction, see {#initialize}.
|
30
|
+
#
|
31
|
+
# When executing an instance of {ProvidersLock} via {#execute}, the
|
32
|
+
# following options are supported:
|
33
|
+
#
|
34
|
+
# * +:providers+: the provider source addresses for which the lock file
|
35
|
+
# should be updated.
|
36
|
+
# * +:chdir+: the path of a working directory to switch to before executing
|
37
|
+
# the given subcommand.
|
38
|
+
# * +:fs_mirror+: if provided, consults the given filesystem mirror
|
39
|
+
# directory instead of the origin registry for each of the given
|
40
|
+
# providers; this would be necessary to generate lock file entries for
|
41
|
+
# a provider that is available only via a mirror, and not published in an
|
42
|
+
# upstream registry; in this case, the set of valid checksums will be
|
43
|
+
# limited only to what Terraform can learn from the data in the mirror
|
44
|
+
# directory.
|
45
|
+
# * +:net_mirror+: if provided, consults the given network mirror (given as
|
46
|
+
# a base URL) instead of the origin registry for each of the given
|
47
|
+
# providers; this would be necessary to generate lock file entries for a
|
48
|
+
# provider that is available only via a mirror, and not published in an
|
49
|
+
# upstream registry; in this case, the set of valid checksums will be
|
50
|
+
# limited only to what Terraform can learn from the data in the mirror
|
51
|
+
# indices.
|
52
|
+
# * +:platform+: the target platform to request package checksums for; by
|
53
|
+
# default Terraform will request package checksums suitable only for the
|
54
|
+
# platform where you run this command; target names consist of an
|
55
|
+
# operating system and a CPU architecture; for example, "linux_amd64"
|
56
|
+
# selects the Linux operating system running on an AMD64 or x86_64 CPU;
|
57
|
+
# each provider is available only for a limited set of target platforms;
|
58
|
+
# if both +:platform+ and +:platforms+ are provided, all platforms will be
|
59
|
+
# passed to Terraform.
|
60
|
+
# * +:platforms+: an array of target platforms to request package checksums
|
61
|
+
# for; see +:platform+ for more details; if both +:platform+ and
|
62
|
+
# +:platforms+ are provided, all platforms will be passed to Terraform.
|
63
|
+
#
|
64
|
+
# @example Basic Invocation
|
65
|
+
# RubyTerraform::Commands::ProvidersLock.new.execute(
|
66
|
+
# fs_mirror: "/usr/local/terraform/providers",
|
67
|
+
# platforms: ["windows_amd64", "darwin_amd64", "linux_amd64"],
|
68
|
+
# providers: "tf.example.com/ourcompany/ourplatform")
|
69
|
+
#
|
8
70
|
class ProvidersLock < Base
|
9
71
|
include RubyTerraform::Options::Common
|
10
72
|
|
73
|
+
# @!visibility private
|
11
74
|
def subcommands
|
12
75
|
%w[providers lock]
|
13
76
|
end
|
14
77
|
|
78
|
+
# @!visibility private
|
15
79
|
def options
|
16
80
|
%w[
|
17
81
|
-fs-mirror
|
@@ -20,6 +84,8 @@ module RubyTerraform
|
|
20
84
|
] + super
|
21
85
|
end
|
22
86
|
|
87
|
+
# @!visibility private
|
88
|
+
# @todo Flatten arguments array to allow array of providers.
|
23
89
|
def arguments(parameters)
|
24
90
|
[parameters[:providers]]
|
25
91
|
end
|