ruby-terraform 0.57.0.pre.1 → 0.57.0.pre.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83e52a2077dcb82f839069ae413d1a634262cf7bc44990d679edf0061cceb1c3
4
- data.tar.gz: 22d850535b3352819ef926b57a9bd3424f0561e526d6984e626a09a6e2cb16ec
3
+ metadata.gz: b81d7b5918ae0fa3f13d025d2deac0f75ee325b403cf442155b5041a7bd3e740
4
+ data.tar.gz: c14af27fb5134648a4c1deaffcb84f4b605018fd4757dce165e1ad82400ccbdb
5
5
  SHA512:
6
- metadata.gz: 2d14a6e67f93125a4da114a3d1f3eae84e40f8fa36a464cd6ac60f2666cb97c17a75aad320b240e6783d1ed8debd014a7b9745f295ceebe7f34f18bfa9e403d7
7
- data.tar.gz: f01bc72f115d317e235b0afca7c2e10deed4bd20953f92f0c5305152748c1b535476b234a74fda95a5dc55df63f502d25e001a7de185a8d72378e802729b3f2b
6
+ metadata.gz: e396f290f591bee57073801c4d87d9eb7309f0543e8158c04a67fec4acdc9488f353234823655e78c230f38cfcc3b56942496e8bb0ac431e7dcece463059b604
7
+ data.tar.gz: b93e880f3e42139beb130fb431c12d3c265770c1f11fa6fcdd48e99539fde29093f0de7137c2cc9fda1e84b23ef797e8cfa7244d00442c060c8a30684b173237
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-terraform (0.57.0.pre.1)
4
+ ruby-terraform (0.57.0.pre.2)
5
5
  lino (>= 1.1, < 2)
6
6
 
7
7
  GEM
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
@@ -68,6 +68,10 @@ module RubyTerraform
68
68
  def workspace(opts = {})
69
69
  Commands::Workspace.new.execute(opts)
70
70
  end
71
+
72
+ def import(opts = {})
73
+ Commands::Import.new.execute(opts)
74
+ end
71
75
  end
72
76
  extend ClassMethods
73
77
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module RubyTerraform
2
- VERSION = "0.57.0.pre.1"
2
+ VERSION = "0.57.0.pre.2"
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.57.0.pre.1
4
+ version: 0.57.0.pre.2
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-25 00:00:00.000000000 Z
11
+ date: 2020-07-16 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