tgswitch icon indicating copy to clipboard operation
tgswitch copied to clipboard

Support terragrunt.hcl file like tfswitch

Open Swahjak opened this issue 2 years ago • 16 comments

Hi. First of all, thanks for both tgswitch and tfswitch. Absolute life savers.

Would be awesome if you could support using the terragrunt.hcl file like tfswitch does.

Swahjak avatar Apr 13 '22 14:04 Swahjak

++ Was kinda surprised that tfswitch supported this but tgswitch didn't!

crablab avatar Apr 25 '22 16:04 crablab

@warrensbox given the open issues, wouldn't it make sense to just completely switch the current tgswitch package and replace it with the ftswitch code? (and obviously switch out 'tf / terraform' with 'tg / terragrunt'. The code seems pretty generic (I don't do Go so ignore my ignorance if this is not the case).

Is that something worth considering? And is it something you're still willing to commit to?

Swahjak avatar Jun 07 '22 10:06 Swahjak

Ok, so that was a bit less generic than expected, but I think I've managed to port it: https://github.com/Swahjak/terragrunt-switcher.

Once again; I am by no means a Go developer so I'm just going with what was available. That is also the reason for me referring to Swahjak/terragrunt-switcher, not trying to hijack your product, just didn't know how to test / get it to work without changing these references. If this is something you're willing to use / look at it @warrensbox I would be more than happy to create a pull (and obviously change Swahjak/terragrunt-switcher back to warrensbox/terragrunt-switcher).

Swahjak avatar Jun 08 '22 10:06 Swahjak

I am working on this. I will release feature this next Monday Jun 13, 2022 @Swahjak

warrensbox avatar Jun 08 '22 16:06 warrensbox

I apologize for the delay. I am still running test cases for this release.

warrensbox avatar Jun 15 '22 18:06 warrensbox

No worries! Glad you're willing to commit time to this.

Swahjak avatar Jun 16 '22 13:06 Swahjak

@Swahjak I released this feature with 0.6.0 https://github.com/warrensbox/tgswitch/releases/tag/0.6.0 Can you help me test it?

warrensbox avatar Jun 23 '22 06:06 warrensbox

Hi, I have a simple setup that results in a 404 page from GitHub pages being downloaded and stored in ~/.terragrunt.versions:

terragrunt.hcl:

terragrunt_version_constraint = "0.35.20"
$ rm -r ~/.terragrunt.versions && tgswitch
Terragrunt file found: /Users/max.friedrich/tgswitch-test/terragrunt.hcl
Reading required version from constraint: 0.35.20
Matched version: 0.35.20
2022/07/07 14:56:54 Creating directory for terragrunt: /Users/max.friedrich/.terragrunt.versions/
Downloading https://warrensbox.github.io/terragunt-versions-list/index.json/v0.35.20/terragrunt_darwin_amd64 to terragrunt_darwin_amd64
Downloading ...
9339 bytes downloaded.
Switched terragrunt to version "0.35.20"

$ head ~/.terragrunt.versions/terragrunt_0.35.20
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <meta http-equiv="Content-Security-Policy" content="default-src 'none'; style-src 'unsafe-inline'; img-src data:; connect-src 'self'">
    <title>Page not found &middot; GitHub Pages</title>
    <style type="text/css" media="screen">
      body {
        background-color: #f1f1f1;
        margin: 0;

If the specified version was already downloaded before with tgswitch "0.35.20" everything works as expected.

maxfriedrich avatar Jul 07 '22 13:07 maxfriedrich

+1 to this, installed tgswitch and running into the same error on a new install. Which then results in

→ [04:17:28]  ✗ terragrunt -v
/Users/shabbirkagalwala/bin/terragrunt: line 7: syntax error near unexpected token `newline'
/Users/shabbirkagalwala/bin/terragrunt: line 7: `<!DOCTYPE html>'

The version I installed was

→ [04:22:31]  ✗ tgswitch --version

Version: 0.6.0

shabbskagalwala avatar Jul 08 '22 23:07 shabbskagalwala

@warrensbox behalf of @Swahjak i can say its working.

I also would like to suggest if you can provide this issue too : https://github.com/warrensbox/tgswitch/issues/89

you can close this

wouter-toppy avatar Aug 04 '22 09:08 wouter-toppy

find out now, I have the same issue as @maxfriedrich

wouter-toppy avatar Aug 04 '22 09:08 wouter-toppy

If the specified version was already downloaded before with tgswitch "0.35.20" everything works as expected

This is a temperary solution

wouter-toppy avatar Aug 04 '22 11:08 wouter-toppy

I am traveling out of the country at the moment. I will take a look at this when I return home.

warrensbox avatar Aug 08 '22 02:08 warrensbox

have the same issue, any chance this can have more attention?

antimack avatar Oct 19 '22 07:10 antimack

I have created a separate issue for the 404 problem - I don't think it is related to this issue, which can probably be closed since the functionality has been released.

crablab avatar Nov 02 '22 14:11 crablab

btw. you can also use tenv that support Terraform as well as OpenTofu (and Terragrunt :) ) in one tool. It allow you to simplify version management and can do much more, than tgswitch.

kvendingoldo avatar Apr 03 '24 14:04 kvendingoldo