terraspace 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/.cody/aws/bin/build.sh +2 -0
  3. data/.cody/azurerm/bin/build.sh +2 -0
  4. data/.cody/google/bin/build.sh +2 -0
  5. data/CHANGELOG.md +38 -0
  6. data/README.md +2 -2
  7. data/lib/templates/base/project/README.md +1 -1
  8. data/lib/terraspace.rb +2 -0
  9. data/lib/terraspace/all/preview.rb +1 -1
  10. data/lib/terraspace/all/runner.rb +1 -0
  11. data/lib/terraspace/all/summary.rb +29 -2
  12. data/lib/terraspace/app.rb +9 -5
  13. data/lib/terraspace/builder.rb +11 -12
  14. data/lib/terraspace/cli.rb +33 -39
  15. data/lib/terraspace/cli/all.rb +15 -9
  16. data/lib/terraspace/cli/bundle.rb +2 -1
  17. data/lib/terraspace/cli/clean.rb +18 -6
  18. data/lib/terraspace/cli/clean/all.rb +18 -0
  19. data/lib/terraspace/cli/clean/base.rb +15 -0
  20. data/lib/terraspace/cli/clean/cache.rb +25 -0
  21. data/lib/terraspace/cli/{logs/tasks.rb → clean/logs.rb} +16 -5
  22. data/lib/terraspace/cli/cloud.rb +3 -9
  23. data/lib/terraspace/cli/cloud/runs.rb +0 -2
  24. data/lib/terraspace/cli/help/all/down.md +32 -0
  25. data/lib/terraspace/cli/help/all/graph.md +21 -0
  26. data/lib/terraspace/cli/help/all/output.md +22 -0
  27. data/lib/terraspace/cli/help/all/plan.md +25 -0
  28. data/lib/terraspace/cli/help/all/providers.md +21 -0
  29. data/lib/terraspace/cli/help/all/refresh.md +17 -0
  30. data/lib/terraspace/cli/help/all/show.md +21 -0
  31. data/lib/terraspace/cli/help/all/up.md +27 -0
  32. data/lib/terraspace/cli/help/all/validate.md +21 -0
  33. data/lib/terraspace/cli/help/build.md +6 -0
  34. data/lib/terraspace/cli/help/bundle.md +9 -5
  35. data/lib/terraspace/cli/help/check_setup.md +9 -0
  36. data/lib/terraspace/cli/help/clean/all.md +10 -0
  37. data/lib/terraspace/cli/help/clean/cache.md +12 -0
  38. data/lib/terraspace/cli/help/clean/logs.md +17 -0
  39. data/lib/terraspace/cli/help/cloud/destroy.md +16 -0
  40. data/lib/terraspace/cli/help/cloud/list.md +7 -0
  41. data/lib/terraspace/cli/help/cloud/runs/list.md +3 -3
  42. data/lib/terraspace/cli/help/cloud/runs/prune.md +2 -2
  43. data/lib/terraspace/cli/help/cloud/sync.md +26 -2
  44. data/lib/terraspace/cli/help/console.md +8 -0
  45. data/lib/terraspace/cli/help/down.md +26 -0
  46. data/lib/terraspace/cli/help/info.md +43 -0
  47. data/lib/terraspace/cli/help/init.md +37 -0
  48. data/lib/terraspace/cli/help/list.md +20 -0
  49. data/lib/terraspace/cli/help/logs.md +48 -0
  50. data/lib/terraspace/cli/help/logs/remove.md +5 -0
  51. data/lib/terraspace/cli/help/logs/truncate.md +5 -0
  52. data/lib/terraspace/cli/help/new/bootstrap_test.md +8 -0
  53. data/lib/terraspace/cli/help/new/example.md +8 -0
  54. data/lib/terraspace/cli/help/new/git_hook.md +6 -0
  55. data/lib/terraspace/cli/help/new/module.md +9 -0
  56. data/lib/terraspace/cli/help/new/module_test.md +12 -0
  57. data/lib/terraspace/cli/help/new/plugin.md +49 -0
  58. data/lib/terraspace/cli/help/new/project.md +40 -0
  59. data/lib/terraspace/cli/help/new/project_test.md +8 -0
  60. data/lib/terraspace/cli/help/new/shim.md +21 -0
  61. data/lib/terraspace/cli/help/new/stack.md +9 -0
  62. data/lib/terraspace/cli/help/output.md +6 -0
  63. data/lib/terraspace/cli/help/plan.md +29 -0
  64. data/lib/terraspace/cli/help/providers.md +18 -0
  65. data/lib/terraspace/cli/help/refresh.md +11 -0
  66. data/lib/terraspace/cli/help/seed.md +7 -0
  67. data/lib/terraspace/cli/help/show.md +36 -0
  68. data/lib/terraspace/cli/help/summary.md +11 -0
  69. data/lib/terraspace/cli/help/test.md +35 -0
  70. data/lib/terraspace/cli/help/up.md +30 -0
  71. data/lib/terraspace/cli/help/validate.md +9 -0
  72. data/lib/terraspace/cli/info.rb +4 -16
  73. data/lib/terraspace/cli/init.rb +3 -7
  74. data/lib/terraspace/cli/logs.rb +106 -9
  75. data/lib/terraspace/cli/{log → logs}/concern.rb +1 -1
  76. data/lib/terraspace/cli/new.rb +18 -18
  77. data/lib/terraspace/cli/new/git_hook.rb +4 -1
  78. data/lib/terraspace/cli/new/helper.rb +9 -2
  79. data/lib/terraspace/cli/new/project.rb +1 -1
  80. data/lib/terraspace/cli/summary.rb +2 -2
  81. data/lib/terraspace/command.rb +1 -1
  82. data/lib/terraspace/compiler/backend.rb +10 -0
  83. data/lib/terraspace/compiler/builder.rb +2 -1
  84. data/lib/terraspace/compiler/commands_concern.rb +18 -0
  85. data/lib/terraspace/compiler/dependencies/helpers.rb +34 -0
  86. data/lib/terraspace/compiler/dsl/syntax/helpers/common.rb +0 -26
  87. data/lib/terraspace/compiler/dsl/syntax/tfvar.rb +1 -0
  88. data/lib/terraspace/compiler/erb/context.rb +1 -1
  89. data/lib/terraspace/compiler/erb/helpers.rb +6 -0
  90. data/lib/terraspace/dependency/graph.rb +2 -1
  91. data/lib/terraspace/dependency/helper/base.rb +7 -0
  92. data/lib/terraspace/dependency/helper/depends_on.rb +12 -0
  93. data/lib/terraspace/dependency/helper/output.rb +11 -0
  94. data/lib/terraspace/hooks/builder.rb +52 -0
  95. data/lib/terraspace/hooks/concern.rb +9 -0
  96. data/lib/terraspace/{terraform/hooks → hooks}/dsl.rb +3 -2
  97. data/lib/terraspace/hooks/runner.rb +23 -0
  98. data/lib/terraspace/mod.rb +11 -2
  99. data/lib/terraspace/plugin/summary/interface.rb +4 -2
  100. data/lib/terraspace/shell.rb +50 -17
  101. data/lib/terraspace/terraform/args/custom.rb +1 -1
  102. data/lib/terraspace/terraform/cloud/runs/lister.rb +0 -2
  103. data/lib/terraspace/terraform/cloud/syncer.rb +2 -2
  104. data/lib/terraspace/terraform/cloud/workspace.rb +0 -9
  105. data/lib/terraspace/terraform/remote_state/fetcher.rb +37 -7
  106. data/lib/terraspace/terraform/remote_state/marker/output.rb +3 -1
  107. data/lib/terraspace/terraform/remote_state/output_proxy.rb +18 -14
  108. data/lib/terraspace/terraform/remote_state/unresolved.rb +40 -0
  109. data/lib/terraspace/terraform/runner.rb +2 -7
  110. data/lib/terraspace/version.rb +1 -1
  111. data/spec/fixtures/dependencies/app/stacks/a1/tfvars/dev.tfvars +1 -0
  112. data/spec/fixtures/fetcher/c1.json +4 -0
  113. data/spec/terraspace/all/summary_spec.rb +1 -1
  114. data/spec/terraspace/compiler/erb/render_spec.rb +15 -0
  115. data/spec/terraspace/dependency/helper/depends_on_spec.rb +27 -0
  116. data/spec/terraspace/dependency/helper/output_spec.rb +29 -0
  117. data/spec/terraspace/{terraform/hooks → hooks}/builder_spec.rb +4 -5
  118. data/spec/terraspace/terraform/remote_state/fetcher_spec.rb +108 -27
  119. data/spec/terraspace/terraform/remote_state/marker/output_spec.rb +36 -0
  120. data/spec/terraspace/terraform/remote_state/output_proxy_spec.rb +69 -0
  121. data/terraspace.gemspec +1 -1
  122. metadata +78 -13
  123. data/lib/terraspace/cli/help/log.md +0 -42
  124. data/lib/terraspace/cli/help/update.md +0 -5
  125. data/lib/terraspace/cli/log.rb +0 -112
  126. data/lib/terraspace/terraform/hooks/builder.rb +0 -40
