tfw 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +47 -21
  3. data/lib/tfw.rb +1 -1
  4. data/lib/tfw/version.rb +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 564a30312f85719c7709db1a07e4acf5b74e1c03849c0f0f7398cb38784e77cc
4
- data.tar.gz: 2954fcfc65533e10ddcbd31025aaa3a08881989762735071f1c436aa3606eb50
3
+ metadata.gz: 0db3357d383025ad106278eba178bf1055488261573a5a0428f4e99718d39e0e
4
+ data.tar.gz: 8d9c8bae4f4e2ac13d9f75c056c4ff8ae146eeb112b572457fb441f68c886155
5
5
  SHA512:
6
- metadata.gz: 0de1ff45b8df4470729d0b10a0e7a6ca09194e2e5af6f396cd9fd6808cf1e22077f22849aa8ebec6fd552905dbf157b5b90dfa6d739e309f73d38dea10c7b50d
7
- data.tar.gz: adb59b8a1613d64813d7cdcbe58e21febc89688853c4f826f818954dc75e0bc4c18bde42c6ef220f5f7ea103ee6918d6a27ed4af0f1215f2356d4736e5630552
6
+ metadata.gz: 82eea2e76375be89fd1f740090c54ea48699ee208b2d9b4050d1c4dadf8487a4afc372efa8f45c9a6ee459318a71d21ea23e269eac593aaae57b05b6b1e0827d
7
+ data.tar.gz: cfb2dbc06fcf90e9e42c9e390f398292d8e33a3eda1ea57bed271404a652dd8c67689b9fdc52a7aaf488f016e9e41cf116837cdb3f99aeacda6434664ff8926b
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,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TFW
4
- VERSION = '0.1.10'
4
+ VERSION = '0.1.11'
5
5
  end
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.10
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-03-02 00:00:00.000000000 Z
11
+ date: 2020-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tfdsl