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

Install version from terragrunt_version_constraint #18

Open
Moulick opened this issue Aug 25, 2023 · 3 comments
Open

Install version from terragrunt_version_constraint #18

Moulick opened this issue Aug 25, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@Moulick
Copy link

Moulick commented Aug 25, 2023

Can we have this action figure out and install terragrunt version from the terragrunt_version_constraint in terragrunt.hcl?

Additional context
This will help in keeping terragrunt version automatically updated within reason

@Moulick Moulick added the enhancement New feature or request label Aug 25, 2023
@denis256
Copy link
Member

Hello,
looks like to implement this feature will be required to parse HCL files(with includes, locals, env variables resolving) and identify which will be the value of terragrunt_version_constraint

@Moulick
Copy link
Author

Moulick commented Aug 29, 2023

As far as I read, tgswitch supports figuring out the version terragrunt_version_constraint automatically. https://github.com/warrensbox/tgswitch#use-terragrunthcl-file It'll figure out the version from .terragrunt-version or terragrunt_version_constraint if a version is not explicitly mentioned

@michw
Copy link

michw commented Sep 1, 2023

A workaround that works for me:

       - name: 'Extract terraform and terragrunt version from terragrunt-root.hcl'
         id: extract-tftg-version
         run: |
           tf_version=$(sed -n 's/^terraform_version_constraint.*=.*\"= \([0-9.]\+\)\"/\1/p' terragrunt-root.hcl)
           tg_version=$(sed -n 's/^terragrunt_version_constraint.*=.*\"= \([0-9.]\+\)\"/\1/p' terragrunt-root.hcl)
           echo "tf_version=$tf_version" | tee -a "$GITHUB_OUTPUT"
           echo "tg_version=$tg_version" | tee -a "$GITHUB_OUTPUT"

and then use them, i.e.:

       - name: (staging) terragrunt plan
         uses: gruntwork-io/terragrunt-action@v1
         with:
           tf_version: ${{ steps.extract-tftg-version.outputs.tf_version }}
           tg_version: ${{ steps.extract-tftg-version.outputs.tg_version }}
           tg_dir: '${{ github.workspace }}/non-prod/us-east-1/staging'
           tg_command: '--terragrunt-non-interactive run-all plan'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants