terraspace 0.3.3 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) 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 +39 -0
  6. data/README.md +1 -1
  7. data/lib/templates/base/project/README.md +1 -1
  8. data/lib/terraspace.rb +1 -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 +10 -6
  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/init.md +33 -0
  27. data/lib/terraspace/cli/help/all/output.md +22 -0
  28. data/lib/terraspace/cli/help/all/plan.md +25 -0
  29. data/lib/terraspace/cli/help/all/providers.md +21 -0
  30. data/lib/terraspace/cli/help/all/refresh.md +17 -0
  31. data/lib/terraspace/cli/help/all/show.md +21 -0
  32. data/lib/terraspace/cli/help/all/up.md +27 -0
  33. data/lib/terraspace/cli/help/all/validate.md +21 -0
  34. data/lib/terraspace/cli/help/build.md +6 -0
  35. data/lib/terraspace/cli/help/bundle.md +9 -5
  36. data/lib/terraspace/cli/help/check_setup.md +9 -0
  37. data/lib/terraspace/cli/help/clean/all.md +10 -0
  38. data/lib/terraspace/cli/help/clean/cache.md +12 -0
  39. data/lib/terraspace/cli/help/clean/logs.md +17 -0
  40. data/lib/terraspace/cli/help/cloud/destroy.md +16 -0
  41. data/lib/terraspace/cli/help/cloud/list.md +7 -0
  42. data/lib/terraspace/cli/help/cloud/runs/list.md +3 -3
  43. data/lib/terraspace/cli/help/cloud/runs/prune.md +1 -1
  44. data/lib/terraspace/cli/help/cloud/sync.md +26 -2
  45. data/lib/terraspace/cli/help/console.md +8 -0
  46. data/lib/terraspace/cli/help/down.md +26 -0
  47. data/lib/terraspace/cli/help/info.md +43 -0
  48. data/lib/terraspace/cli/help/init.md +37 -0
  49. data/lib/terraspace/cli/help/list.md +20 -0
  50. data/lib/terraspace/cli/help/logs.md +48 -0
  51. data/lib/terraspace/cli/help/logs/remove.md +5 -0
  52. data/lib/terraspace/cli/help/logs/truncate.md +5 -0
  53. data/lib/terraspace/cli/help/new/bootstrap_test.md +8 -0
  54. data/lib/terraspace/cli/help/new/example.md +8 -0
  55. data/lib/terraspace/cli/help/new/git_hook.md +6 -0
  56. data/lib/terraspace/cli/help/new/module.md +9 -0
  57. data/lib/terraspace/cli/help/new/module_test.md +12 -0
  58. data/lib/terraspace/cli/help/new/plugin.md +49 -0
  59. data/lib/terraspace/cli/help/new/project.md +40 -0
  60. data/lib/terraspace/cli/help/new/project_test.md +8 -0
  61. data/lib/terraspace/cli/help/new/shim.md +21 -0
  62. data/lib/terraspace/cli/help/new/stack.md +9 -0
  63. data/lib/terraspace/cli/help/output.md +6 -0
  64. data/lib/terraspace/cli/help/plan.md +29 -0
  65. data/lib/terraspace/cli/help/providers.md +18 -0
  66. data/lib/terraspace/cli/help/refresh.md +11 -0
  67. data/lib/terraspace/cli/help/seed.md +7 -0
  68. data/lib/terraspace/cli/help/show.md +36 -0
  69. data/lib/terraspace/cli/help/summary.md +11 -0
  70. data/lib/terraspace/cli/help/test.md +35 -0
  71. data/lib/terraspace/cli/help/up.md +30 -0
  72. data/lib/terraspace/cli/help/validate.md +9 -0
  73. data/lib/terraspace/cli/info.rb +4 -16
  74. data/lib/terraspace/cli/init.rb +3 -7
  75. data/lib/terraspace/cli/list.rb +2 -1
  76. data/lib/terraspace/cli/logs.rb +106 -9
  77. data/lib/terraspace/cli/{log → logs}/concern.rb +1 -1
  78. data/lib/terraspace/cli/new.rb +18 -18
  79. data/lib/terraspace/cli/new/git_hook.rb +4 -1
  80. data/lib/terraspace/cli/new/helper.rb +9 -2
  81. data/lib/terraspace/cli/new/project.rb +1 -1
  82. data/lib/terraspace/cli/summary.rb +2 -2
  83. data/lib/terraspace/command.rb +1 -1
  84. data/lib/terraspace/compiler/dependencies/helpers.rb +34 -0
  85. data/lib/terraspace/compiler/dsl/syntax/helpers/common.rb +0 -26
  86. data/lib/terraspace/compiler/dsl/syntax/tfvar.rb +1 -0
  87. data/lib/terraspace/compiler/erb/context.rb +1 -1
  88. data/lib/terraspace/compiler/erb/helpers.rb +6 -0
  89. data/lib/terraspace/dependency/graph.rb +2 -1
  90. data/lib/terraspace/dependency/helper/base.rb +7 -0
  91. data/lib/terraspace/dependency/helper/depends_on.rb +12 -0
  92. data/lib/terraspace/dependency/helper/output.rb +11 -0
  93. data/lib/terraspace/hooks/builder.rb +52 -0
  94. data/lib/terraspace/hooks/concern.rb +9 -0
  95. data/lib/terraspace/{terraform/hooks → hooks}/dsl.rb +3 -2
  96. data/lib/terraspace/hooks/runner.rb +23 -0
  97. data/lib/terraspace/mod.rb +11 -2
  98. data/lib/terraspace/plugin/summary/interface.rb +4 -2
  99. data/lib/terraspace/shell.rb +29 -14
  100. data/lib/terraspace/terraform/args/custom.rb +1 -1
  101. data/lib/terraspace/terraform/cloud/runs/lister.rb +0 -2
  102. data/lib/terraspace/terraform/cloud/syncer.rb +2 -2
  103. data/lib/terraspace/terraform/cloud/workspace.rb +0 -9
  104. data/lib/terraspace/terraform/remote_state/fetcher.rb +13 -4
  105. data/lib/terraspace/terraform/remote_state/marker/output.rb +3 -1
  106. data/lib/terraspace/terraform/remote_state/output_proxy.rb +18 -14
  107. data/lib/terraspace/terraform/remote_state/unresolved.rb +40 -0
  108. data/lib/terraspace/terraform/runner.rb +2 -7
  109. data/lib/terraspace/version.rb +1 -1
  110. data/spec/fixtures/dependencies/app/stacks/a1/tfvars/dev.tfvars +1 -0
  111. data/spec/fixtures/fetcher/c1.json +4 -0
  112. data/spec/terraspace/all/summary_spec.rb +1 -1
  113. data/spec/terraspace/compiler/erb/render_spec.rb +15 -0
  114. data/spec/terraspace/dependency/helper/depends_on_spec.rb +27 -0
  115. data/spec/terraspace/dependency/helper/output_spec.rb +29 -0
  116. data/spec/terraspace/{terraform/hooks → hooks}/builder_spec.rb +4 -5
  117. data/spec/terraspace/terraform/remote_state/fetcher_spec.rb +108 -27
  118. data/spec/terraspace/terraform/remote_state/marker/output_spec.rb +36 -0
  119. data/spec/terraspace/terraform/remote_state/output_proxy_spec.rb +69 -0
  120. data/terraspace.gemspec +1 -1
  121. metadata +78 -13
  122. data/lib/terraspace/cli/help/log.md +0 -46
  123. data/lib/terraspace/cli/help/update.md +0 -5
  124. data/lib/terraspace/cli/log.rb +0 -112
  125. data/lib/terraspace/terraform/hooks/builder.rb +0 -40
