ruby-terraform 0.54.0 → 0.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2385ec22d2a91817d5ab78b2a8564b014e0d3c60598766dce4d94996f9e5cabe
4
- data.tar.gz: e0756e8af43ca107aa9ea094a067b9dec50ac947262b3cb30dfe485f8d9cabf3
3
+ metadata.gz: a169d8302479fd0aa777ea6f3a7f2fe5243e49fd54a1d45548be4fae4937c1cb
4
+ data.tar.gz: ee71f858ae3783e6d0bf83f1e7ae3a5083d083ca885cc5465ac065dd7a1a84e7
5
5
  SHA512:
6
- metadata.gz: a789683f855b4e23881f56dbfe52f5fbbbd3468ddd1789cb35f4ad20be2a6bfa03bc61e0d44e4e8ef9b725c80c784da51769b68818ed83f79102b11105732f19
7
- data.tar.gz: 6ed327dc742af0a41c2e7b0df6258879a732357b2c0c7b1cc5077a073400e222c39113ba7aafcdbba6d94484e68a1b4c3e8a45c687a64569b2a82b38f60210ed
6
+ metadata.gz: fdbcf07a395455bf0d6ffad1811fe836b5921183426fa65818a7939ffcb605691c949eadc66d47f6899b0bd6475d2a8c6dc03649da667cbd2b1b294e85374f3d
7
+ data.tar.gz: b853e31c72eb7bb358d203b98d68087de8b752ee24d1b78d474136a4aae71e64cc335275f1a8867d3deab7fcf58f78e8a5f904c1382447b8840696d6665366f4
@@ -1,18 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-terraform (0.54.0)
4
+ ruby-terraform (0.58.0)
5
5
  lino (>= 1.1, < 2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (6.0.2.2)
10
+ activesupport (6.0.3.1)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
12
  i18n (>= 0.7, < 2)
13
13
  minitest (~> 5.1)
14
14
  tzinfo (~> 1.1)
15
- zeitwerk (~> 2.2)
15
+ zeitwerk (~> 2.2, >= 2.2.2)
16
16
  addressable (2.7.0)
17
17
  public_suffix (>= 2.0.2, < 5.0)
18
18
  colored2 (3.1.2)
@@ -29,13 +29,13 @@ GEM
29
29
  lino (1.3.0)
30
30
  hamster (~> 3.0)
31
31
  open4 (~> 1.3)
32
- minitest (5.14.0)
32
+ minitest (5.14.1)
33
33
  multipart-post (2.1.1)
34
34
  octokit (4.18.0)
35
35
  faraday (>= 0.9)
36
36
  sawyer (~> 0.8.0, >= 0.5.3)
37
37
  open4 (1.3.4)
38
- public_suffix (4.0.4)
38
+ public_suffix (4.0.5)
39
39
  rake (13.0.1)
40
40
  rake_circle_ci (0.7.0)
41
41
  colored2 (~> 3.1)
@@ -60,7 +60,7 @@ GEM
60
60
  rspec-mocks (~> 3.9.0)
61
61
  rspec-core (3.9.2)
62
62
  rspec-support (~> 3.9.3)
63
- rspec-expectations (3.9.1)
63
+ rspec-expectations (3.9.2)
64
64
  diff-lcs (>= 1.2.0, < 2.0)
65
65
  rspec-support (~> 3.9.0)
66
66
  rspec-mocks (3.9.1)
data/README.md CHANGED
@@ -48,6 +48,7 @@ Currently, there is partial support for the following commands:
48
48
  * `RubyTerraform::Commands::Destroy`: executes `terraform destroy`
49
49
  * `RubyTerraform::Commands::Output`: executes `terraform output`
50
50
  * `RubyTerraform::Commands::Refresh`: executes `terraform refresh`
51
+ * `RubyTerraform::Commands::Import`: executes `terraform import`
51
52
  * `RubyTerraform::Commands::RemoteConfig`: executes `terraform remote config`
52
53
  * `RubyTerraform::Commands::Validate`: executes `terraform validate`
53
54
  * `RubyTerraform::Commands::Workspace`: executes `terraform workspace`
@@ -311,6 +312,47 @@ The refresh command supports the following options passed as keyword arguments:
311
312
  defaults to `false`.
312
313
 
313
314
 
315
+ ### RubyTerraform::Commands::Import
316
+
317
+ The import command imports existing infrastructure into your terraform state.
318
+ It can be called in the following ways:
319
+
320
+ ```ruby
321
+ RubyTerraform.import(
322
+ directory: 'infra/networking',
323
+ address: 'a.resource.address',
324
+ id: 'a-resource-id',
325
+ vars: {
326
+ region: 'eu-central'
327
+ }))
328
+ RubyTerraform::Commands::Import.new.execute(
329
+ directory: 'infra/networking',
330
+ address: 'a.resource.address',
331
+ id: 'a-resource-id',
332
+ vars: {
333
+ region: 'eu-central'
334
+ }))
335
+ ```
336
+
337
+ The import command supports the following options passed as keyword arguments:
338
+ * `directory`: the directory containing terraform configuration; required.
339
+ * `address`: a valid resource address; required.
340
+ * `id`: id of resource being imported; required.
341
+ * `vars`: a map of vars to be passed in to the terraform configuration.
342
+ * `var_file`: the path to a terraform var file; if both `var_file` and
343
+ `var_files` are provided, all var files will be passed to terraform.
344
+ * `var_files`: an array of paths to terraform var files; if both `var_file` and
345
+ `var_files` are provided, all var files will be passed to terraform.
346
+ * `input`: when `false`, will not ask for input for variables not directly set;
347
+ defaults to `true`.
348
+ * `state`: the path to the state file containing the current state; defaults to
349
+ terraform.tfstate in the working directory or the remote state if configured.
350
+ * `no_backup`: when `true`, no backup file will be written; defaults to `false`.
351
+ * `backup`: the path to the backup file in which to store the state backup.
352
+ * `no_color`: whether or not the output from the command should be in color;
353
+ defaults to `false`.
354
+
355
+
314
356
  ### RubyTerraform::Commands::RemoteConfig
315
357
 
316
358
  The remote config command configures storage of state using a remote backend. It
@@ -69,13 +69,8 @@ module RubyTerraform
69
69
  Commands::Workspace.new.execute(opts)
70
70
  end
71
71
 
72
- def output_from_remote(opts)
73
- output_name = opts[:name]
74
- remote_opts = opts[:remote]
75
-
76
- clean
77
- remote_config(remote_opts)
78
- output(name: output_name)
72
+ def import(opts = {})
73
+ Commands::Import.new.execute(opts)
79
74
  end
80
75
  end
81
76
  extend ClassMethods
@@ -10,6 +10,7 @@ require_relative 'commands/refresh'
10
10
  require_relative 'commands/remote_config'
11
11
  require_relative 'commands/show'
12
12
  require_relative 'commands/workspace'
13
+ require_relative 'commands/import'
13
14
 
14
15
  module RubyTerraform
15
16
  module Commands
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lino'
4
+ require_relative 'base'
5
+
6
+ module RubyTerraform
7
+ module Commands
8
+ class Import < Base
9
+ def configure_command(builder, opts)
10
+ directory = opts[:directory]
11
+ vars = opts[:vars] || {}
12
+ var_file = opts[:var_file]
13
+ var_files = opts[:var_files] || []
14
+ no_color = opts[:no_color]
15
+ no_backup = opts[:no_backup]
16
+ backup = no_backup ? '-' : opts[:backup]
17
+ state = opts[:state]
18
+ input = opts[:input]
19
+ address = opts[:address]
20
+ id = opts[:id]
21
+
22
+ builder
23
+ .with_subcommand('import') do |sub|
24
+ sub = sub.with_option('-config', directory)
25
+ vars.each do |key, value|
26
+ var_value = value.is_a?(String) ? value : JSON.generate(value)
27
+ sub = sub.with_option(
28
+ '-var', "'#{key}=#{var_value}'", separator: ' '
29
+ )
30
+ end
31
+ sub = sub.with_option('-var-file', var_file) if var_file
32
+ var_files.each do |file|
33
+ sub = sub.with_option('-var-file', file)
34
+ end
35
+ sub = sub.with_option('-state', state) if state
36
+ sub = sub.with_option('-input', input) if input
37
+ sub = sub.with_option('-backup', backup) if backup
38
+ sub = sub.with_flag('-no-color') if no_color
39
+ sub
40
+ end
41
+ .with_argument(address)
42
+ .with_argument(id)
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,21 @@
1
+ module RubyTerraform
2
+ class Output
3
+ def self.for(opts)
4
+ name = opts[:name]
5
+ backend_config = opts[:backend_config]
6
+
7
+ source_directory = opts[:source_directory]
8
+ work_directory = opts[:work_directory]
9
+
10
+ configuration_directory = File.join(work_directory, source_directory)
11
+
12
+ FileUtils.mkdir_p File.dirname(configuration_directory)
13
+ FileUtils.cp_r source_directory, configuration_directory
14
+
15
+ Dir.chdir(configuration_directory) do
16
+ RubyTerraform.init(backend_config: backend_config)
17
+ RubyTerraform.output(name: name)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module RubyTerraform
2
- VERSION = "0.54.0"
2
+ VERSION = "0.58.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-terraform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.54.0
4
+ version: 0.58.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toby Clemson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-06 00:00:00.000000000 Z
11
+ date: 2020-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lino
@@ -173,6 +173,7 @@ files:
173
173
  - lib/ruby_terraform/commands/clean.rb
174
174
  - lib/ruby_terraform/commands/destroy.rb
175
175
  - lib/ruby_terraform/commands/get.rb
176
+ - lib/ruby_terraform/commands/import.rb
176
177
  - lib/ruby_terraform/commands/init.rb
177
178
  - lib/ruby_terraform/commands/output.rb
178
179
  - lib/ruby_terraform/commands/plan.rb
@@ -183,6 +184,7 @@ files:
183
184
  - lib/ruby_terraform/commands/workspace.rb
184
185
  - lib/ruby_terraform/errors.rb
185
186
  - lib/ruby_terraform/errors/execution_error.rb
187
+ - lib/ruby_terraform/output.rb
186
188
  - lib/ruby_terraform/version.rb
187
189
  - ruby_terraform.gemspec
188
190
  - scripts/ci/common/configure-git.sh