Git Product home page Git Product logo

tflint-config-generator's Introduction

TFLint Config Generator

Tools for generating an up-to-date .tflint.hcl configuration file for use with tflint.

The configuration options change often enough to annoy me, so here is some automation for generating it.

Requirements

  • macOS/Linux/WSL
  • make
  • Git
  • Go
  • Familiarity with Go templates (for making changes)

Usage

There are 4 supported modes:

  • Amazon Web Services (AWS)
  • Google Cloud Platform (GCP)
  • Microsoft Azure (Azure)
  • "base" (e.g., New Relic, PagerDuty, Cloudflare, Artifactory)

Base version

This is the version that has the good rules for standard Terraform, but is not tied to any particular cloud provider. This is useful when using one of the other 2,000 providers that aren't AWS, GCP, or Azure.

make base

This will output a file called .tflint.hcl which can be copied into your project and used with tflint.

Cloud versions

This is the version that has everything that base has, with the addition of all of the cloud-specific rules enabled.

NOTE: There is not yet any way to override individual values as enabled = false. Open an issue if you want this and are willing to help.

make aws
make gcp
make azure

This will output a file called .tflint.hcl which can be copied into your project and used with tflint.

This whole approach works by fetching the terraform-linters/tflint-ruleset-* repository and leveraging its existing code generation in a different way. By default, this uses the latest version of that ruleset I've personally tested. But if there is a newer/older version you want to use instead, you can pass the intended Git tag for the repository.

make aws TFLINT_AWS_TAG=0.13.2
make gcp TFLINT_GCP_TAG=0.16.1
make azure TFLINT_AZURE_TAG=0.15.0

You can find Git tag values at:

How does it work?

Base

  1. Generate the "Base" .tflint.hcl file from the _base.tmpl.hcl template.

Cloud

  1. Read _base.tmpl.hcl.
  2. Apply cloud-specific overlay (e.g., _aws.tmpl.hcl) to generate a new template that will be passed to the ruleset repo for further code generation.
  3. Clones the tflint-ruleset-* repo to your /tmp directory.
  4. Resolves the Git submodules.
  5. There is a file that is used as a template for generating a README with a list of all of the options. We replace that template with our own (see step 2).
  6. We run the generation step that's already part of the the upstream build process.
  7. We take the output file, and replace our .tflint.hcl file with it.

tflint-config-generator's People

Contributors

dependabot[bot] avatar skyzyx avatar step-security-bot 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.