Giter VIP home page Giter VIP logo

grunter's Introduction

Grunter

'grʌntər

A worker, often in a technical, creative, or professional field, who performs the repetitive, tedious, or less glamorous tasks necessary for a project or operation. This may involve any work deemed necessary but not necessarily requiring high-level decision-making or creativity.

Go Report Card Go Reference

Grunter is a simple Terragrunt file generator. It generates a terragrunt.hcl file from your config.yaml file in the current directory.

It enables you to define your Terragrunt configuration in a simple YAML file, which is easier to read and maintain than the HCL format. It saves you from writing the boilerplate code for each module and keeps your IaaC configuration even DRYer.

It is meant to be used in conjunction with Terragrunt, a thin wrapper for Terraform that provides extra tools for keeping your configurations DRY and managing remote state.

The configuration format is defined here.

Installation

go install github.com/romainframe/grunter@latest

Usage

grunter gen

Example

Given the following config.yaml file:

template: modules/k8s/namespace/default
metadata:
  cluster: main
dependencies:
  - name: cluster
    path: ../../../cluster
    pathType: relative
    withOutputs: true
  - name: env
    path: "${local.env}/example-${local.stack_namespace}"
    pathType: root
inputs:
  name: local.values.locals.name
  namespace: local.values.locals.namespace

The following terragrunt.hcl file will be generated:

# Dependencies
dependency "cluster" {
  config_path  = "../../../cluster"
  skip_outputs = false
}
dependency "env" {
  config_path  = "${local.env}/example-${local.stack_namespace}"
  skip_outputs = true
}

# Locals
locals {
  cluster = read_terragrunt_config("../../../services/k8s/main/values.hcl")
  # grunted locals = begin
  email         = get_env("TF_VAR_EMAIL", "")
  project       = read_terragrunt_config(find_in_parent_folders("project.hcl"))
  template_root = get_env("TF_VAR_TEMPLATE_ROOT", "")
  values        = read_terragrunt_config("values.hcl")
  # grunted locals = end
}

# OpenTofu Configuration
terraform {
  before_hook "gke-context" {
    commands = ["plan", "apply", "destroy", ]
    execute  = ["bash", "-c", "gcloud config set account ${local.email} && gcloud container clusters get-credentials ${local.cluster.locals.name} --region=${local.cluster.locals.region}  --project=${local.project.locals.slug}", ]
  }

  source = "${local.template_root}//modules/k8s/namespace/default"
}

# Include all settings from the root terragrunt.hcl file
include {
  path = find_in_parent_folders()
}

# Inputs to pass to the Terraform module
inputs = {
  name      = local.values.locals.name
  namespace = local.values.locals.namespace
}

© 2024 Romain Untereiner. All materials licensed under Apache v2.0

grunter's People

Contributors

romainframe avatar

Stargazers

 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.