terraspace 0.1.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +35 -2
- data/README.md +20 -12
- data/lib/templates/base/git_hook/hook.sh +5 -0
- data/lib/templates/base/project/.gitignore +0 -1
- data/lib/templates/base/shim/terraspace +7 -0
- data/lib/templates/hcl/project/config/terraform/backend.tf.tt +3 -3
- data/lib/templates/plugin/lib/templates/hcl/project/config/terraform/backend.tf.tt +2 -2
- data/lib/terraspace/app.rb +8 -0
- data/lib/terraspace/builder.rb +6 -45
- data/lib/terraspace/cli.rb +34 -18
- data/lib/terraspace/cli/build/placeholder.rb +40 -0
- data/lib/terraspace/cli/cloud.rb +24 -0
- data/lib/terraspace/cli/commander.rb +8 -1
- data/lib/terraspace/cli/init.rb +67 -0
- data/lib/terraspace/cli/list.rb +13 -0
- data/lib/terraspace/cli/new.rb +8 -0
- data/lib/terraspace/cli/new/git_hook.rb +33 -0
- data/lib/terraspace/cli/new/shim.rb +58 -0
- data/lib/terraspace/cli/summary.rb +9 -12
- data/lib/terraspace/compiler/backend.rb +9 -37
- data/lib/terraspace/compiler/backend/parser.rb +42 -0
- data/lib/terraspace/compiler/builder.rb +6 -2
- data/lib/terraspace/compiler/cleaner.rb +19 -2
- data/lib/terraspace/compiler/cleaner/backend_change.rb +1 -1
- data/lib/terraspace/compiler/dsl/syntax/mod.rb +1 -0
- data/lib/terraspace/compiler/dsl/syntax/mod/backend.rb +16 -3
- data/lib/terraspace/compiler/expander.rb +28 -1
- data/lib/terraspace/compiler/writer.rb +1 -1
- data/lib/terraspace/core.rb +7 -1
- data/lib/terraspace/mod.rb +37 -12
- data/lib/terraspace/mod/remote.rb +1 -1
- data/lib/terraspace/plugin/expander/interface.rb +48 -5
- data/lib/terraspace/plugin/infer_provider.rb +15 -0
- data/lib/terraspace/plugin/layer/interface.rb +5 -0
- data/lib/terraspace/plugin/summary/interface.rb +1 -0
- data/lib/terraspace/seeder.rb +4 -4
- data/lib/terraspace/terraform/api.rb +58 -0
- data/lib/terraspace/terraform/api/client.rb +10 -0
- data/lib/terraspace/terraform/api/http.rb +106 -0
- data/lib/terraspace/terraform/api/var.rb +72 -0
- data/lib/terraspace/terraform/api/vars.rb +38 -0
- data/lib/terraspace/terraform/api/vars/base.rb +7 -0
- data/lib/terraspace/terraform/api/vars/json.rb +14 -0
- data/lib/terraspace/terraform/api/vars/rb.rb +21 -0
- data/lib/terraspace/terraform/args/custom.rb +1 -1
- data/lib/terraspace/terraform/args/default.rb +16 -2
- data/lib/terraspace/terraform/cloud.rb +25 -0
- data/lib/terraspace/terraform/cloud/workspace.rb +95 -0
- data/lib/terraspace/terraform/runner.rb +1 -1
- data/lib/terraspace/util/sh.rb +1 -1
- data/lib/terraspace/version.rb +1 -1
- data/spec/fixtures/{cache_build_dir → cache_dir}/variables.tf +0 -0
- data/spec/fixtures/projects/hcl/aws/config/backend.tf +1 -1
- data/spec/fixtures/projects/hcl/google/config/backend.tf +1 -1
- data/spec/terraspace/seeder_spec.rb +1 -1
- data/spec/terraspace/terraform/hooks/builder_spec.rb +1 -1
- data/terraspace.gemspec +5 -4
- metadata +47 -13
- data/lib/terraspace/cli/build.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfffe08e9ea588c9c01b6e6bfb0c3399047391acf17eac9d74c8d4643ba4722b
|
4
|
+
data.tar.gz: f887084702cab528ef80c786bbacf5ce5e7e7f56938b96bce2cc4c85da8d0549
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe9ec67940c66eaf3f091b2e9dc7eaec2252ad8e1b134c11faaf4fc03befdb840c2e5222cf6204d879d6b5f0221f506457245910c236785c0caee8c58528352d
|
7
|
+
data.tar.gz: 725d3091bad4ea62ccb7e9fbb49dcb124c235e5ec810278b301fa859ba3c9721f8b616528cb777dd5e17a233b66bc6804ecef605b922364e8634b3e16a4204c9
|
data/CHANGELOG.md
CHANGED
@@ -3,8 +3,41 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [0.2.3]
|
7
|
+
* #37 config.clean_cache option
|
8
|
+
|
9
|
+
## [0.2.2]
|
10
|
+
* #36 cloud.relative_root setting
|
11
|
+
|
12
|
+
## [0.2.1]
|
13
|
+
* #35 fix summary bug when ran multiple times with different envs
|
14
|
+
|
15
|
+
## [0.2.0]
|
16
|
+
* #34 Terraform Cloud and Terraform Enterprise support added.
|
17
|
+
* TFC Vars support: JSON and DSL. config.overwrite and config.overwrite_sensitive configs
|
18
|
+
* Build all stacks with config/terraform files. Designed to support the TFC VCS-driven workflow.
|
19
|
+
* Layer Interface module added. All latest provider plugins like terraspace\_plugin_aws make use of this module.
|
20
|
+
* Backend pattern expansion auto-detects the provider bakcend. The `expansion` method replaces the `backend_expand` method. `backend_expand` is deprecated.
|
21
|
+
* New expander variables: TYPE_INSTANCE, INSTANCE, CACHE_ROOT. Also added strip trailing - and / behavior.
|
22
|
+
* Timeout for terraform init. The default timeout is 10m and will then print out the terraform init log.
|
23
|
+
* Terraspace 0.2.x is compatible with terraspace\_plugin_aws 0.2.x, terraspace\_plugin_google 0.2.x, and terraspace\_plugin_azurerm 0.2.x
|
24
|
+
* New commands: terraspace list, terraspace cloud list, terraspace cloud setup, terraspace cloud destroy, terraspace new shim, terraspace new git_hook
|
25
|
+
* terraspace list: list of modules and stacks
|
26
|
+
* terraspace cloud list: shows list of TFC workspaces
|
27
|
+
* terraspace cloud setup: setups up TFC workspace for VCS-driven workflow. This automatically happens for the TFC CLI-driven workflow.
|
28
|
+
* terraspace cloud destroy: destroys the TFC workspace associated with the stack. Can also use the `terraspace down demo --destroy-workspace` option.
|
29
|
+
* terraspace new shim: An quick way to generate a terraspace shim.
|
30
|
+
* terraspace new git_hook: An quick way to set up a git pre-push hook for the TFC VCS-driven workflow.
|
31
|
+
* terraspace down: works even if there's no app/stacks folder. A fake stack is built.
|
32
|
+
* terraspace build: terraspace build placeholder concept.
|
33
|
+
* terraspace build: only builds now. auto bucket backend creation and terraform init is is still automatically called by terraform up, etc.
|
34
|
+
* terraspace up: --reconfigure option. This is useful if upgrading Terraform version.
|
35
|
+
|
36
|
+
## [0.1.2]
|
37
|
+
* #33 rspec-terraspace dependency added
|
38
|
+
|
6
39
|
## [0.1.1]
|
7
|
-
|
40
|
+
* #32 terraspace summary --short option
|
8
41
|
|
9
42
|
## [0.1.0]
|
10
|
-
|
43
|
+
* Initial release
|
data/README.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
<div align="center">
|
2
|
+
<a href="https://terraspace.cloud"><img src="https://img.boltops.com/boltops/logos/terraspace-dark-v2.png" /></a>
|
3
|
+
</div>
|
4
|
+
|
1
5
|
# Terraspace
|
2
6
|
|
3
7
|
[![Gem Version](https://badge.fury.io/rb/terraspace.png)](http://badge.fury.io/rb/terraspace)
|
@@ -8,6 +12,10 @@ The Terraform Framework.
|
|
8
12
|
|
9
13
|
Official Docs Site: [terraspace.cloud](https://terraspace.cloud)
|
10
14
|
|
15
|
+
Introduction Video:
|
16
|
+
|
17
|
+
[![Watch the video](https://img.boltops.com/boltops/tools/terraspace/terraspace-youtube.png)](https://www.youtube.com/watch?v=O87t5q22YNc)
|
18
|
+
|
11
19
|
## Quick Start
|
12
20
|
|
13
21
|
Here are commands to get started:
|
@@ -17,8 +25,8 @@ Here are commands to get started:
|
|
17
25
|
terraspace up demo
|
18
26
|
terraspace down demo
|
19
27
|
|
20
|
-
* The `new` command generates a starter project.
|
21
|
-
* The `up` command creates an s3 bucket.
|
28
|
+
* The `new` command generates a starter project.
|
29
|
+
* The `up` command creates an s3 bucket.
|
22
30
|
* The `down` command cleans up and deletes the bucket.
|
23
31
|
|
24
32
|
The default plugin is aws. Other plugins also supported are: google and azurerm.
|
@@ -28,10 +36,10 @@ The default plugin is aws. Other plugins also supported are: google and azurerm.
|
|
28
36
|
Create infrastructure:
|
29
37
|
|
30
38
|
$ terraspace up demo -y
|
31
|
-
Building .terraspace-cache/dev/stacks/demo
|
32
|
-
Current directory: .terraspace-cache/dev/stacks/demo
|
33
|
-
=> terraform init -get > /
|
34
|
-
Built in .terraspace-cache/dev/stacks/demo
|
39
|
+
Building .terraspace-cache/us-west-2/dev/stacks/demo
|
40
|
+
Current directory: .terraspace-cache/us-west-2/dev/stacks/demo
|
41
|
+
=> terraform init -get > /tmp/terraspace/out/terraform-init20200824-21379-bkfvnh.out
|
42
|
+
Built in .terraspace-cache/us-west-2/dev/stacks/demo
|
35
43
|
=> terraform apply -auto-approve
|
36
44
|
random_pet.bucket: Creating...
|
37
45
|
random_pet.bucket: Creation complete after 0s [id=amusing-mouse]
|
@@ -48,10 +56,10 @@ Create infrastructure:
|
|
48
56
|
Destroy infrastructure:
|
49
57
|
|
50
58
|
$ terraspace down demo -y
|
51
|
-
Building .terraspace-cache/dev/stacks/demo
|
52
|
-
Current directory: .terraspace-cache/dev/stacks/demo
|
53
|
-
=> terraform init -get > /
|
54
|
-
Built in .terraspace-cache/dev/stacks/demo
|
59
|
+
Building .terraspace-cache/us-west-2/dev/stacks/demo
|
60
|
+
Current directory: .terraspace-cache/us-west-2/dev/stacks/demo
|
61
|
+
=> terraform init -get > /tmp/terraspace/out/terraform-init20200824-21379-bkfvnh.out
|
62
|
+
Built in .terraspace-cache/us-west-2/dev/stacks/demo
|
55
63
|
=> terraform destroy -auto-approve
|
56
64
|
random_pet.bucket: Refreshing state... [id=amusing-mouse]
|
57
65
|
module.bucket.aws_s3_bucket.this: Refreshing state... [id=bucket-amusing-mouse]
|
@@ -67,9 +75,9 @@ Destroy infrastructure:
|
|
67
75
|
|
68
76
|
* [Config Structure](https://terraspace.cloud/docs/config/): A common config structure that gets materializes with the deployed module. Configs can be dynamically controlled to keep your code DRY. You can override the settings if needed, like for using existing backends. See: [Existing Backends](https://terraspace.cloud/docs/state/existing/).
|
69
77
|
* [Generators](https://terraspace.cloud/docs/generators/): Built-in generators to quickly create the starter module. Focus on code instead of boilerplate structure.
|
70
|
-
* [Tfvars](https://terraspace.cloud/docs/tfvars/): Use the same code with different tfvars to create multiple environments. Terraspace conventionally loads tfvars from the `tfvars` folder.
|
71
|
-
* [Layering](https://terraspace.cloud/docs/tfvars/layering/): Rich layering support. This allows you to build different environments like dev and prod with the same code.
|
78
|
+
* [Tfvars](https://terraspace.cloud/docs/tfvars/) & [Layering](https://terraspace.cloud/docs/tfvars/layering/): Use the same code with different tfvars to create multiple environments. Terraspace conventionally loads tfvars from the `tfvars` folder. Rich layering support allows you to build different environments like dev and prod with the same code. Examples are in [Full Layering](https://terraspace.cloud/docs/tfvars/full-layering/).
|
72
79
|
* [Testing](https://terraspace.cloud/docs/testing/): A testing framework that allows you to create test harnesses, deploy real-resources, and have higher confidence that your code works.
|
73
80
|
* [Configurable CLI](https://terraspace.cloud/docs/cli/): Configurable [CLI Hooks](https://terraspace.cloud/docs/cli/hooks/) and [CLI Args](https://terraspace.cloud/docs/cli/args/) allow you to adjust the underlying terraform command.
|
81
|
+
* [Terraform Cloud and Terraform Enterprise Support](https://terraspace.cloud/docs/cloud/): TFC and TFE are both supported. Terraspace adds additional conveniences to make working with Terraform Cloud Workspaces easier.
|
74
82
|
|
75
83
|
For more info: [terraspace.cloud](https://terraspace.cloud)
|
@@ -3,8 +3,8 @@
|
|
3
3
|
# terraform {
|
4
4
|
# backend "s3" {
|
5
5
|
# bucket = "<%= options[:bucket] || "terraform-state-:ACCOUNT-:REGION-:ENV" %>"
|
6
|
-
# key = "<%%= "
|
7
|
-
# region = "<%%= "
|
6
|
+
# key = "<%%= expansion(":REGION/:ENV/:BUILD_DIR/terraform.tfstate") %> # IE: us-west-2/dev/ec2/modules/vpc/terraform.tfstate
|
7
|
+
# region = "<%%= expansion(":REGION") %>"
|
8
8
|
# encrypt = true
|
9
9
|
# dynamodb_table = "terraform_locks"
|
10
10
|
# }
|
@@ -13,6 +13,6 @@
|
|
13
13
|
# terraform {
|
14
14
|
# backend "gcs" {
|
15
15
|
# bucket = "<%= options[:bucket] || "terraform-state-:PROJECT-:REGION-:ENV" %>"
|
16
|
-
# prefix = "<%%=
|
16
|
+
# prefix = "<%%= expansion(":REGION/:ENV/:BUILD_DIR") %>" # IE: us-central1/dev/modules/vm
|
17
17
|
# }
|
18
18
|
# }
|
@@ -1,6 +1,6 @@
|
|
1
1
|
terraform {
|
2
2
|
backend "PROVIDER_BACKEND" {
|
3
|
-
bucket = "<%%=
|
4
|
-
prefix = "<%%=
|
3
|
+
bucket = "<%%= expansion("terraform-state-REPLACE_ME-REPLACE_ME-:ENV") %>" # expanded by terraspace
|
4
|
+
prefix = "<%%= expansion("REPLACE_ME/:ENV/:BUILD_DIR") %>" # expanded by terraspace
|
5
5
|
}
|
6
6
|
}
|
data/lib/terraspace/app.rb
CHANGED
@@ -14,6 +14,14 @@ module Terraspace
|
|
14
14
|
config.logger = Logger.new($stdout)
|
15
15
|
config.logger.level = :info
|
16
16
|
config.hooks = Hooks.new
|
17
|
+
config.cloud = ActiveSupport::OrderedOptions.new
|
18
|
+
config.cloud.overwrite = true
|
19
|
+
config.cloud.overwrite_sensitive = true
|
20
|
+
config.cloud.relative_root = nil
|
21
|
+
config.build = ActiveSupport::OrderedOptions.new
|
22
|
+
config.build.cache_root = nil # defaults to /full/path/to/.terraspace-cache
|
23
|
+
config.build.cache_dir = ":CACHE_ROOT/:REGION/:ENV/:BUILD_DIR"
|
24
|
+
config.build.clean_cache = nil # defaults to /full/path/to/.terraspace-cache
|
17
25
|
config
|
18
26
|
end
|
19
27
|
|
data/lib/terraspace/builder.rb
CHANGED
@@ -3,25 +3,16 @@ module Terraspace
|
|
3
3
|
def run
|
4
4
|
Terraspace::CLI::CheckSetup.check!
|
5
5
|
@mod.root_module = true
|
6
|
-
Compiler::Cleaner.new(@mod, @options).clean
|
7
|
-
build_dir = Util.pretty_path(@mod.
|
6
|
+
Compiler::Cleaner.new(@mod, @options).clean if clean?
|
7
|
+
build_dir = Util.pretty_path(@mod.cache_dir)
|
8
8
|
logger.info "Building #{build_dir}"
|
9
9
|
|
10
10
|
build_all("modules") # build all modules and stacks as dependencies
|
11
11
|
build_all("stacks")
|
12
|
-
build_root_module
|
13
|
-
|
14
|
-
auto_create_backend
|
15
|
-
Terraform::Runner.new("init", @options).run if !auto? && @options[:init] != false # will run on @options[:init].nil?
|
16
|
-
build_remote_dependencies # runs after terraform init, which downloads remote modules
|
12
|
+
build_root_module
|
17
13
|
logger.info "Built in #{build_dir}"
|
18
14
|
end
|
19
15
|
|
20
|
-
def auto?
|
21
|
-
# command is only passed from CLI in the update specifically for this check
|
22
|
-
@options[:auto] && @options[:command] == "update"
|
23
|
-
end
|
24
|
-
|
25
16
|
def build_root_module
|
26
17
|
Compiler::Builder.new(@mod).build
|
27
18
|
end
|
@@ -35,22 +26,12 @@ module Terraspace
|
|
35
26
|
|
36
27
|
consider_stacks = type_dir == "stacks"
|
37
28
|
mod = Mod.new(mod_name, consider_stacks: consider_stacks)
|
38
|
-
next if root?(mod) # will build root module at the end
|
39
29
|
|
40
30
|
Compiler::Builder.new(mod).build
|
41
31
|
built << mod_name
|
42
32
|
end
|
43
33
|
end
|
44
34
|
|
45
|
-
def root?(mod)
|
46
|
-
mod.name == @mod.name && mod.type == @mod.type
|
47
|
-
end
|
48
|
-
|
49
|
-
def auto_create_backend
|
50
|
-
return unless @options[:command] == "update"
|
51
|
-
Compiler::Backend.new(@mod).create
|
52
|
-
end
|
53
|
-
|
54
35
|
def local_paths(type_dir)
|
55
36
|
dirs("app/#{type_dir}/*") + dirs("vendor/#{type_dir}/*")
|
56
37
|
end
|
@@ -59,29 +40,9 @@ module Terraspace
|
|
59
40
|
Dir.glob("#{Terraspace.root}/#{path}")
|
60
41
|
end
|
61
42
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
return unless File.exist?(modules_json_path)
|
66
|
-
|
67
|
-
initialized_modules = JSON.load(IO.read(modules_json_path))
|
68
|
-
# For example of structure see spec/fixtures/initialized/modules.json
|
69
|
-
initialized_modules["Modules"].each do |meta|
|
70
|
-
build_remote_mod(meta)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def build_remote_mod(meta)
|
75
|
-
return if local_source?(meta["Source"])
|
76
|
-
return if meta['Dir'] == '.' # root is already built
|
77
|
-
|
78
|
-
remote_mod = Mod::Remote.new(meta, @mod)
|
79
|
-
Compiler::Builder.new(remote_mod).build
|
80
|
-
end
|
81
|
-
|
82
|
-
private
|
83
|
-
def local_source?(s)
|
84
|
-
s =~ %r{^\.} || s =~ %r{^/}
|
43
|
+
def clean?
|
44
|
+
clean_cache = Terraspace.config.build.clean_cache
|
45
|
+
clean_cache.nil? ? true : clean_cache
|
85
46
|
end
|
86
47
|
end
|
87
48
|
end
|
data/lib/terraspace/cli.rb
CHANGED
@@ -24,20 +24,25 @@ module Terraspace
|
|
24
24
|
init_option = Proc.new {
|
25
25
|
option :init, type: :boolean, default: true, desc: "Instance of stack"
|
26
26
|
}
|
27
|
+
reconfigure_option = Proc.new {
|
28
|
+
option :reconfigure, type: :boolean, desc: "Add terraform -reconfigure option"
|
29
|
+
}
|
27
30
|
|
28
31
|
desc "new SUBCOMMAND", "new subcommands"
|
29
32
|
long_desc Help.text(:new)
|
30
33
|
subcommand "new", New
|
31
34
|
|
32
|
-
desc "
|
35
|
+
desc "cloud SUBCOMMAND", "cloud subcommands"
|
36
|
+
long_desc Help.text(:cloud)
|
37
|
+
subcommand "cloud", Cloud
|
38
|
+
|
39
|
+
desc "build STACK", "build"
|
33
40
|
long_desc Help.text(:build)
|
34
41
|
option :quiet, type: :boolean, default: true, desc: "quiet output"
|
35
|
-
auto_option.call
|
36
|
-
init_option.call
|
37
|
-
input_option.call
|
38
42
|
instance_option.call
|
43
|
+
yes_option.call
|
39
44
|
def build(mod)
|
40
|
-
|
45
|
+
Terraspace::Builder.new(@options.merge(mod: mod)).run
|
41
46
|
end
|
42
47
|
|
43
48
|
desc "bundle", "bundle"
|
@@ -58,22 +63,25 @@ module Terraspace
|
|
58
63
|
Clean.new(options).run
|
59
64
|
end
|
60
65
|
|
61
|
-
desc "console", "console .terraspace-cache dir"
|
66
|
+
desc "console STACK", "console .terraspace-cache dir"
|
62
67
|
long_desc Help.text(:console)
|
63
68
|
instance_option.call
|
64
69
|
def console(mod)
|
65
70
|
Commander.new("console", options.merge(mod: mod)).run
|
66
71
|
end
|
67
72
|
|
68
|
-
desc "down
|
73
|
+
desc "down STACK", "down"
|
69
74
|
long_desc Help.text(:down)
|
70
75
|
instance_option.call
|
71
76
|
yes_option.call
|
77
|
+
reconfigure_option.call
|
78
|
+
option :destroy_workspace, type: :boolean, desc: "Also destroy the Cloud workspace. Only applies when using Terraform Cloud remote backend."
|
72
79
|
def down(mod)
|
73
|
-
Commander.new("destroy", options.merge(mod: mod)).run
|
80
|
+
Commander.new("destroy", options.merge(mod: mod, command: "down")).run
|
81
|
+
Terraspace::Terraform::Cloud::Workspace.new(options.merge(mod: mod)).destroy if @options[:destroy_workspace]
|
74
82
|
end
|
75
83
|
|
76
|
-
desc "info
|
84
|
+
desc "info STACK", "info"
|
77
85
|
long_desc Help.text(:info)
|
78
86
|
format_option.call
|
79
87
|
instance_option.call
|
@@ -81,31 +89,38 @@ module Terraspace
|
|
81
89
|
Info.new(options.merge(mod: mod)).run
|
82
90
|
end
|
83
91
|
|
84
|
-
desc "
|
92
|
+
desc "list", "list stacks and modules"
|
93
|
+
long_desc Help.text(:list)
|
94
|
+
def list
|
95
|
+
List.new(options).run
|
96
|
+
end
|
97
|
+
|
98
|
+
desc "plan STACK", "plan stack"
|
85
99
|
long_desc Help.text(:plan)
|
86
100
|
auto_option.call
|
87
101
|
input_option.call
|
88
102
|
instance_option.call
|
89
103
|
out_option.call
|
104
|
+
reconfigure_option.call
|
90
105
|
def plan(mod)
|
91
106
|
Commander.new("plan", options.merge(mod: mod)).run
|
92
107
|
end
|
93
108
|
|
94
|
-
desc "providers
|
109
|
+
desc "providers STACK", "providers"
|
95
110
|
long_desc Help.text(:providers)
|
96
111
|
instance_option.call
|
97
112
|
def providers(mod)
|
98
113
|
Commander.new("providers", options.merge(mod: mod)).run
|
99
114
|
end
|
100
115
|
|
101
|
-
desc "refresh", "refresh"
|
116
|
+
desc "refresh STACK", "refresh"
|
102
117
|
long_desc Help.text(:refresh)
|
103
118
|
instance_option.call
|
104
119
|
def refresh(mod)
|
105
120
|
Commander.new("refresh", options.merge(mod: mod)).run
|
106
121
|
end
|
107
122
|
|
108
|
-
desc "seed
|
123
|
+
desc "seed STACK", "seed"
|
109
124
|
long_desc Help.text(:seed)
|
110
125
|
option :yes, aliases: :y, type: :boolean, desc: "bypass prompts and force overwrite files"
|
111
126
|
option :where, desc: "where to create file. either under app or seed folder structure. values: app or stack"
|
@@ -124,7 +139,7 @@ module Terraspace
|
|
124
139
|
Summary.new(options).run
|
125
140
|
end
|
126
141
|
|
127
|
-
desc "show
|
142
|
+
desc "show STACK", "show"
|
128
143
|
long_desc Help.text(:show)
|
129
144
|
instance_option.call
|
130
145
|
def show(mod)
|
@@ -137,7 +152,7 @@ module Terraspace
|
|
137
152
|
Test.new(options).run
|
138
153
|
end
|
139
154
|
|
140
|
-
desc "output
|
155
|
+
desc "output STACK", "output"
|
141
156
|
long_desc Help.text(:output)
|
142
157
|
format_option.call
|
143
158
|
instance_option.call
|
@@ -146,20 +161,21 @@ module Terraspace
|
|
146
161
|
Commander.new("output", options.merge(mod: mod)).run
|
147
162
|
end
|
148
163
|
|
149
|
-
desc "update
|
164
|
+
desc "update STACK", "Update infrasturcture. IE: apply plan"
|
150
165
|
long_desc Help.text(:update)
|
151
166
|
auto_option.call
|
152
167
|
init_option.call
|
153
168
|
input_option.call
|
154
169
|
instance_option.call
|
155
170
|
yes_option.call
|
171
|
+
reconfigure_option.call
|
156
172
|
option :plan, desc: "Execution plan that can be used to only execute a pre-determined set of actions."
|
157
173
|
option :var_files, type: :array, desc: "list of var files"
|
158
174
|
def update(mod)
|
159
|
-
Commander.new("apply", options.merge(mod: mod
|
175
|
+
Commander.new("apply", options.merge(mod: mod)).run
|
160
176
|
end
|
161
177
|
|
162
|
-
desc "validate
|
178
|
+
desc "validate STACK", "validate"
|
163
179
|
long_desc Help.text(:validate)
|
164
180
|
instance_option.call
|
165
181
|
def validate(mod)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# The placeholder stack is a special stack that is useful in case there are no app/stacks.
|
2
|
+
# We build a placeholder back just so we have backend.tf to be used to grab info.
|
3
|
+
# It's useful for the summary command.
|
4
|
+
module Terraspace::CLI::Build
|
5
|
+
class Placeholder
|
6
|
+
include Terraspace::Util::Logging
|
7
|
+
|
8
|
+
def initialize(options={})
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
12
|
+
# Grab the last module and build that.
|
13
|
+
# Assume the backend key has the same prefix
|
14
|
+
# Note: Tried building a empty "null" stack but with TFC a null space workspace is created, which is undesired.
|
15
|
+
def build
|
16
|
+
return if ENV['TS_SUMMARY_BUILD'] == '0'
|
17
|
+
|
18
|
+
mod = @options[:mod]
|
19
|
+
if !mod or mod == "placeholder"
|
20
|
+
logger.info "Building one of the modules to get backend.tf info"
|
21
|
+
mod = find_mod
|
22
|
+
end
|
23
|
+
Terraspace::Builder.new(@options.merge(mod: mod, init: false)).run # generate and init
|
24
|
+
Terraspace::Mod.new(mod, @options) # mod metadata
|
25
|
+
end
|
26
|
+
|
27
|
+
# Used by: terraspace build placeholder
|
28
|
+
def find_mod
|
29
|
+
mod_path = Dir.glob("{app,vendor}/{modules,stacks}/*").last
|
30
|
+
unless mod_path
|
31
|
+
logger.info <<~EOL
|
32
|
+
No modules or stacks found.
|
33
|
+
Unable to determine the backend state path without at least one module.
|
34
|
+
EOL
|
35
|
+
exit 0
|
36
|
+
end
|
37
|
+
File.basename(mod_path) # mod name
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|