Code Monkey home page Code Monkey logo

generator-tf-module's Introduction

Terraform module generator

npm version npm Docker Stars Docker Pulls Docker Image Version (latest by date)

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 framework

  • 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

  • To use generator using Docker, Install Docker recommended
  • To use generator using Nodejs, Install nodejs pro tip: use nvm

Usage

To use the included generator execute the below command in shell and provide your answers to the prompts.

With Docker:
> docker run --rm -it -v $(pwd):/generated -e myuid="$(id -u):$(id -g)" sudokar/generator-tf-module
With NodeJs:
> npx -p yo -p generator-tf-module -c 'yo tf-module'
Prompts:
...
? Enter name for the new terraform module :  example-module
? Enter description for the new terraform module :  Example terraform module
? Enter author name :  sudokar
? Choose terraform version (Use arrow keys)
❯ 0.13
  0.12
  0.11
? 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.

Maintainer

This project is authored and maintained by sudokar

License

MIT

generator-tf-module's People

Contributors

dependabot[bot] avatar officel avatar sudokar avatar wesley-dean-flexion avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

swipswaps

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.