@@ -0,0 +1,9 @@
1
+ module Terraspace::Hooks
2
+ module Concern
3
+ def run_hooks(dsl_file, name, &block)
4
+ hooks = Builder.new(@mod, "#{Terraspace.root}/config/hooks/#{dsl_file}", name)
5
+ hooks.build # build hooks
6
+ hooks.run_hooks(&block)
7
+ end
8
+ end
9
+ end
@@ -1,4 +1,4 @@
1
- module Terraspace::Terraform::Hooks
1
+ module Terraspace::Hooks
2
2
  module Dsl
3
3
  def before(*commands, **props)
4
4
  commands.each do |name|
@@ -13,7 +13,8 @@ module Terraspace::Terraform::Hooks
13
13
  end
14
14
 
15
15
  def each_hook(type, name, props={})
16
- @hooks[type][name] = props
16
+ @hooks[type][name] ||= []
17
+ @hooks[type][name] << props
17
18
  end
18
19
  end
19
20
  end
@@ -0,0 +1,23 @@
1
+ module Terraspace::Hooks
2
+ class Runner
3
+ include Terraspace::Util
4
+
5
+ def initialize(mod, hook)
6
+ @mod, @hook = mod, hook
7
+ @execute = @hook["execute"]
8
+ end
9
+
10
+ def run
11
+ case @execute
12
+ when String
13
+ Terraspace::Shell.new(@mod, @execute, exit_on_fail: @hook["exit_on_fail"]).run
14
+ when -> (e) { e.respond_to?(:public_instance_methods) && e.public_instance_methods.include?(:call) }
15
+ @execute.new.call
16
+ when -> (e) { e.respond_to?(:call) }
17
+ @execute.call
18
+ else
19
+ logger.warn "WARN: execute option not set for hook: #{@hook.inspect}"
20
+ end
21
+ end
22
+ end
23
+ end
@@ -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,36 @@ module Terraspace
6
6
 
7
7
  def initialize(mod, command, options={})
8
8
  @mod, @command, @options = mod, command, options
9
- @error_type, @error_messages = nil, ''
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
+
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
21
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
- @error_type ||= known_error_type(err)
26
- if @error_type
27
- @error_messages << err
28
- else
36
+ @error_messages << err # aggregate all error lines
37
+ @known_error ||= known_error_type(err)
38
+ unless @known_error
29
39
  # Sometimes may print a "\e[31m\n" which like during dependencies fetcher init
30
40
  # suppress it so dont get a bunch of annoying "newlines"
31
41
  next if err == "\e[31m\n" && @options[:suppress_error_color]
@@ -39,8 +49,8 @@ module Terraspace
39
49
  end
40
50
 
41
51
  def known_error_type(err)
42
- if reinitialization_required?(err)
43
- :reinitialization_required
52
+ if reinit_required?(err)
53
+ :reinit_required
44
54
  elsif bucket_not_found?(err)
45
55
  :bucket_not_found
46
56
  end
@@ -51,7 +61,12 @@ module Terraspace
51
61
  err.include?("Failed to get existing workspaces")
52
62
  end
53
63
 
54
- def reinitialization_required?(err)
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 ||
55
70
  err.include?("reinitialization required") ||
56
71
  err.include?("terraform init") ||
57
72
  err.include?("require reinitialization")
@@ -61,9 +76,9 @@ module Terraspace
61
76
  return if status == 0
62
77
 
63
78
  exit_on_fail = @options[:exit_on_fail].nil? ? true : @options[:exit_on_fail]
64
- if @error_type == :reinitialization_required
79
+ if @known_error == :reinit_required
65
80
  raise InitRequiredError.new(@error_messages)
66
- elsif @error_type == :bucket_not_found
81
+ elsif @known_error == :bucket_not_found
67
82
  raise BucketNotFoundError.new(@error_messages)
68
83
  elsif exit_on_fail
69
84
  logger.error "Error running command: #{@command}".color(:red)
@@ -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
@@ -8,6 +8,7 @@ module Terraspace::Terraform::RemoteState
8
8
  @parent, @identifier, @options = parent, identifier, options
9
9
  child_name, @output_key = identifier.split('.')
10
10
  @child = Terraspace::Mod.new(child_name)
11
+ @child.resolved = @parent.resolved
11
12
  end
12
13
 
13
14
  def run
@@ -16,16 +17,24 @@ module Terraspace::Terraform::RemoteState
16
17
  load
17
18
  end
18
19
 
20
+ # Returns OutputProxy
19
21
  def output
20
22
  run
21
23
  if pull_success?
22
- value = output_value
23
- error = output_error(:key_not_found) unless @outputs.key?(@output_key)
24
- OutputProxy.new(value, @options.merge(error: error))
24
+ pull_success_output
25
25
  else
26
26
  @error_type ||= :state_not_found # could be set to :bucket_not_found by bucket_not_found_error
27
27
  error = output_error(@error_type)
28
- OutputProxy.new(nil, @options.merge(error: error))
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))
29
38
  end
30
39
  end
31
40
 
@@ -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.3"
2
+ VERSION = "0.4.1"
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"
@@ -68,7 +68,7 @@ describe Terraspace::All::Summary do
68
68
  let(:log_path) { "spec/fixtures/summary/output.log" }
69
69
  it "run" do
70
70
  summary.run
71
- expect(@io.string).to include "=> terraform output"
71
+ expect(@io.string).to include "pet1 = krill"
72
72
  end
73
73
  end
74
74
 
@@ -0,0 +1,15 @@
1
+ describe Terraspace::Compiler::Erb::Render do
2
+ let(:render) { described_class.new(mod, src_path) }
3
+ let(:mod) { Terraspace::Mod.new("a1") }
4
+
5
+ # Only testing mod unresolved as a sanity check and its worth the ROI.
6
+ # The resolved would the Fetcher. We have unit tests to cover those other changes.
7
+ context "a1" do
8
+ let(:src_path) { fixture("dependencies/app/stacks/a1/tfvars/dev.tfvars") }
9
+ it "build" do
10
+ allow(Terraspace::Terraform::RemoteState::Marker::Output).to receive(:stack_names).and_return("b1")
11
+ result = render.build
12
+ expect(result).to eq "length = (unresolved)"
13
+ end
14
+ end
15
+ end