@@ -34,8 +34,17 @@ module Terraspace
34
34
  Terraspace.check_project!
35
35
  return if root
36
36
 
37
- pretty_paths = paths.map { |p| Terraspace::Util.pretty_path(p) }
38
- logger.error "ERROR: Unable to find #{@name.color(:green)} module. Searched paths: #{pretty_paths}"
37
+ pretty_paths = paths.map { |p| Terraspace::Util.pretty_path(p) }.join(", ")
38
+ logger.error <<~EOL
39
+ ERROR: Unable to find #{@name.color(:green)}. Searched paths:
40
+
41
+ #{pretty_paths}
42
+
43
+ To see available stacks, try running:
44
+
45
+ terraspace list
46
+
47
+ EOL
39
48
  ENV['TS_TEST'] ? raise : exit(1)
40
49
  end
41
50
 
@@ -18,7 +18,7 @@ module Terraspace::Plugin::Summary
18
18
  # Note: will not change any of these instance variables unless we note breaking changes
19
19
  @bucket = @info[bucket_field]
20
20
  @key = @info[key_field] # key_field is INTERFACE METHOD IE: aws: key , google: prefix
21
- @folder = folder(@key)
21
+ @folder = folder(@key) # useful as prefix for performance when listing objects in buckets
22
22
  @dest = dest(@bucket)
23
23
  # May change any of these instance variables that follow
24
24
  @dest_folder = "#{@dest}/#{@folder}"
@@ -64,7 +64,9 @@ module Terraspace::Plugin::Summary
64
64
 
65
65
  def show_each(path)
66
66
  data = JSON.load(IO.read(path))
67
+ return unless data # edge case: blank file
67
68
  resources = data['resources']
69
+ return unless resources
68
70
  remove_statefile(path) if resources && resources.size == 0 && !ENV['TS_KEEP_EMPTY_STATEFILES']
69
71
  return unless resources && resources.size > 0
70
72
 
@@ -75,7 +77,7 @@ module Terraspace::Plugin::Summary
75
77
  identifier = r['instances'].map do |i|
76
78
  i['attributes']['name'] || i['attributes']['id']
77
79
  end.join(',')
78
- return if @options[:short]
80
+ return unless @options[:details]
79
81
  logger.info " #{r['type']} #{r['name']}: #{identifier}"
80
82
  end
81
83
  end
@@ -6,26 +6,39 @@ module Terraspace
6
6
 
7
7
  def initialize(mod, command, options={})
8
8
  @mod, @command, @options = mod, command, options
9
- @init_required, @init_messages = false, ''
9
+ # error_messages holds aggregation of all error lines
10
+ @known_error, @error_messages = nil, ''
10
11
  end
11
12
 
12
13
  # requires @mod to be set
14
+ # quiet useful for RemoteState::Fetcher
13
15
  def run
14
- env = @options[:env] || {}
15
- env.stringify_keys!
16
-
17
- # quiet useful for RemoteState::Fetcher
18
16
  msg = "=> #{@command}"
19
17
  @options[:quiet] ? logger.debug(msg) : logger.info(msg)
20
18
  return if ENV['TS_TEST']
19
+ shell
20
+ end
21
21
 
22
+ def shell
23
+ env = @options[:env] || {}
24
+ env.stringify_keys!
25
+ if @options[:shell] == "system" # terraspace console
26
+ system(env, @command, chdir: @mod.cache_dir)
27
+ else
28
+ popen3(env)
29
+ end
30
+ end
31
+
32
+ def popen3(env)
22
33
  Open3.popen3(env, @command, chdir: @mod.cache_dir) do |stdin, stdout, stderr, wait_thread|
23
34
  mimic_terraform_input(stdin, stdout)
24
35
  while err = stderr.gets
25
- @init_required ||= reinitialization_required?(err)
26
- if @init_required
27
- @init_messages << err
28
- else
36
+ @error_messages << err # aggregate all error lines
37
+ @known_error ||= known_error_type(err)
38
+ unless @known_error
39
+ # Sometimes may print a "\e[31m\n" which like during dependencies fetcher init
40
+ # suppress it so dont get a bunch of annoying "newlines"
41
+ next if err == "\e[31m\n" && @options[:suppress_error_color]
29
42
  logger.error(err)
