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,8 @@
1
+ ## Example
2
+
3
+ => Creating test for new module: example
4
+ create app/modules/example
5
+ create app/modules/example/main.tf
6
+ create app/modules/example/outputs.tf
7
+ create app/modules/example/variables.tf
8
+ $
@@ -0,0 +1,6 @@
1
+ ## Example
2
+
3
+ $ terraspace new git_hook
4
+ create .git/hooks/pre-push
5
+ chmod .git/hooks/pre-push
6
+ $
@@ -0,0 +1,9 @@
1
+ ## Example
2
+
3
+ $ terraspace new module example
4
+ => Creating test for new module: example
5
+ create app/modules/example
6
+ create app/modules/example/main.tf
7
+ create app/modules/example/outputs.tf
8
+ create app/modules/example/variables.tf
9
+ $
@@ -0,0 +1,12 @@
1
+ ## Example
2
+
3
+ $ terraspace new module_test example
4
+ => Creating module test: example
5
+ exist app/modules/example
6
+ create app/modules/example/test/.rspec
7
+ create app/modules/example/test/Gemfile
8
+ create app/modules/example/test/spec/fixtures/stack/main.tf
9
+ create app/modules/example/test/spec/fixtures/stack/outputs.tf
10
+ create app/modules/example/test/spec/main_spec.rb
11
+ create app/modules/example/test/spec/spec_helper.rb
12
+ $
@@ -0,0 +1,49 @@
1
+ ## Example
2
+
3
+ $ terraspace new plugin mycloud
4
+ => Creating new plugin: mycloud
5
+ create terraspace_plugin_mycloud
6
+ create terraspace_plugin_mycloud/.gitignore
7
+ create terraspace_plugin_mycloud/.rspec
8
+ create terraspace_plugin_mycloud/CHANGELOG.md
9
+ create terraspace_plugin_mycloud/Gemfile
10
+ create terraspace_plugin_mycloud/LICENSE.txt
11
+ create terraspace_plugin_mycloud/README.md
12
+ create terraspace_plugin_mycloud/Rakefile
13
+ create terraspace_plugin_mycloud/bin/console
14
+ create terraspace_plugin_mycloud/bin/setup
15
+ create terraspace_plugin_mycloud/lib/templates/hcl/module/main.tf
16
+ create terraspace_plugin_mycloud/lib/templates/hcl/module/outputs.tf
17
+ create terraspace_plugin_mycloud/lib/templates/hcl/module/variables.tf
18
+ create terraspace_plugin_mycloud/lib/templates/hcl/project/config/terraform/backend.tf
19
+ create terraspace_plugin_mycloud/lib/templates/hcl/project/config/terraform/provider.tf
20
+ create terraspace_plugin_mycloud/lib/templates/hcl/stack/main.tf
21
+ create terraspace_plugin_mycloud/lib/templates/hcl/stack/outputs.tf
22
+ create terraspace_plugin_mycloud/lib/templates/hcl/stack/variables.tf
23
+ create terraspace_plugin_mycloud/lib/templates/ruby/module/main.rb
24
+ create terraspace_plugin_mycloud/lib/templates/ruby/module/outputs.rb
25
+ create terraspace_plugin_mycloud/lib/templates/ruby/module/variables.rb
26
+ create terraspace_plugin_mycloud/lib/templates/ruby/project/config/terraform/backend.rb
27
+ create terraspace_plugin_mycloud/lib/templates/ruby/project/config/terraform/provider.rb
28
+ create terraspace_plugin_mycloud/lib/templates/ruby/stack/main.rb
29
+ create terraspace_plugin_mycloud/lib/templates/ruby/stack/outputs.rb
30
+ create terraspace_plugin_mycloud/lib/templates/ruby/stack/variables.rb
31
+ create terraspace_plugin_mycloud/lib/templates/test/rspec/module/test/.rspec
32
+ create terraspace_plugin_mycloud/lib/templates/test/rspec/module/test/Gemfile
33
+ create terraspace_plugin_mycloud/lib/templates/test/rspec/module/test/spec/fixtures/stack/main.tf
34
+ create terraspace_plugin_mycloud/lib/templates/test/rspec/module/test/spec/fixtures/stack/outputs.tf
35
+ create terraspace_plugin_mycloud/lib/templates/test/rspec/module/test/spec/fixtures/stack/variables.tf
36
+ create terraspace_plugin_mycloud/lib/templates/test/rspec/module/test/spec/main_spec.rb
37
+ create terraspace_plugin_mycloud/lib/templates/test/rspec/module/test/spec/spec_helper.rb
38
+ create terraspace_plugin_mycloud/lib/terraspace_plugin_mycloud.rb
39
+ create terraspace_plugin_mycloud/lib/terraspace_plugin_mycloud/autoloader.rb
40
+ create terraspace_plugin_mycloud/lib/terraspace_plugin_mycloud/clients.rb
41
+ create terraspace_plugin_mycloud/lib/terraspace_plugin_mycloud/interfaces/backend.rb
42
+ create terraspace_plugin_mycloud/lib/terraspace_plugin_mycloud/interfaces/config.rb
43
+ create terraspace_plugin_mycloud/lib/terraspace_plugin_mycloud/interfaces/expander.rb
44
+ create terraspace_plugin_mycloud/lib/terraspace_plugin_mycloud/interfaces/layer.rb
45
+ create terraspace_plugin_mycloud/lib/terraspace_plugin_mycloud/version.rb
46
+ create terraspace_plugin_mycloud/spec/spec_helper.rb
47
+ create terraspace_plugin_mycloud/spec/terraspace_provider_mycloud_spec.rb
48
+ create terraspace_plugin_mycloud/terraspace_plugin_mycloud.gemspec
49
+ $
@@ -0,0 +1,40 @@
1
+ ## Example
2
+
3
+ $ terraspace new project infra --plugin aws --examples
4
+ => Creating new project called infra.
5
+ create infra
6
+ create infra/.gitignore
7
+ create infra/Gemfile
8
+ create infra/README.md
9
+ create infra/Terrafile
10
+ create infra/config/app.rb
11
+ exist infra
12
+ create infra/config/terraform/backend.tf
13
+ create infra/config/terraform/provider.tf
14
+ => Creating test for new module: example
15
+ create infra/app/modules/example
16
+ create infra/app/modules/example/main.tf
17
+ create infra/app/modules/example/outputs.tf
18
+ create infra/app/modules/example/variables.tf
19
+ => Creating new stack called demo.
20
+ create infra/app/stacks/demo
21
+ create infra/app/stacks/demo/main.tf
22
+ create infra/app/stacks/demo/outputs.tf
23
+ create infra/app/stacks/demo/variables.tf
24
+ => Creating test bootstrap structure
25
+ exist infra
26
+ create infra/.rspec
27
+ create infra/spec/spec_helper.rb
28
+ => Installing dependencies with: bundle install
29
+ Bundle complete! 3 Gemfile dependencies, 88 gems now installed.
30
+ Use `bundle info [gemname]` to see where a bundled gem is installed.
31
+ ================================================================
32
+ Congrats! You have successfully created a terraspace project.
33
+ Check out the created files. Adjust to the examples and then deploy with:
34
+
35
+ cd infra
36
+ terraspace up demo -y # to deploy
37
+ terraspace down demo -y # to destroy
38
+
39
+ More info: https://terraspace.cloud/
40
+ $
@@ -0,0 +1,8 @@
1
+ ## Example
2
+
3
+ $ terraspace new project_test demo
4
+ => Creating project test: demo
5
+ exist
6
+ create spec/fixtures/tfvars/demo.tfvars
7
+ create spec/stacks/demo/main_spec.rb
8
+ $
@@ -0,0 +1,21 @@
1
+ ## Example
2
+
3
+ $ terraspace new shim
4
+ A terraspace shim as been generated at /usr/local/bin/terraspace
5
+ Please make sure that it is found in the $PATH.
6
+
7
+ You can double check with:
8
+
9
+ which terraspace
10
+
11
+ You should see
12
+
13
+ $ which terraspace
14
+ /usr/local/bin/terraspace
15
+
16
+ If you do not, please add /usr/local/bin to your PATH.
17
+ You can usually do so by adding this line to ~/.bash_profile and opening a new terminal to check.
18
+
19
+ export PATH=/usr/local/bin:/$PATH
20
+
21
+ $
@@ -0,0 +1,9 @@
1
+ ## Example
2
+
3
+ $ terraspace new stack demo
4
+ => Creating new stack called demo.
5
+ create app/stacks/demo
6
+ create app/stacks/demo/main.tf
7
+ create app/stacks/demo/outputs.tf
8
+ create app/stacks/demo/variables.tf
9
+ $
@@ -0,0 +1,6 @@
1
+ ## Example
2
+
3
+ $ terraspace output demo
4
+ => terraform output
5
+ bucket_name = bucket-fond-sheep
6
+ $
@@ -0,0 +1,29 @@
1
+ ## Example
2
+
3
+ $ terraspace plan demo
4
+ => terraform plan
5
+ Refreshing Terraform state in-memory prior to plan...
6
+ The refreshed state will be used to calculate this plan, but will not be
7
+ persisted to local or remote state storage.
8
+
9
+ random_pet.this: Refreshing state... [id=fond-sheep]
10
+ module.bucket.aws_s3_bucket.this: Refreshing state... [id=bucket-fond-sheep]
11
+
12
+ ------------------------------------------------------------------------
13
+
14
+ An execution plan has been generated and is shown below.
15
+ Resource actions are indicated with the following symbols:
16
+ -/+ destroy and then create replacement
17
+ ...
18
+ Plan: 2 to add, 0 to change, 2 to destroy.
19
+
20
+ Changes to Outputs:
21
+ ~ bucket_name = "bucket-fond-sheep" -> (known after apply)
22
+
23
+ ------------------------------------------------------------------------
24
+
25
+ Note: You didn't specify an "-out" parameter to save this plan, so Terraform
26
+ can't guarantee that exactly these actions will be performed if
27
+ "terraform apply" is subsequently run.
28
+
29
+ $
@@ -0,0 +1,18 @@
1
+ ## Example
2
+
3
+ $ terraspace providers demo
4
+ => terraform providers
5
+
6
+ Providers required by configuration:
7
+ .
8
+ ├── provider[registry.terraform.io/hashicorp/random]
9
+ └── module.bucket
10
+ └── provider[registry.terraform.io/hashicorp/aws]
11
+
12
+ Providers required by state:
13
+
14
+ provider[registry.terraform.io/hashicorp/aws]
15
+
16
+ provider[registry.terraform.io/hashicorp/random]
17
+
18
+ $
@@ -0,0 +1,11 @@
1
+ ## Example
2
+
3
+ $ terraspace refresh demo
4
+ => terraform refresh
5
+ random_pet.this: Refreshing state... [id=fond-sheep]
6
+ module.bucket.aws_s3_bucket.this: Refreshing state... [id=bucket-fond-sheep]
7
+
8
+ Outputs:
9
+
10
+ bucket_name = bucket-fond-sheep
11
+ $
@@ -0,0 +1,7 @@
1
+ ## Example
2
+
3
+ $ terraspace seed demo
4
+ Seeding tfvar files for demo
5
+ Reading: .terraspace-cache/us-west-2/dev/stacks/demo/variables.tf
6
+ create app/stacks/demo/tfvars/dev.tfvars
7
+ $
@@ -0,0 +1,36 @@
1
+ ## Example
2
+
3
+ $ terraspace show demo
4
+ => terraform show
5
+ # random_pet.this:
6
+ resource "random_pet" "this" {
7
+ id = "fond-sheep"
8
+ length = 2
9
+ separator = "-"
10
+ }
11
+
12
+ # module.bucket.aws_s3_bucket.this:
13
+ resource "aws_s3_bucket" "this" {
14
+ acl = "private"
15
+ arn = "arn:aws:s3:::bucket-fond-sheep"
16
+ bucket = "bucket-fond-sheep"
17
+ bucket_domain_name = "bucket-fond-sheep.s3.amazonaws.com"
18
+ bucket_regional_domain_name = "bucket-fond-sheep.s3.us-west-2.amazonaws.com"
19
+ force_destroy = false
20
+ hosted_zone_id = "Z3BJ6K6RIION7M"
21
+ id = "bucket-fond-sheep"
22
+ region = "us-west-2"
23
+ request_payer = "BucketOwner"
24
+ tags = {}
25
+
26
+ versioning {
27
+ enabled = false
28
+ mfa_delete = false
29
+ }
30
+ }
31
+
32
+
33
+ Outputs:
34
+
35
+ bucket_name = "bucket-fond-sheep"
36
+ $
@@ -0,0 +1,11 @@
1
+ ## Example
2
+
3
+ $ terraspace summary
4
+ Summary of resources based on backend storage statefiles
5
+ Downloading statefiles to /tmp/terraspace/statefiles/terraform-state-111111111111-us-west-2-dev/us-west-2/dev/
6
+ stacks/demo/terraform.tfstate
7
+ random_pet this: sunny-chicken
8
+ aws_s3_bucket this: bucket-sunny-chicken
9
+ $
10
+
11
+ Also, check out `terraspace all show`.
@@ -0,0 +1,35 @@
1
+ ## Example
2
+
3
+ Terraspace test just calls the configured test framework, by default, rspec.
4
+ Here's an example with output cleaned up to reduce noise:
5
+
6
+ $ terraspace test
7
+ => rspec
8
+
9
+ main
10
+ Building test harness...
11
+ ...
12
+ Test harness built: /tmp/terraspace/test-harnesses/demo-harness
13
+ => terraspace up demo -y
14
+ Building .terraspace-cache/us-west-2/test/stacks/demo
15
+ Built in .terraspace-cache/us-west-2/test/stacks/demo
16
+ Current directory: .terraspace-cache/us-west-2/test/stacks/demo
17
+ => terraform init -get >> /tmp/terraspace/log/init/demo.log
18
+ => terraform plan -out /tmp/terraspace/plans/demo-20200920160313.plan
19
+ ...
20
+ => terraform apply -auto-approve /tmp/terraspace/plans/demo-20200920160313.plan
21
+ ...
22
+ => terraform destroy -auto-approve
23
+ random_pet.this: Refreshing state... [id=hopelessly-outgoing-serval]
24
+ module.bucket.aws_s3_bucket.this: Refreshing state... [id=bucket-hopelessly-outgoing-serval]
25
+ module.bucket.aws_s3_bucket.this: Destroying... [id=bucket-hopelessly-outgoing-serval]
26
+ module.bucket.aws_s3_bucket.this: Destruction complete after 0s
27
+ random_pet.this: Destroying... [id=hopelessly-outgoing-serval]
28
+ random_pet.this: Destruction complete after 0s
29
+
30
+ Destroy complete! Resources: 2 destroyed.
31
+ Time took: 5s
32
+
33
+ Finished in 22.08 seconds (files took 0.48602 seconds to load)
34
+ 1 example, 0 failures
35
+ $
@@ -0,0 +1,30 @@
1
+ ## Example
2
+
3
+ $ terraspace up demo
4
+ Building .terraspace-cache/us-west-2/dev/stacks/demo
5
+ Built in .terraspace-cache/us-west-2/dev/stacks/demo
6
+ Current directory: .terraspace-cache/us-west-2/dev/stacks/demo
7
+ => terraform apply
8
+ ...
9
+ Plan: 2 to add, 0 to change, 0 to destroy.
10
+
11
+ Changes to Outputs:
12
+ + bucket_name = (known after apply)
13
+
14
+ Do you want to perform these actions?
15
+ Terraform will perform the actions described above.
16
+ Only 'yes' will be accepted to approve.
17
+ Enter a value: yes
18
+
19
+ random_pet.this: Creating...
20
+ random_pet.this: Creation complete after 0s [id=trusty-marmoset]
21
+ module.bucket.aws_s3_bucket.this: Creating...
22
+ module.bucket.aws_s3_bucket.this: Creation complete after 2s [id=bucket-trusty-marmoset]
23
+
24
+ Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
25
+
26
+ Outputs:
27
+
28
+ bucket_name = bucket-trusty-marmoset
29
+ Time took: 39s
30
+ $
@@ -0,0 +1,9 @@
1
+ ## Example
2
+
3
+ $ terraspace validate demo
4
+ Building .terraspace-cache/us-west-2/dev/stacks/demo
5
+ Built in .terraspace-cache/us-west-2/dev/stacks/demo
6
+ Current directory: .terraspace-cache/us-west-2/dev/stacks/demo
7
+ => terraform validate
8
+ Success! The configuration is valid.
9
+ $
@@ -3,26 +3,14 @@ class Terraspace::CLI
3
3
  extend Memoist
4
4
 
5
5
  def run
6
- format = @options[:format] || "text"
7
- send("#{format}_output")
8
- end
9
-
10
- def json_output
11
- puts JSON.pretty_generate(info)
12
- end
13
-
14
- def text_output
6
+ presenter = CliFormat::Presenter.new(@options)
7
+ presenter.header = %w[Name Value]
15
8
  info.each do |k,v|
16
- k = "%-#{rpad}s" % k
17
- puts "#{k} #{v}"
9
+ presenter.rows << [k, v]
18
10
  end
11
+ presenter.show
19
12
  end
20
13
 
21
- def rpad
22
- info.keys.map(&:size).max
23
- end
24
- memoize :rpad
25
-
26
14
  def info
27
15
  @mod.to_info
28
16
  end
@@ -67,7 +67,7 @@ class Terraspace::CLI
67
67
  mode = ENV['TS_INIT_MODE'] || Terraspace.config.init.mode
68
68
  case mode.to_sym
69
69
  when :auto
70
- !already_initialized?
70
+ !already_init?
71
71
  when :always
72
72
  true
73
73
  when :never
@@ -80,16 +80,12 @@ class Terraspace::CLI
80
80
  # Traverse symlink dirs also: linux_amd64 is a symlink
81
81
  # plugins/registry.terraform.io/hashicorp/google/3.39.0/linux_amd64/terraform-provider-google_v3.39.0_x5
82
82
  #
83
- # Check modules/modules.json also because during the tfvars dependency pass main.tf modules are not built.
84
- # So init happens again during the second pass.
85
- #
86
- def already_initialized?
83
+ def already_init?
87
84
  terraform = "#{@mod.cache_dir}/.terraform"
88
85
  provider = Dir.glob("#{terraform}/**{,/*/**}/*").find do |path|
89
86
  path.include?("terraform-provider-")
90
87
  end
91
- modules = File.exist?("#{terraform}/modules/modules.json")
92
- !!(provider && modules)
88
+ !!provider
93
89
  end
94
90
  end
95
91
  end
@@ -6,7 +6,8 @@ class Terraspace::CLI
6
6
  end
7
7
 
8
8
  def run
9
- Dir.glob("{app,vendor}/{modules,stacks}/*").sort.each do |path|
9
+ dirs = Dir.glob("{app,vendor}/{modules,stacks}/*").select { |p| File.directory?(p) }
10
+ dirs.sort.each do |path|
10
11
  if @type_dir
11
12
  puts path if path.include?("/#{@type_dir}/")
12
13
  else