Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ jobs:
terragrunt-integration-tests:
name: Terragrunt Integration Tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
terragrunt_version:
- "0.78.0"
- "0.95.1"
- "latest"
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
Expand All @@ -97,7 +104,7 @@ jobs:
- name: Install Terragrunt
uses: autero1/action-terragrunt@v3
with:
terragrunt-version: 0.77.20
terragrunt-version: ${{ matrix.terragrunt_version }}
- name: Print Terragrunt version
run: |
terragrunt --version
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,27 @@ TERRATAG_KEEP_EXISTING_TAGS
- `azurestack`
- `azapi`

### Usage with Terragrunt

Terratag supports Terragrunt v0.78.0 and above.
> Note: Terragrunt hasn't released a stable 1.x version yet,
so compatibility with future releases isn't guaranteed.

To use terratag with Terragrunt:

- Use `-type=terragrunt` for a standard unit
- Use `-type=terragrunt-run-all` for implicit stacks

> Note: Explicit stacks are not explicitly supported.
If you are working with an explicit stack,
you may run terratag on each unit individually by using `-type=terragrunt` and `-dir=<unit_path>`.
If your generated stack is similar to an implicit stack,
you may use `-type=terragrunt-run-all` from the generated stack directory (`.terragrunt-stack` by default).
Remember to initialize the units in the stack by either running `terragrunt stack run init`,
or running `terragrunt init` in each unit beforehand.

If issues arise with new Terragrunt versions, please open an issue.

## Develop

Issues and Pull Requests are very welcome!
Expand Down
16 changes: 10 additions & 6 deletions internal/tfschema/tfschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,17 @@ func InitProviderSchemas(dir string, iacType common.IACType, defaultToTerraform

log.Print("[INFO] Fetching provider schemas for directory: ", dir)

var cmd *exec.Cmd
if iacType == common.TerragruntRunAll {
log.Print("[INFO] Using terragrunt run-all mode")
cmd = exec.Command(name, "run-all", "providers", "schema", "-json")
} else {
cmd = exec.Command(name, "providers", "schema", "-json")
cmd := exec.Command(name)
if iacType == common.Terragrunt || iacType == common.TerragruntRunAll {
cmd.Args = append(cmd.Args, "run")
if iacType == common.TerragruntRunAll {
log.Print("[INFO] Using terragrunt run-all mode")
cmd.Args = append(cmd.Args, "--all")
}
cmd.Args = append(cmd.Args, "--")
}

cmd.Args = append(cmd.Args, "providers", "schema", "-json")
cmd.Dir = dir

out, err := cmd.Output()
Expand Down
8 changes: 5 additions & 3 deletions terratag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,11 @@ func itShouldGenerateExpectedTerragruntTerratagFiles(entryDir string, g *GomegaW
expectedPattern := entryDir + "/expected/**/*.tf"
expectedTerratag, _ := doublestar.Glob(expectedPattern)

cachePattern := entryDir + "/out/**/.terragrunt-cache"
cachePattern := entryDir + "/out/**/unit*/.terragrunt-cache"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change may not be needed anymore. There was a bug in terragrunt v.94.0^ that was fixed in v0.96.0;

Unnecessary .terragrunt-cache directory no longer generated in run --all runs

I am keeping this in for now, as one of the integration tests is testing terragrunt version 0.95.1. If we do not want to test between those two version numbers, we can remove this change.

cacheDirs, _ := doublestar.Glob(cachePattern)

g.Expect(len(cacheDirs)).To(BeNumerically(">", 0))

for _, cacheDir := range cacheDirs {
hashmap := make(map[string]string)

Expand Down Expand Up @@ -458,9 +460,9 @@ func run_opentofu(entryDir string, cmd string) error {
}

func run_terragrunt(entryDir string, cmd string, runAll bool) error {
args := []string{}
args := []string{"run"}
if runAll {
args = append(args, "run-all")
args = append(args, "--all")
}
args = append(args, cmd)

Expand Down