Git Product home page Git Product logo

terragrunt-infrastructure-gcp's Introduction

Terragrunt example for GCP

A Terragrunt example to layout folders and modules in a Google Cloud Platform project. This is a real production-ready example, but you can change the folders/moduleslayout based on your requirements and needs.

This layout is trying to make both code and confirations really DRY. It is also solving a common chicken and egg problem: "how can I apply code with a remote state without having the remote backend in place?" --> remote_state block in live/global.hcl.

A brief overview on files in this repo:

  • live/global.hcl contains global parameters (e.g region, location, common prefixes, ..)
  • live/terragrunt.hcl centrally defines backend configurations, provider(s) definition, backend creation, global parameters
  • live/_envcommon folder sets the common resources needed among all environments (dev and prod)
  • live/dev/environment.hcl defines environment specific parameters

Code is self-explanatory, please read comments in hcl files.

How to use repository

pre-commit initialization

To format the code in this repo I use pre-commit. You can install the tool with pip or brew:

# Install with pip
pip install pre-commit

# Install with brew
brew install pre-commit

Once installed you need to configure the cloned repo to use the versioned configuration:

pre-commit install

For further information read the upstream documentation.

Configure Terraform authentication

Read Terraform documentation for Google provider as a reference.

Set your GCP project IDs

Replace placeholders in:

Deploy a single module in an environment

cd infrastructure/gcp/dev/buckets
terragrunt plan -out=terragrunt.plan
terragrunt apply terragrunt.plan

Deploy all modules within an environment

cd infrastructure/gcp/dev
terragrunt run-all --terragrunt-no-auto-approve apply

terragrunt-infrastructure-gcp's People

Contributors

pibong avatar

Stargazers

Hue Truong 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.