30
43
  end
31
44
  end
@@ -35,24 +48,44 @@ module Terraspace
35
48
  end
36
49
  end
37
50
 
51
+ def known_error_type(err)
52
+ if reinit_required?(err)
53
+ :reinit_required
54
+ elsif bucket_not_found?(err)
55
+ :bucket_not_found
56
+ end
57
+ end
58
+
59
+ def bucket_not_found?(err)
60
+ # Message is included in aws, azurerm, and google. See: https://bit.ly/3iOKDri
61
+ err.include?("Failed to get existing workspaces")
62
+ end
63
+
64
+ def reinit_required?(err)
65
+ # Example error: https://gist.github.com/tongueroo/f7e0a44b64f0a2e533089b18f331c21e
66
+ squeezed = @error_messages.gsub("\n", ' ').squeeze(' ') # remove double whitespaces and newlines
67
+ general_check = squeezed.include?("terraform init") && squeezed.include?("Error:")
68
+
69
+ general_check ||
70
+ err.include?("reinitialization required") ||
71
+ err.include?("terraform init") ||
72
+ err.include?("require reinitialization")
73
+ end
74
+
38
75
  def exit_status(status)
39
76
  return if status == 0
40
77
 
41
78
  exit_on_fail = @options[:exit_on_fail].nil? ? true : @options[:exit_on_fail]
42
- if @init_required
43
- raise InitRequiredError.new(@init_messages)
79
+ if @known_error == :reinit_required
80
+ raise InitRequiredError.new(@error_messages)
81
+ elsif @known_error == :bucket_not_found
82
+ raise BucketNotFoundError.new(@error_messages)
44
83
  elsif exit_on_fail
45
84
  logger.error "Error running command: #{@command}".color(:red)
46
85
  exit status
47
86
  end
48
87
  end
49
88
 
50
- def reinitialization_required?(err)
51
- err.include?("reinitialization required") ||
52
- err.include?("terraform init") ||
53
- err.include?("require reinitialization")
54
- end
55
-
56
89
  # Terraform doesnt seem to stream the line that prompts with "Enter a value:" when using Open3.popen3
57
90
  # Hack around it by mimicking the "Enter a value:" prompt
58
91
  #
@@ -7,7 +7,7 @@ module Terraspace::Terraform::Args
7
7
  attr_accessor :name
8
8
  def initialize(mod, name)
9
9
  @mod, @name = mod, name
10
- @file = "#{Terraspace.root}/config/cli/args.rb"
10
+ @file = "#{Terraspace.root}/config/args/terraform.rb"
11
11
  @commands = {}
12
12
  end
13
13
 
@@ -1,5 +1,3 @@
1
- require 'cli-format'
2
-
3
1
  class Terraspace::Terraform::Cloud::Runs
4
2
  class Lister < Base
5
3
  def run
@@ -12,8 +12,8 @@ module Terraspace::Terraform::Cloud
12
12
  end
13
13
 
14
14
  def mods
15
- mod = @options[:mod]
16
- mod ? [mod] : stack_names
15
+ stacks = @options[:stacks]
16
+ stacks.empty? ? stack_names : stacks
17
17
  end
18
18
 
19
19
  def run_sync(mod)
@@ -20,15 +20,6 @@ module Terraspace::Terraform::Cloud
20
20
  logger.info names.join("\n")
21
21
  end
22
22
 
23
- def setup
24
- build
25
- unless backend.dig('remote','workspaces') # in case called by terraspace down demo -y --destroy-workspace with a non-remote backend
26
- logger.info "ERROR: Workspace not configured in backend.tf"
27
- exit 1
28
- end
29
- init
30
- end
31
-
32
23
  def init
33
24
  Terraspace::CLI::Init.new(@options.merge(calling_command: "cloud-setup")).run
34
25
  end
@@ -1,29 +1,40 @@
1
1
  module Terraspace::Terraform::RemoteState
2
2
  class Fetcher
3
3
  extend Memoist
4
+ include Terraspace::Compiler::CommandsConcern
4
5
  include Terraspace::Util::Logging
5
6
 
6
7
  def initialize(parent, identifier, options={})
7
8
  @parent, @identifier, @options = parent, identifier, options
8
9
  child_name, @output_key = identifier.split('.')
9
10
  @child = Terraspace::Mod.new(child_name)
11
+ @child.resolved = @parent.resolved
10
12
  end
11
13
 
12
14
  def run
13
- validate!
15
+ validate! # check child stack exists
14
16
  pull
15
17
  load
16
18
  end
17
19
 
20
+ # Returns OutputProxy
18
21
  def output
19
22
  run
20
23
  if pull_success?
21
- value = output_value
22
- error = output_error(:key_not_found) unless @outputs.key?(@output_key)
23
- OutputProxy.new(value, @options.merge(error: error))
24
+ pull_success_output
24
25
  else
25
- error = output_error(:state_not_found)
26
- OutputProxy.new(nil, @options.merge(error: error))
26
+ @error_type ||= :state_not_found # could be set to :bucket_not_found by bucket_not_found_error
27
+ error = output_error(@error_type)
28
+ OutputProxy.new(@child, nil, @options.merge(error: error))
29
+ end
30
+ end
31
+
32
+ def pull_success_output
33
+ if @outputs.key?(@output_key)
34
+ OutputProxy.new(@child, output_value, @options)
35
+ else
36
+ error = output_error(:key_not_found)
37
+ OutputProxy.new(@child, nil, @options.merge(error: error))
27
38
  end
28
39
  end
29
40
 
@@ -39,6 +50,8 @@ module Terraspace::Terraform::RemoteState
39
50
  "Output #{@output_key} was not found for the #{@parent.name} tfvars file. Either #{@child.name} stack has not been deployed yet or it does not have this output: #{@output_key}"
40
51
  when :state_not_found
41
52
  "Output #{@output_key} could not be looked up for the #{@parent.name} tfvars file. #{@child.name} stack needs to be deployed"
53
+ when :bucket_not_found
54
+ "The bucket for the backend could not be found"
42
55
  end
43
56
  msg = "(#{msg})"
44
57
  log_message(msg)
@@ -52,7 +65,10 @@ module Terraspace::Terraform::RemoteState
52
65
  logger.info "Downloading tfstate files for dependencies defined in tfvars..." unless @@download_shown || @options[:quiet]
53
66
  @@download_shown = true
54
67
  logger.debug "Downloading tfstate for stack: #{@child.name}"
55
- Terraspace::CLI::Init.new(mod: @child.name, calling_command: "apply", quiet: true).init # init not run, so only init
68
+
69
+ success = init # init not yet run. only run .init directly, not .run. init can completely error and early exit.
70
+ return unless success
71
+
56
72
  FileUtils.mkdir_p(File.dirname(state_path))
57
73
  command = "cd #{@child.cache_dir} && terraform state pull > #{state_path}"
58
74
  logger.debug "=> #{command}"
@@ -67,6 +83,20 @@ module Terraspace::Terraform::RemoteState
67
83
  @@pull_successes[cache_key] = success
68
84
  end
69
85
 
86
+ def init
87
+ Terraspace::CLI::Init.new(mod: @child.name, calling_command: "apply", quiet: true, suppress_error_color: true).init
88
+ true
89
+ rescue Terraspace::BucketNotFoundError # from Terraspace::Shell
90
+ bucket_not_found_error
91
+ false
92
+ end
93
+
94
+ # mimic pull error
95
+ def bucket_not_found_error
96
+ @@pull_successes[cache_key] = false
97
+ @error_type = :bucket_not_found
98
+ end
99
+
70
100
  def load
71
101
  return self unless pull_success?
72
102
 
@@ -8,6 +8,7 @@ module Terraspace::Terraform::RemoteState::Marker
8
8
  @child_name, @output_key = @identifier.split('.')
9
9
  end
10
10
 
11
+ # Returns OutputProxy
11
12
  def build
12
13
  if valid?
13
14
  Terraspace::Dependency::Registry.register(@parent_name, @child_name)
@@ -16,7 +17,7 @@ module Terraspace::Terraform::RemoteState::Marker
16
17
  end
17
18
  # MARKER for debugging. Only appears on 1st pass. Will not see unless changing Terraspace code for debugging.
18
19
  marker = "MARKER:terraform_output('#{@identifier}')"
19
- Terraspace::Terraform::RemoteState::OutputProxy.new(marker, @options)
20
+ Terraspace::Terraform::RemoteState::OutputProxy.new(@mod, marker, @options)
20
21
  end
21
22
 
22
23
  def valid?
@@ -26,6 +27,7 @@ module Terraspace::Terraform::RemoteState::Marker
26
27
  def warning
27
28
  logger.warn "WARN: The #{@child_name} stack does not exist".color(:yellow)
28
29
  caller_line = caller.find { |l| l.include?('.tfvars') }
