Build Status Software License Release Last Release Github commits (since latest release) Last Commit TerraformToolbox

Terradoc

Terradoc is a tool creating documentation from terraform code. It will parse all of the terraform code in a given directory and generate 5 data tables.

  1. Data Sources
  2. Modules
  3. Outputs
  4. Resources
  5. Variables

You can then use the custom tags to insert these data tables into your README or other markdown files.

Installation

Add this line to your application's Gemfile:

gem 'terradoc'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install terradoc

Usage

Usage: terradoc
    -h, --help               Display this screen
    -v, --verbose            Turn on verbose mode
    -o, --output string      Name of the output file. [default: README.md]
    -p, --path string        Path to the terraform code. [default: current directory]

Adding Tags

There are a number tags that you need to add to your README in order for terradoc to know where to insert the data.

# Data Sources
<!--Terradoc-data-sources-start-->
<!--Terradoc-data-sources-end-->

# Modules
<!--Terradoc-modules-start-->
<!--Terradoc-modules-end-->

# Outputs
<!--Terradoc-outputs-start-->
<!--Terradoc-outputs-end-->

# Providers
<!--Terradoc-providers-start-->
<!--Terradoc-providers-end-->

# Resources
<!--Terradoc-resources-start-->
<!--Terradoc-resources-end-->

# Variables
<!--Terradoc-variables-start-->
<!--Terradoc-variables-end-->

Now you can simply run terradoc and it will generate the output.

Known Errors

If you see an error similiar to Error: nesting of 257 is too deep then you should review your code as you have very high levels of nesting. The code will cope with 256 levels.

Contributing to Terradoc

Setup

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

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.

Testing

For local testing make sure that you run bundle exec rspec spec and then rake install to install the gem locally.

For further information please refer to the contributing documentation.

To-Do List

  • [ ] Allow for setting of root url for linking to terraform registry
  • [ ] Allow different format outputs
  • [ ] Allow got global config files
  • [ ] Pre/Post git commit hook