Skip to content

Git config like .tflint.hcl files combination #1536

@pjroth

Description

@pjroth

Introduction

I have a git repo with lots of directories that represent my deployed infrastructure. I'm using the Gruntwork infrastructure-live setup as can be seen in their example.

In my directories that start with /dev which represent my dev infrastructure. I want to allow main as a target for terraform module source lines so that I can deploy to DEV work that is not yet tagged/released such as:

module "my-app" {
  source                     = "git::ssh://git@bitbucket.org/my-org/my-repo.git//terraform?ref=main"

  // etc
}

In my qa and prod directories, I want to allow only released version tags and NOT allow main such as:

module "my-app" {
  source                     = "git::ssh://git@bitbucket.org/my-org/my-repo.git//terraform?ref=1.2.3"

  // etc
}

This means I need to configure tflint differently depending on which directory tree I'm under. Specifically I want to disable the rule terraform_module_pinned_source for my dev environment but enable it for my qa and prod environments.

Proposal

Allow .tflint.hcl files to "combine" if multiple files exist in defined locations. This would happen by looking "up" directories until the root is reached combining them into one where the more specific directory takes precedence. This would allow me to put "common" config into my home directory the root of /dev to disable the rules I need to disable for my dev files

A slightly different solution is to not look in all directories, but define some locations, perhaps GLOBAL -> HOME DIR -> current directory. This solution is inspired withs how git config files work. Copying the git config solution would be very nice and consistent since many users are likely familiar with git config.

Thank you for this great tool!

References

  1. https://git-scm.com/docs/git-config#FILES

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementneeds-designDetailed design is required for implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions