tfw 0.1.9 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ee59038678372b5909b1bd70d8a28bbb2de4fdcd407d3d09e08e2c0f57992a1
4
- data.tar.gz: b6b3a185df06d7ec3ba90b775b136946beaea8baefbf57450662a7a6e7a052d8
3
+ metadata.gz: 8bc1a297f3a4298321ef182f415a28d25855a65fb9c221c54733b91baa1087e3
4
+ data.tar.gz: 2062ad35f45c0939844fabf28cc2b67e7c8e189911b5a73b3885aa7df36aab9f
5
5
  SHA512:
6
- metadata.gz: cfb94b1fdddbaab1915b07aa7656e70b589fde26b60c81ca9d340e9d01120cae55c6fd0b6dcd91869baefd516ff916ce50ea3728482f6eebab1c4ed66450a6b8
7
- data.tar.gz: 8660607b97c1fa6fee66174410742f17beb2d9ba65016b7c80790cda2b7898a412a1e70fbd73e0c2a9dbde93aeb2a64e8d7cef7f953ae3c07914cd4d7b4b2f70
6
+ metadata.gz: 8521b1c5ae3ca1c671ae43744033a162427abde06084aa7e6f117196c821ea0b425d9e963f7a7333997a19ca53d601804b768348baac3612074a07fcd34f2a94
7
+ data.tar.gz: 18f7ac5a1b377bb88396577503447fb906232da4376e34ee77eb8072f8c926a4fa906a29f28fd29bf268a7ab27ae08c27548d4845acf7152273267dd762fe1d0
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tfw (0.1.9)
5
- tfdsl (= 0.1.7)
4
+ tfw (0.1.14)
5
+ tfdsl (= 0.1.10)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -15,6 +15,7 @@ GEM
15
15
  term-ansicolor (~> 1.3)
16
16
  thor (~> 0.19.4)
17
17
  tins (~> 1.6)
18
+ deep_merge (1.2.1)
18
19
  docile (1.3.1)
19
20
  jaro_winkler (1.5.4)
20
21
  json (2.1.0)
@@ -43,7 +44,8 @@ GEM
43
44
  simplecov-html (0.10.2)
44
45
  term-ansicolor (1.7.1)
45
46
  tins (~> 1.0)
46
- tfdsl (0.1.7)
47
+ tfdsl (0.1.10)
48
+ deep_merge (~> 1.2)
47
49
  thor (0.19.4)
48
50
  tins (1.20.2)
49
51
  unicode-display_width (1.6.1)
data/README.md CHANGED
@@ -1,43 +1,69 @@
1
- # Tfw
1
+ # TFW - Terraform Wrapper
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/tfw`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Terraform Wrapper writes terraform configuration using TFDSL (Terraform DSL for Ruby) and invokes the terraform binary.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
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
- Add this line to your application's Gemfile:
14
+ ## Usage:
10
15
 
16
+ 1. let's create a file called `foo.rb`
11
17
  ```ruby
12
- gem 'tfw'
18
+ resource 'local_file', 'foo' do
19
+ content 'foo'
20
+ filename '/tmp/foo.txt'
21
+ end
13
22
  ```
14
23
 
15
- And then execute:
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
- $ bundle
32
+ Terraform will perform the following actions:
18
33
 
19
- Or install it yourself as:
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
- $ gem install tfw
43
+ Plan: 1 to add, 0 to change, 0 to destroy.
22
44
 
23
- ## Usage
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
- TODO: Write usage instructions here
49
+ Enter a value: yes
26
50
 
27
- ## Development
51
+ local_file.foo: Creating...
52
+ local_file.foo: Creation complete after 0s [id=0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33]
28
53
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
54
+ Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
55
+ ```
30
56
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
57
+ ## How it works
32
58
 
33
- ## Contributing
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
- ## License
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
- ## Code of Conduct
65
+ TFW is just a ruby gem and can easily be installed as below:
42
66
 
43
- Everyone interacting in the Tfw project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/tfw/blob/master/CODE_OF_CONDUCT.md).
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 datsource resource output terraform].each do |name|
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
@@ -1,19 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Singleton class to keep the stack
4
- class State
5
- include Singleton
3
+ module TFW
4
+ # Singleton class to keep the stack
5
+ class State
6
+ include Singleton
6
7
 
7
- def initialize
8
- @stack = TFDSL::Stack.new
9
- end
8
+ def initialize
9
+ @stack = TFDSL::Stack.new
10
+ end
10
11
 
11
- def stack(&block)
12
- @stack.instance_eval(&block) if block_given?
13
- @stack
14
- end
12
+ def stack(&block)
13
+ @stack.instance_eval(&block) if block_given?
14
+ @stack
15
+ end
15
16
 
16
- def reset
17
- @stack = TFDSL::Stack.new
17
+ def reset
18
+ @stack = TFDSL::Stack.new
19
+ end
18
20
  end
19
21
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TFW
4
- VERSION = '0.1.9'
4
+ VERSION = '0.1.14'
5
5
  end
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
35
35
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
36
  spec.require_paths = ['lib']
37
37
 
38
- spec.add_dependency 'tfdsl', '0.1.7'
38
+ spec.add_dependency 'tfdsl', '0.1.10'
39
39
 
40
40
  spec.add_development_dependency 'bundler', '~> 1.17'
41
41
  spec.add_development_dependency 'coveralls', '~> 0.8'
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.9
4
+ version: 0.1.14
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-03-01 00:00:00.000000000 Z
11
+ date: 2020-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tfdsl
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.7
19
+ version: 0.1.10
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.7
26
+ version: 0.1.10
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement