Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use terragrunt parser to parse terragrunt.hcl #264

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marcoreni
Copy link

Fixes #259 .

This PR introduces the Terragrunt parser to handle terragrunt.hcl parsing, so that include blocks can be read and more complex logics of constraints can be handled (for example, having the constraint inside a parent file).

Pros:

  • Uses Terragrunt logics, that is thoroughly tested on the terragrunt repo.
  • The same mechanism can be added to tgswitch with minimal effort.

Cons:

  • Since Terragrunt does not expose APIs, using it requires lots of libraries (+20MB in my sample compiled build) and requires logrus to be initialized to avoid crash.

LMKWYT

@Tensho
Copy link

Tensho commented Jul 25, 2022

Hey 👋 I have the same use case with hierarchical terraform/terragrunt constraints definition.

terragrunt.hcl     # <= terraform_version_constraint = "1.1.6"
test
  component
    terragrunt.hcl # <= implicit include of the root terragrunt.hcl config, no explicit terraform_version_constraint definition
prod
  component
    terragrunt.hcl

As far as tfswitch already supports current terragrunt.hcl parsing I think it's reasonable to extend it further.

Another option could be checking .tfswitchrc file presence from the current folder to root one, a bottom-up search through a hierarchy.

.tfswitchrc     # <= 1.1.6
test
  component 
                # <= Switch to default 1.1.6
prod
  component
    .tfswitchrc # <= Switch to override 1.1.7

@marcoreni
Copy link
Author

@Tensho that is another possibility, yes. I went this way because by using the hcl I would need to declare the constraint once and I would be able to delete the .tfswitchrc files entirely

@MatrixCrawler MatrixCrawler added the help wanted Extra attention is needed label Apr 5, 2024
@MatrixCrawler
Copy link
Collaborator

@marcoreni Could you rebase and update this PR to the latest terragrunt version? There seems to be a lot of changes since you opened that PR.
Also it would be good to have a test case for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
3 participants