Mini ruby dsl for generating terraform files
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


A mini ruby dsl for generating terraform files.

It's a terrible name, but a useful lib.

This is intended to be used in conjuction with human authored .tf files


For now, just copy the terrafiddle.rb file into your project - it's less than 20 lines.

Perhaps at some point I'll make it an actual gem.


Create a ruby file for building up some terraform config.

require './terrafiddle'

resource :resource_type, "Name", {
  attr: 1,
  attr2: "value",
  attr3: "${}"

And then run it to generate some JSON

ruby >

If you have a bunch of these, you'll probably want a Makefile. Here's an example:

# Based on

TERRAFORMS := $(patsubst %.rb,%.json,$(wildcard *.tf.rb))

all : build plan

build : $(TERRAFORMS)

%.json : %.rb terrafiddle.rb
  ruby $< > $@

plan :
  terraform plan

clean :

rebuild : clean build

graph : graph.png

graph.png :
  terraform graph | dot -Tpng > $@