terraspace 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +56 -29
- data/lib/terraspace/cli.rb +1 -0
- data/lib/terraspace/cli/help/logs.md +4 -4
- data/lib/terraspace/cli/logs/concern.rb +1 -0
- data/lib/terraspace/terraform/args/default.rb +9 -19
- data/lib/terraspace/terraform/runner.rb +1 -1
- data/lib/terraspace/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0174dca33a15bfe2c0eb0a1e0f573599ab7de2850d746e6f0be4e34aec573e39
|
4
|
+
data.tar.gz: 4d2b91fb5631d3fa1c32379845cc1f3d677238edc7133015cf99050e874339f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b624c36518fd03e4b03c8ddba62dc196ea656f26921086ddb3dec4859f613b3da2534f0320f0c6197a53fd31d9f5a44ad98f5c5c4b3914164185707a42eb007e
|
7
|
+
data.tar.gz: 87b7625d52efd046193ec7ed9abfb7e311b7b143d70e492db84e60cccb4b90fea872d1f6333901d95a6c9af7d07bf2d5027980aa482794d5f60b27ed9a8e3e41
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,10 @@
|
|
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.4.2]
|
7
|
+
* #48 add logs pid option
|
8
|
+
* default to input false, encourage set tfvars
|
9
|
+
|
6
10
|
## [0.4.1]
|
7
11
|
* #47 `terraspace list` fix and `terraspace all init` help updates
|
8
12
|
|
data/README.md
CHANGED
@@ -29,59 +29,77 @@ Here are commands to get started:
|
|
29
29
|
* The `up` command creates an s3 bucket.
|
30
30
|
* The `down` command cleans up and deletes the bucket.
|
31
31
|
|
32
|
-
The default plugin is aws.
|
32
|
+
The default plugin is aws. Major cloud providers are supported: [aws](https://terraspace.cloud/docs/learn/aws/), [azurerm](https://terraspace.cloud/docs/learn/azure/), [google](https://terraspace.cloud/docs/learn/gcp/).
|
33
33
|
|
34
34
|
## Usage
|
35
35
|
|
36
36
|
Create infrastructure:
|
37
37
|
|
38
|
-
$ terraspace up demo
|
38
|
+
$ terraspace up demo
|
39
39
|
Building .terraspace-cache/us-west-2/dev/stacks/demo
|
40
40
|
Current directory: .terraspace-cache/us-west-2/dev/stacks/demo
|
41
|
-
=> terraform init -get
|
42
|
-
|
43
|
-
=> terraform apply -auto-approve
|
44
|
-
random_pet.bucket: Creating...
|
45
|
-
random_pet.bucket: Creation complete after 0s [id=amusing-mouse]
|
46
|
-
module.bucket.aws_s3_bucket.this: Creating...
|
47
|
-
module.bucket.aws_s3_bucket.this: Creation complete after 1s [id=bucket-amusing-mouse]
|
48
|
-
|
41
|
+
=> terraform init -get >> /tmp/terraspace/log/init/demo.log
|
42
|
+
=> terraform apply
|
49
43
|
Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
|
50
|
-
|
51
|
-
Outputs:
|
52
|
-
|
53
|
-
bucket_name = bucket-amusing-mouse
|
54
44
|
$
|
55
45
|
|
56
46
|
Destroy infrastructure:
|
57
47
|
|
58
|
-
$ terraspace down demo
|
48
|
+
$ terraspace down demo
|
59
49
|
Building .terraspace-cache/us-west-2/dev/stacks/demo
|
60
50
|
Current directory: .terraspace-cache/us-west-2/dev/stacks/demo
|
61
|
-
=> terraform
|
62
|
-
Built in .terraspace-cache/us-west-2/dev/stacks/demo
|
63
|
-
=> terraform destroy -auto-approve
|
64
|
-
random_pet.bucket: Refreshing state... [id=amusing-mouse]
|
65
|
-
module.bucket.aws_s3_bucket.this: Refreshing state... [id=bucket-amusing-mouse]
|
66
|
-
module.bucket.aws_s3_bucket.this: Destroying... [id=bucket-amusing-mouse]
|
67
|
-
module.bucket.aws_s3_bucket.this: Destruction complete after 1s
|
68
|
-
random_pet.bucket: Destroying... [id=amusing-mouse]
|
69
|
-
random_pet.bucket: Destruction complete after 0s
|
70
|
-
|
51
|
+
=> terraform destroy
|
71
52
|
Destroy complete! Resources: 2 destroyed.
|
72
53
|
$
|
73
54
|
|
55
|
+
* Blog: [Introducing Terraspace: The Terraform Framework](https://blog.boltops.com/2020/08/22/introducing-terraspace-the-terraform-framework)
|
56
|
+
* Docs: [Terraspace Intro](https://terraspace.cloud/docs/intro/)
|
57
|
+
|
74
58
|
## Deploy Multiple Stacks
|
75
59
|
|
76
60
|
To deploy all the infrastructure stacks:
|
77
61
|
|
78
|
-
terraspace all up
|
62
|
+
$ terraspace all up
|
63
|
+
Will run:
|
64
|
+
terraspace up vpc # batch 1
|
65
|
+
terraspace up mysql # batch 2
|
66
|
+
terraspace up redis # batch 2
|
67
|
+
terraspace up instance # batch 3
|
68
|
+
Are you sure? (y/N)
|
79
69
|
|
80
70
|
To choose multiple stacks to deploy
|
81
71
|
|
82
|
-
terraspace all up
|
72
|
+
$ terraspace all up mysql redis
|
73
|
+
Will run:
|
74
|
+
terraspace up vpc # batch 1
|
75
|
+
terraspace up mysql # batch 2
|
76
|
+
terraspace up redis # batch 2
|
77
|
+
Are you sure? (y/N)
|
78
|
+
|
79
|
+
When you use the all command, the dependency graph is calculated and the stacks are deployed in the right order.
|
80
|
+
|
81
|
+
* Blog: [Terraspace All: Deploy Multiple Stacks or Terraform Modules At Once](https://blog.boltops.com/2020/09/19/terraspace-all-deploy-multiple-stacks-at-once)
|
82
|
+
* Docs: [Deploy Multiple Stacks](https://terraspace.cloud/docs/intro/deploy-all/).
|
83
|
+
|
84
|
+
## Terrafile
|
83
85
|
|
84
|
-
|
86
|
+
Terraspace makes it easy to use Terraform modules sourced from your own git repositories, other git repositories, or the Terraform Registry. Use any module you want:
|
87
|
+
|
88
|
+
Terrafile:
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
# GitHub repo
|
92
|
+
mod "s3", source: "boltops-tools/terraform-aws-s3", tag: "v0.1.0"
|
93
|
+
# Terraform registry
|
94
|
+
mod "sg", source: "terraform-aws-modules/security-group/aws", version: "3.10.0"
|
95
|
+
```
|
96
|
+
|
97
|
+
To install modules:
|
98
|
+
|
99
|
+
terraspace bundle
|
100
|
+
|
101
|
+
* Blog: [Terraspace Terrafile: Using Git and Terraform Registry Modules](https://blog.boltops.com/2020/10/18/terraspace-terrafile-using-git-repos-and-terraform-registry-modules)
|
102
|
+
* Docs: [Terrafile](https://terraspace.cloud/docs/terrafile/)
|
85
103
|
|
86
104
|
## Features
|
87
105
|
|
@@ -89,8 +107,17 @@ When you use the all command, the dependency graph is calculated and the stacks
|
|
89
107
|
* [Generators](https://terraspace.cloud/docs/generators/): Built-in generators to quickly create the starter module. Focus on code instead of boilerplate structure.
|
90
108
|
* [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/).
|
91
109
|
* [Deploy Multiple Stacks](https://terraspace.cloud/docs/intro/deploy-all/): The ability to deploy multiple stacks with a single command. Terraspace calculates the [dependency graph](https://terraspace.cloud/docs/dependencies/) and deploys stacks in the right order. You can also target specific stacks and deploy [subgraphs](https://terraspace.cloud/docs/dependencies/subgraphs/).
|
110
|
+
* [Terrafile](https://terraspace.cloud/docs/terrafile/}): Terraspace makes it easy to use Terraform modules sourced from your own git repositories, other git repositories, or the Terraform Registry. The git repos can be private or public. This is an incredibly powerful feature of Terraspace because it opens up a world of modules for you to use. Use any module you want.
|
92
111
|
* [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.
|
93
112
|
* [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.
|
94
113
|
* [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.
|
95
114
|
|
96
|
-
|
115
|
+
## Comparison
|
116
|
+
|
117
|
+
Here are some useful comparisons to help you compare Terraspace vs other tools in the ecosystem:
|
118
|
+
|
119
|
+
* [Terraspace vs Custom Solution](https://terraspace.cloud/docs/vs/custom/)
|
120
|
+
* [Terraspace vs Terraform](https://terraspace.cloud/docs/vs/terraform/)
|
121
|
+
* [Terraform vs Terragrunt vs Terraspace](https://blog.boltops.com/2020/09/28/terraform-vs-terragrunt-vs-terraspace)
|
122
|
+
|
123
|
+
More info: [terraspace.cloud](https://terraspace.cloud)
|
data/lib/terraspace/cli.rb
CHANGED
@@ -110,6 +110,7 @@ module Terraspace
|
|
110
110
|
option :follow, aliases: %w[f], type: :boolean, desc: "Follow the log in live tail fashion. Must specify a stack if using this option."
|
111
111
|
option :limit, aliases: %w[n], default: 10, type: :numeric, desc: "Number of lines to limit showing. Only applies in no-follow mode."
|
112
112
|
option :all, aliases: %w[a], type: :boolean, desc: "All mode turns off the limit. Defaults to all if a single log is specified. Only applies in no-follow mode."
|
113
|
+
option :pid, aliases: %w[p], desc: "Filter by pid. Defaults to the last pid at the bottom of the log file."
|
113
114
|
def logs(action=nil, stack=nil)
|
114
115
|
Logs.new(@options.merge(action: action, stack: stack)).run
|
115
116
|
end
|
@@ -12,12 +12,12 @@ Note, Terraspace automatically checks every second for new logs and adds them to
|
|
12
12
|
|
13
13
|
View last 10 lines of each log file.
|
14
14
|
|
15
|
-
terraspace logs up network # view up log on specific stack
|
15
|
+
terraspace logs up network # view up log on a specific stack
|
16
16
|
terraspace logs up # view all up logs
|
17
17
|
terraspace logs down # view all down logs
|
18
18
|
terraspace logs # view all logs: up, down, etc
|
19
19
|
|
20
|
-
By default, the
|
20
|
+
By default, the logs command shows the last 10 lines for each log file. You can use the `-n` option to adjust this.
|
21
21
|
|
22
22
|
terraspace logs -n 2 # view last 2 lines of all logs: up, down, etc
|
23
23
|
|
@@ -31,14 +31,14 @@ Note, if both an action and stack is specified, then it defaults to showing all
|
|
31
31
|
|
32
32
|
To tail logs, use the `-f` option.
|
33
33
|
|
34
|
-
terraspace logs up network -f # view up log on specific stack
|
34
|
+
terraspace logs up network -f # view up log on a specific stack
|
35
35
|
terraspace logs up -f # view all up logs
|
36
36
|
terraspace logs down -f # view all down logs
|
37
37
|
terraspace logs -f # view all logs: up, down, etc
|
38
38
|
|
39
39
|
## Timestamps
|
40
40
|
|
41
|
-
The timestamps are shown by default when you are looking for multiple files. When you specify both the action and stack for a single log file,
|
41
|
+
The timestamps are shown by default when you are looking for multiple files. When you specify both the action and stack for a single log file, the timestamps are not shown.
|
42
42
|
|
43
43
|
terraspace logs up # timestamps will be shown in this case
|
44
44
|
terraspace logs up network # timestamps not be shown in this case
|
@@ -17,6 +17,7 @@ class Terraspace::CLI::Logs
|
|
17
17
|
|
18
18
|
# [2020-09-06T21:58:25 #11313 terraspace up b1]:
|
19
19
|
def pid(line)
|
20
|
+
return @options[:pid] if @options && @options[:pid] # Terraspace::All::Summary: doesnt have @options set
|
20
21
|
md = line.match(/:\d{2} #(\d+) /)
|
21
22
|
md[1] if md
|
22
23
|
end
|
@@ -26,7 +26,7 @@ module Terraspace::Terraform::Args
|
|
26
26
|
args << var_files.map { |f| "-var-file #{Dir.pwd}/#{f}" }.join(' ')
|
27
27
|
end
|
28
28
|
|
29
|
-
args << input_option
|
29
|
+
args << input_option
|
30
30
|
|
31
31
|
# must be at the end
|
32
32
|
plan = @options[:plan]
|
@@ -45,27 +45,17 @@ module Terraspace::Terraform::Args
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def input_option
|
48
|
-
option =
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
option = " -input=#{input}" # = sign required for apply when there's a plan at the end. so input=false works input false doesnt
|
55
|
-
end
|
56
|
-
option
|
48
|
+
option = if @options[:auto]
|
49
|
+
"false"
|
50
|
+
else
|
51
|
+
@options[:input] ? @options[:input] : "false"
|
52
|
+
end
|
53
|
+
" -input=#{option}"
|
57
54
|
end
|
58
55
|
|
59
56
|
def init_args
|
60
57
|
args = "-get"
|
61
|
-
|
62
|
-
args << " -input=false"
|
63
|
-
end
|
64
|
-
unless @options[:input].nil?
|
65
|
-
input = @options[:input] ? "true" : "false"
|
66
|
-
args << " -input=#{input}"
|
67
|
-
end
|
68
|
-
|
58
|
+
args << input_option
|
69
59
|
args << " -reconfigure" if @options[:reconfigure]
|
70
60
|
|
71
61
|
# must be at the end
|
@@ -86,7 +76,7 @@ module Terraspace::Terraform::Args
|
|
86
76
|
|
87
77
|
def plan_args
|
88
78
|
args = []
|
89
|
-
args << input_option
|
79
|
+
args << input_option
|
90
80
|
args << "-destroy" if @options[:destroy]
|
91
81
|
args << "-out #{expanded_out}" if @options[:out]
|
92
82
|
args
|
@@ -21,7 +21,7 @@ module Terraspace::Terraform
|
|
21
21
|
current_dir_message # only show once
|
22
22
|
|
23
23
|
params = args.flatten.join(' ')
|
24
|
-
command = "terraform #{name} #{params}"
|
24
|
+
command = "terraform #{name} #{params}".squish
|
25
25
|
run_hooks("terraform.rb", name) do
|
26
26
|
Terraspace::Shell.new(@mod, command, @options.merge(env: custom.env_vars)).run
|
27
27
|
end
|
data/lib/terraspace/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terraspace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|