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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rake_terraform/tasks.rb +2 -1
- data/lib/rake_terraform/tasks/destroy.rb +73 -0
- data/lib/rake_terraform/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8291b39a4b15b2b20eec4eff3dbcf88a1575dfd9
|
4
|
+
data.tar.gz: b8422d70d988283989c7cca3fdb7853d2e22430f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fbfacaa511f513de1edc50740b3cbfe5c8981f7fef1c14d53792214bbb2c78c9923f2a0346b9b83ec8fe2419274cfdf4481c08ff47244370178c8a1f3811f97
|
7
|
+
data.tar.gz: 9a9279bc071b401849becf19435eef42ac17c2eb28edd8091f2139985f0b4d4adc32a7ba0dcfc29b695426dae3e3450148379733dee51b1c0dce260071da0ef5
|
data/Gemfile.lock
CHANGED
data/lib/rake_terraform/tasks.rb
CHANGED
@@ -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
|
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.
|
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
|