Git Product home page Git Product logo

terrafirm's Introduction

Terrafirm

Terrafirm is a wrapper around Terraform that enforces what I feel is an ideal workflow/structure for a Terraform project.

Terraform Docs

Project Structure

Terrafirm expects a project with this basic structure:

| project_root
├── configs
│   └── example_config
│       └──  config.tf
├── terrafirm.sh
└── variables
    ├── environments
    │   └── dev
    │       └── common.tfvars
    │       └── example_config.tfvars
    └── terrafirm_variables.sh

Terraform provides a native implementation of "environments", which are simply arbitrary namespaces that separate out pieces of your state. These environments do not currently enforce any kind of project structure or separation of variables.

Instead of using these namespaces, Terrafirm declares environments simply by using named variable folders. At runtime, these files will always be passed to Terraform in order to override any config defaults with environment specific variables. In turn, this pushes you to create environment agnostic configs which keeps your environments in line with each other.

Wrapper

Basic Usage:

./terrafirm.sh (environment) (config) (terraform_command) (extra_args)

The wrapper assumes a few things:

  • You have the structure defined above.
  • You are storing states remotely in an S3 backend.
    • The finished path to a remote state file would look like this: s3://$state_bucket/$environment/$config/terrafirm.tfstate

Terrafirm Variables

Terrafirm will source a variables file named "terrafirm_variables.sh" from the "variables" folder of your project. This will allow you to set variables such as your S3 bucket name to store remote states.

When you add a new environment, be sure to add the environment name to the $my_environments list in this file.

Testing and Validation

There is a pre-commit hook script in the root of this directory. To enable it locally, run this command from the project root:

ln -s pre-commit.sh .git/hooks/pre-commit

terrafirm's People

Contributors

elocnatsirt avatar

Watchers

 avatar  avatar

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.