30
+ return unless caller_line # specs dont have a tfvars file
29
31
  source_code = PrettyTracer.new(caller_line).source_code
30
32
  logger.info source_code
31
33
  end
@@ -1,29 +1,33 @@
1
1
  module Terraspace::Terraform::RemoteState
2
2
  class OutputProxy
3
3
  # raw: can be anything: String, Array, Hash, etc
4
- # options: original options passed by user with terraform_output
4
+ # options: original options passed by user from the output helper in tfvars
5
5
  attr_reader :raw, :options
6
- def initialize(raw, options={})
7
- @raw, @options = raw, options
6
+ def initialize(mod, raw, options={})
7
+ @mod, @raw, @options = mod, raw, options
8
8
  @format = @options[:format]
9
9
  end
10
10
 
11
11
  # Should always return a String
12
12
  def to_s
13
- case @format
14
- when "string"
15
- content.to_s
16
- else # "json"
17
- content.to_json
13
+ if @mod.resolved
14
+ # Dont use Unresolved wrapper because Integer get changed to Strings.
15
+ # Want raw value to be used for the to_json call
16
+ value = @raw.nil? ? mock_or_error : @raw
17
+ value.to_json
18
+ else
19
+ Unresolved.new
18
20
  end
19
21
  end
20
22
 
21
- def content
22
- if @raw.nil?
23
- @options[:mock] || @options[:error]
24
- else
25
- @raw
26
- end
23
+ def to_ruby
24
+ data = @raw.nil? ? mock_or_error : @raw
25
+ @mod.resolved ? data : Unresolved.new
26
+ end
27
+
28
+ private
29
+ def mock_or_error
30
+ @options[:mock] || @options[:error]
27
31
  end
28
32
  end
29
33
  end
@@ -0,0 +1,40 @@
1
+ module Terraspace::Terraform::RemoteState
2
+ class Unresolved
3
+ def to_a
4
+ []
5
+ end
6
+
7
+ def to_ary
8
+ []
9
+ end
10
+
11
+ def to_s
12
+ "(unresolved)" # always returned as part of first unresolved processing pass
13
+ end
14
+ alias_method :to_str, :to_s # ERB requires to_str
15
+
16
+ def to_f
17
+ 0.0
18
+ end
19
+
20
+ def to_i
21
+ 0
22
+ end
23
+
24
+ def nil?
25
+ true
26
+ end
27
+
28
+ def inspect
29
+ format("#<%s:0x%x>", self.class, object_id)
30
+ end
31
+
32
+ def method_missing(*_args, &_block)
33
+ self
34
+ end
35
+
36
+ def respond_to?(_message, _include_private = false)
37
+ true
38
+ end
39
+ end
40
+ end
@@ -1,6 +1,7 @@
1
1
  module Terraspace::Terraform
2
2
  class Runner < Terraspace::CLI::Base
3
3
  extend Memoist
4
+ include Terraspace::Hooks::Concern
4
5
  include Terraspace::Util
5
6
 
6
7
  attr_reader :name
@@ -21,7 +22,7 @@ module Terraspace::Terraform
21
22
 
22
23
  params = args.flatten.join(' ')
23
24
  command = "terraform #{name} #{params}"
24
- run_hooks(name) do
25
+ run_hooks("terraform.rb", name) do
25
26
  Terraspace::Shell.new(@mod, command, @options.merge(env: custom.env_vars)).run
26
27
  end
27
28
  rescue Terraspace::InitRequiredError => e
@@ -53,12 +54,6 @@ module Terraspace::Terraform
53
54
  @options[:quiet] ? logger.debug(msg) : logger.info(msg)
54
55
  end
55
56
 
56
- def run_hooks(name, &block)
57
- hooks = Hooks::Builder.new(@mod, name)
58
- hooks.build # build hooks
59
- hooks.run_hooks(&block)
60
- end
61
-
62
57
  def args
63
58
  # base at end in case of redirection. IE: terraform output > /path
64
59
  custom.args + custom.var_files + default.args
@@ -1,3 +1,3 @@
1
1
  module Terraspace
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -0,0 +1 @@
1
+ length = <%= output('b1.length') %>
@@ -8,6 +8,10 @@
8
8
  "value": 1,
9
9
  "type": "number"
10
10
  },
11
+ "complex": {
12
+ "value": ["a","b"],
13
+ "type": "list"
14
+ },
11
15
  "random_pet_id": {
12
16
  "value": "valued-buzzard",
13
17
  "type": "string"