tfw 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +47 -21
- data/lib/tfw.rb +1 -1
- data/lib/tfw/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: 0db3357d383025ad106278eba178bf1055488261573a5a0428f4e99718d39e0e
|
4
|
+
data.tar.gz: 8d9c8bae4f4e2ac13d9f75c056c4ff8ae146eeb112b572457fb441f68c886155
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82eea2e76375be89fd1f740090c54ea48699ee208b2d9b4050d1c4dadf8487a4afc372efa8f45c9a6ee459318a71d21ea23e269eac593aaae57b05b6b1e0827d
|
7
|
+
data.tar.gz: cfb2dbc06fcf90e9e42c9e390f398292d8e33a3eda1ea57bed271404a652dd8c67689b9fdc52a7aaf488f016e9e41cf116837cdb3f99aeacda6434664ff8926b
|
data/README.md
CHANGED
@@ -1,43 +1,69 @@
|
|
1
|
-
#
|
1
|
+
# TFW - Terraform Wrapper
|
2
2
|
|
3
|
-
|
3
|
+
Terraform Wrapper writes terraform configuration using TFDSL (Terraform DSL for Ruby) and invokes the terraform binary.
|
4
4
|
|
5
|
-
|
5
|
+
## Motivation (Short Version)
|
6
|
+
|
7
|
+
Terraform is an excellent tool, but it lacks funcionalities like Loops and Conditionals, actually since version 0.12+ it has loops as meta-arguments which is a hacky implementation in my humble opinion.
|
8
|
+
|
9
|
+
For years I was templating terraform configuration with ERB / Jinja, that's reasonable way to avoid repetition in terraform but it's not very flexible nor reusable.
|
10
|
+
|
11
|
+
The solution was writing a tool which mimics terraform usage but writes configuration in plain Ruby.
|
6
12
|
|
7
|
-
## Installation
|
8
13
|
|
9
|
-
|
14
|
+
## Usage:
|
10
15
|
|
16
|
+
1. let's create a file called `foo.rb`
|
11
17
|
```ruby
|
12
|
-
|
18
|
+
resource 'local_file', 'foo' do
|
19
|
+
content 'foo'
|
20
|
+
filename '/tmp/foo.txt'
|
21
|
+
end
|
13
22
|
```
|
14
23
|
|
15
|
-
|
24
|
+
2. Just like in terrraform, run init and apply
|
25
|
+
```
|
26
|
+
$ tfw init && tfw apply
|
27
|
+
... <omitted output>
|
28
|
+
An execution plan has been generated and is shown below.
|
29
|
+
Resource actions are indicated with the following symbols:
|
30
|
+
+ create
|
16
31
|
|
17
|
-
|
32
|
+
Terraform will perform the following actions:
|
18
33
|
|
19
|
-
|
34
|
+
# local_file.foo will be created
|
35
|
+
+ resource "local_file" "foo" {
|
36
|
+
+ content = "foo"
|
37
|
+
+ directory_permission = "0777"
|
38
|
+
+ file_permission = "0777"
|
39
|
+
+ filename = "/tmp/foo.txt"
|
40
|
+
+ id = (known after apply)
|
41
|
+
}
|
20
42
|
|
21
|
-
|
43
|
+
Plan: 1 to add, 0 to change, 0 to destroy.
|
22
44
|
|
23
|
-
|
45
|
+
Do you want to perform these actions?
|
46
|
+
Terraform will perform the actions described above.
|
47
|
+
Only 'yes' will be accepted to approve.
|
24
48
|
|
25
|
-
|
49
|
+
Enter a value: yes
|
26
50
|
|
27
|
-
|
51
|
+
local_file.foo: Creating...
|
52
|
+
local_file.foo: Creation complete after 0s [id=0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33]
|
28
53
|
|
29
|
-
|
54
|
+
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
|
55
|
+
```
|
30
56
|
|
31
|
-
|
57
|
+
## How it works
|
32
58
|
|
33
|
-
|
59
|
+
TFW will create a subdirectory called `.tfw`, and it will create a file called `.tfw/stack.tf` which is the dynamically generated terraform file, and will invoke terrafom in that directory.
|
34
60
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tfw. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
61
|
|
37
|
-
##
|
62
|
+
## Installation
|
38
63
|
|
39
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
64
|
|
41
|
-
|
65
|
+
TFW is just a ruby gem and can easily be installed as below:
|
42
66
|
|
43
|
-
|
67
|
+
```bash
|
68
|
+
gem install tfw
|
69
|
+
```
|
data/lib/tfw.rb
CHANGED
@@ -101,7 +101,7 @@ module TFW
|
|
101
101
|
def configure_methods_using_stack(stack)
|
102
102
|
silent_block do
|
103
103
|
# This will trigger warnings as we are redefining methods
|
104
|
-
%w[provider variable locals tfmodule
|
104
|
+
%w[provider variable locals tfmodule datasource resource output terraform].each do |name|
|
105
105
|
TOPLEVEL_BINDING.eval('self').define_singleton_method name do |*args, &block|
|
106
106
|
stack.method(name).call(*args, &block)
|
107
107
|
end
|
data/lib/tfw/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tfw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tiago Lopo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tfdsl
|