Skip to content
Project scaffolding for Terraform Modules
Branch: master
Clone or download
Latest commit 1a136e9 Mar 19, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
generators/app Set version 0.4.0 Mar 13, 2019
.gitignore
LICENSE
README.md
package.json Set version 0.4.0 Mar 13, 2019
yarn.lock

README.md

Terraform module generator npm version

Scaffolding for new Terraform module projects

Features

  • main.tf, variables.tf,outputs.tf files to module root path

  • .editorconfig, .gitignore, .gitattributes and .terraform-version files to module root path

  • Option to choose test frameworks

  • test directory with an example test based on test framework selection

  • .pre-commit-config.yaml for terraform fmt, terraform-docs, check-merge-conflict and (go fmt, golint) / rubocop

  • example directory with module usage tf files

Prerequisites

Installation

  1. Install nodejs pro tip: use nvm

  2. Install Yeoman

npm install -g yo
  1. Install this generator
npm install -g generator-tf-module

Usage

To use the included generator execute the below command in shell and provide your new module name for the prompt

> yo tf-module
...
? Enter name for the new terraform module :  example-module
? Enter description for the new terraform module :  A new terraform module
? Enter author name :  sudokar
? Choose test framework (Use arrow keys)
❯ Terratest
  kitchen-terraform

Project layout generated for the new module with Terratest selection

example-module
├── .editorconfig
├── .gitattributes
├── .gitignore
├── .pre-commit-config.yaml
├── .terraform-version
├── README.md
├── main.tf
├── outputs.tf
├── variables.tf
├── example
│   ├── main.tf
│   ├── outputs.tf
│   └── variables.tf
├── test
    └── example_test.go

Project layout generated for the new module with kitchen-terraform selection

example-module
├── .editorconfig
├── .gitattributes
├── .gitignore
├── .pre-commit-config.yaml
├── .terraform-version
├── .ruby-version
├── .kitchen.yml
├── Gemfile
├── README.md
├── main.tf
├── outputs.tf
├── variables.tf
├── example
│   ├── main.tf
│   ├── outputs.tf
│   └── variables.tf
├── test
    └── integration
        └── default
            └── example_spec.rb
Post generation steps

Step 1

On the generated module's root path, Initialize git repository

git init

Step 2

On the generated module's root path, Install pre-commit hooks

pre-commit install

Step 3 (Applicable only for terratest)

For golang tests, get below libs

> go get github.com/gruntwork-io/terratest/modules/terraform
> go get github.com/stretchr/testify/assert

Contribution

Found a bug? feel free to raise an issue.
Pull requests are always welcome. Keen to review and merge asap.

Maintainers

This project is maintained by sudokar

License

MIT

You can’t perform that action at this time.