Giter Club home page Giter Club logo

hygen-terraform's Introduction

Hygen Terraform

A collection of templates for Hygen to allow creation of Terraform boilerplate with some extra functionality.

Dependencies

Description

The collection of templates will create the required boilerplate for a Terraform project in AWS or GCP. Interactively asks for Terraform version that will be used and injects to the required template. The following files will be created upon executing the Hygen

  • main.tf
  • backend.tf
  • version.tf
  • providers.tf
  • variables.tf
  • oututs.tf
  • pre-commit.yaml
  • README.md
  • LICENSE.md
  • .gitignore

pre-commit

pre-commit is used and the latest version is retrieved and it is inserted into the yaml manifest automatically.

See pre-commit hooks for Terraform. There are some dependencies that are detailed here. The repository uses the following pre commit hooks:

Automation

Hygen allows execution of certain commands so some elements of the setup beyond the boilerplate are also automated. On completion of generating the files some actions are also carried out. Note Hygen executes the template files in alphabetical order so some files have prefix of z,zz & zzz in order to ensure they are executed after all the files have been generated.

Hygen uses shell via the sh: in the frontmatter section to execute these elements.

pre-commit version

The latest version of pre-commit is retrieved from the releases page of GitHub and this is manipulated via SED to be injected into the pre-commit yaml manifest.

Terraform

direnv and terraform are setup so that can quickly get going.

direnv allow
tfswitch
terraform init

git

On completion of generating the files the following commands are run to create a git repository:

git init
git add .
git commit -m 'Initial commit'
pre-commit install

Deployment

Run the following, dependent on the repository being located at $HOME/hygen-terraform/_templates. The idea is t have this sitting on the machine and then copy over as required whenever creating new Terraform for a particular service on a particular cloud provider.

cp -r $HOME/repos/hygen-terraform/_templates .

Then depending on the cloud provider you will need to run either of the following. You will be asked interactively for what version of Terraform you would like to use.

AWS

hygen terraform aws

GCP

hygen terraform gcp

Testing

The following commands may be useful for testing:

gh repo delete mcdermg/hygen-test
mcdermg/hygen-test

rm -rf .terraform *.tf .git .gitignore .pre-commit-config.yaml .terraform.lock.hcl _templates *.md .envrc

cp -r $HOME/repos/hygen-terraform/_templates .

hygen terraform gcp
hygen terraform aws

gh repo create --private --remote hygen-test --source .
git push -u hygen-test main

Authors

Gary Mc Dermott

Github Profile

License

This project is licensed under the MIT License - see the LICENSE.md file for details

hygen-terraform's People

Contributors

mcdermg avatar

Stargazers

Roman avatar

Watchers

 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.