rake_terraform 0.3.0 → 0.4.0

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
  SHA1:
3
- metadata.gz: f54d2792411a0272b935cb2622c4ded0c4d875a1
4
- data.tar.gz: f74564eb5f5c3bc0e603bec7c6f8e35f8d0b326d
3
+ metadata.gz: 8291b39a4b15b2b20eec4eff3dbcf88a1575dfd9
4
+ data.tar.gz: b8422d70d988283989c7cca3fdb7853d2e22430f
5
5
  SHA512:
6
- metadata.gz: a8fa4235b2504b5a0d3637147220ef9415d58d9f2c17f53977e722237b3168947e8b651c665be30f5e5431961b35841b59e791eaefd81beea43b930dda476a46
7
- data.tar.gz: 78f15f694e30e9e1126c8feb265c4f4c60447de8822dd8fd7fa8bed970495cd9e924d633b134a1b561c99a1bd0fd87abf70d7bba213d99f1296dcf5b61454d1b
6
+ metadata.gz: 0fbfacaa511f513de1edc50740b3cbfe5c8981f7fef1c14d53792214bbb2c78c9923f2a0346b9b83ec8fe2419274cfdf4481c08ff47244370178c8a1f3811f97
7
+ data.tar.gz: 9a9279bc071b401849becf19435eef42ac17c2eb28edd8091f2139985f0b4d4adc32a7ba0dcfc29b695426dae3e3450148379733dee51b1c0dce260071da0ef5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rake_terraform (0.3.0)
4
+ rake_terraform (0.4.0)
5
5
  rake_dependencies (~> 0.15)
6
6
  ruby-terraform (~> 0.4)
7
7
 
@@ -1 +1,2 @@
1
- require_relative 'tasks/provision'
1
+ require_relative 'tasks/provision'
2
+ require_relative 'tasks/destroy'
@@ -0,0 +1,73 @@
1
+ require 'ruby_terraform'
2
+ require_relative '../tasklib'
3
+
4
+ module RakeTerraform
5
+ module Tasks
6
+ class Destroy < TaskLib
7
+ parameter :name, :default => :destroy
8
+
9
+ parameter :configuration_name, :required => true
10
+ parameter :configuration_directory, :required => true
11
+
12
+ parameter :backend
13
+ parameter :backend_config
14
+
15
+ parameter :vars, default: {}
16
+ parameter :state_file
17
+
18
+ parameter :no_color, :default => false
19
+ parameter :no_backup, :default => false
20
+
21
+ parameter :backup_file
22
+
23
+ parameter :ensure_task, :default => :'terraform:ensure'
24
+
25
+ def process_arguments(args)
26
+ self.name = args[0] if args[0]
27
+ end
28
+
29
+ def define
30
+ if backend && state_file
31
+ raise ArgumentError.new(
32
+ "Only one of 'state_file' and 'backend' can be provided.")
33
+ end
34
+
35
+ desc "Destroy #{configuration_name} using terraform"
36
+ task name => [ensure_task] do
37
+ apply_vars = vars.respond_to?(:call) ?
38
+ vars.call(
39
+ configuration_name: configuration_name,
40
+ configuration_directory: configuration_directory,
41
+ backend: backend,
42
+ backend_config: backend_config,
43
+ state_file: state_file,
44
+ no_color: no_color,
45
+ no_backup: no_backup,
46
+ backup_file: backup_file) :
47
+ vars
48
+
49
+ puts "Destroying #{configuration_name}"
50
+
51
+ RubyTerraform.clean
52
+ RubyTerraform.get(
53
+ directory: configuration_directory,
54
+ no_color: no_color)
55
+ if backend
56
+ RubyTerraform.remote_config(
57
+ no_color: no_color,
58
+ backend: backend,
59
+ backend_config: backend_config)
60
+ end
61
+ RubyTerraform.destroy(
62
+ force: true,
63
+ no_color: no_color,
64
+ no_backup: no_backup,
65
+ backup: backup_file,
66
+ directory: configuration_directory,
67
+ state: state_file,
68
+ vars: apply_vars)
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -1,3 +1,3 @@
1
1
  module RakeTerraform
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake_terraform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toby Clemson
@@ -145,6 +145,7 @@ files:
145
145
  - lib/rake_terraform/exceptions.rb
146
146
  - lib/rake_terraform/tasklib.rb
147
147
  - lib/rake_terraform/tasks.rb
148
+ - lib/rake_terraform/tasks/destroy.rb
148
149
  - lib/rake_terraform/tasks/provision.rb
149
150
  - lib/rake_terraform/version.rb
150
151
  - rake_terraform.gemspec