Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package terragrunt for openSUSE:Factory checked in at 2023-05-31 21:54:32 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/terragrunt (Old) and /work/SRC/openSUSE:Factory/.terragrunt.new.1533 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "terragrunt" Wed May 31 21:54:32 2023 rev:49 rq:1089900 version:0.45.17 Changes: -------- --- /work/SRC/openSUSE:Factory/terragrunt/terragrunt.changes 2023-05-25 23:52:42.155669412 +0200 +++ /work/SRC/openSUSE:Factory/.terragrunt.new.1533/terragrunt.changes 2023-05-31 21:54:33.289025742 +0200 @@ -1,0 +2,6 @@ +Wed May 31 04:45:56 UTC 2023 - ka...@b1-systems.de + +- Update to version 0.45.17: + * fix: checking dependent modules in `destroy` command (#2581) + +------------------------------------------------------------------- Old: ---- terragrunt-0.45.16.obscpio New: ---- terragrunt-0.45.17.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ terragrunt.spec ++++++ --- /var/tmp/diff_new_pack.TaWqSF/_old 2023-05-31 21:54:34.101030542 +0200 +++ /var/tmp/diff_new_pack.TaWqSF/_new 2023-05-31 21:54:34.105030565 +0200 @@ -19,7 +19,7 @@ %define __arch_install_post export NO_BRP_STRIP_DEBUG=true Name: terragrunt -Version: 0.45.16 +Version: 0.45.17 Release: 0 Summary: Thin wrapper for Terraform for working with multiple Terraform modules License: MIT ++++++ _service ++++++ --- /var/tmp/diff_new_pack.TaWqSF/_old 2023-05-31 21:54:34.137030754 +0200 +++ /var/tmp/diff_new_pack.TaWqSF/_new 2023-05-31 21:54:34.141030778 +0200 @@ -3,7 +3,7 @@ <param name="url">https://github.com/gruntwork-io/terragrunt</param> <param name="scm">git</param> <param name="exclude">.git</param> - <param name="revision">v0.45.16</param> + <param name="revision">v0.45.17</param> <param name="versionformat">@PARENT_TAG@</param> <param name="changesgenerate">enable</param> <param name="versionrewrite-pattern">v(.*)</param> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.TaWqSF/_old 2023-05-31 21:54:34.161030896 +0200 +++ /var/tmp/diff_new_pack.TaWqSF/_new 2023-05-31 21:54:34.165030920 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/gruntwork-io/terragrunt</param> - <param name="changesrevision">e5b394060e8eb5009b99d15195e64688614a768f</param></service></servicedata> + <param name="changesrevision">9154ad0ff23e876c9e2bfe0ad7948e179c2bbdae</param></service></servicedata> (No newline at EOF) ++++++ terragrunt-0.45.16.obscpio -> terragrunt-0.45.17.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.45.16/cli/cli_app.go new/terragrunt-0.45.17/cli/cli_app.go --- old/terragrunt-0.45.16/cli/cli_app.go 2023-05-24 21:08:10.000000000 +0200 +++ new/terragrunt-0.45.17/cli/cli_app.go 2023-05-30 13:50:03.000000000 +0200 @@ -606,7 +606,7 @@ // Run graph dependencies prints the dependency graph to stdout func runGraphDependencies(terragruntOptions *options.TerragruntOptions) error { - stack, err := configstack.FindStackInSubfolders(terragruntOptions) + stack, err := configstack.FindStackInSubfolders(terragruntOptions, nil) if err != nil { return err } @@ -1186,7 +1186,7 @@ } } - stack, err := configstack.FindStackInSubfolders(terragruntOptions) + stack, err := configstack.FindStackInSubfolders(terragruntOptions, nil) if err != nil { return err } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.45.16/config/config.go new/terragrunt-0.45.17/config/config.go --- old/terragrunt-0.45.16/config/config.go 2023-05-24 21:08:10.000000000 +0200 +++ new/terragrunt-0.45.17/config/config.go 2023-05-30 13:50:03.000000000 +0200 @@ -80,7 +80,7 @@ IsPartial bool // Map of processed includes - ProcessedIncludes map[string]IncludeConfig + ProcessedIncludes IncludeConfigs // Map to store fields metadata FieldsMetadata map[string]map[string]interface{} @@ -241,6 +241,19 @@ Disable *bool `hcl:"disable,attr" mapstructure:"disable"` } +type IncludeConfigs map[string]IncludeConfig + +// ContainsPath returns true if the given path is contained in at least one configuration. +func (cfgs IncludeConfigs) ContainsPath(path string) bool { + for _, cfg := range cfgs { + if cfg.Path == path { + return true + } + } + + return false +} + // IncludeConfig represents the configuration settings for a parent Terragrunt configuration file that you can // include into a child Terragrunt configuration file. You can have more than one include config. type IncludeConfig struct { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.45.16/config/config_helpers.go new/terragrunt-0.45.17/config/config_helpers.go --- old/terragrunt-0.45.16/config/config_helpers.go 2023-05-24 21:08:10.000000000 +0200 +++ new/terragrunt-0.45.17/config/config_helpers.go 2023-05-30 13:50:03.000000000 +0200 @@ -444,14 +444,15 @@ return ".", nil } - includePath := filepath.Dir(included.Path) currentPath := filepath.Dir(terragruntOptions.TerragruntConfigPath) + includePath := filepath.Dir(included.Path) if !filepath.IsAbs(includePath) { includePath = util.JoinPath(currentPath, includePath) } - return util.GetPathRelativeTo(currentPath, includePath) + relativePath, err := util.GetPathRelativeTo(currentPath, includePath) + return relativePath, err } // Return the relative path from the current Terragrunt configuration to the included Terragrunt configuration file @@ -561,7 +562,7 @@ return cty.NilVal, errors.WithStackTrace(WrongNumberOfParams{Func: "read_terragrunt_config", Expected: "1 or 2", Actual: numParams}) } - configPath, err := ctySliceToStringSlice(args[:1]) + strArgs, err := ctySliceToStringSlice(args[:1]) if err != nil { return cty.NilVal, err } @@ -570,7 +571,11 @@ if numParams == 2 { defaultVal = &args[1] } - return readTerragruntConfig(configPath[0], defaultVal, terragruntOptions) + + targetConfigPath := strArgs[0] + + relativePath, err := readTerragruntConfig(targetConfigPath, defaultVal, terragruntOptions) + return relativePath, err }, }) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.45.16/config/config_partial.go new/terragrunt-0.45.17/config/config_partial.go --- old/terragrunt-0.45.16/config/config_partial.go 2023-05-24 21:08:10.000000000 +0200 +++ new/terragrunt-0.45.17/config/config_partial.go 2023-05-30 13:50:03.000000000 +0200 @@ -193,13 +193,14 @@ // PartialParseConfigString partially parses and decodes the provided string. Which blocks/attributes to decode is // controlled by the function parameter decodeList. These blocks/attributes are parsed and set on the output // TerragruntConfig. Valid values are: -// - DependenciesBlock: Parses the `dependencies` block in the config -// - DependencyBlock: Parses the `dependency` block in the config -// - TerraformBlock: Parses the `terraform` block in the config -// - TerragruntFlags: Parses the boolean flags `prevent_destroy` and `skip` in the config -// - TerragruntVersionConstraints: Parses the attributes related to constraining terragrunt and terraform versions in -// the config. -// - RemoteStateBlock: Parses the `remote_state` block in the config +// - DependenciesBlock: Parses the `dependencies` block in the config +// - DependencyBlock: Parses the `dependency` block in the config +// - TerraformBlock: Parses the `terraform` block in the config +// - TerragruntFlags: Parses the boolean flags `prevent_destroy` and `skip` in the config +// - TerragruntVersionConstraints: Parses the attributes related to constraining terragrunt and terraform versions in +// the config. +// - RemoteStateBlock: Parses the `remote_state` block in the config +// // Note that the following blocks are always decoded: // - locals // - include diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.45.16/configstack/module.go new/terragrunt-0.45.17/configstack/module.go --- old/terragrunt-0.45.16/configstack/module.go 2023-05-24 21:08:10.000000000 +0200 +++ new/terragrunt-0.45.17/configstack/module.go 2023-05-30 13:50:03.000000000 +0200 @@ -43,18 +43,18 @@ // Go through each of the given Terragrunt configuration files and resolve the module that configuration file represents // into a TerraformModule struct. Return the list of these TerraformModule structs. -func ResolveTerraformModules(terragruntConfigPaths []string, terragruntOptions *options.TerragruntOptions, howThesePathsWereFound string) ([]*TerraformModule, error) { +func ResolveTerraformModules(terragruntConfigPaths []string, terragruntOptions *options.TerragruntOptions, childTerragruntConfig *config.TerragruntConfig, howThesePathsWereFound string) ([]*TerraformModule, error) { canonicalTerragruntConfigPaths, err := util.CanonicalPaths(terragruntConfigPaths, ".") if err != nil { return []*TerraformModule{}, err } - modules, err := resolveModules(canonicalTerragruntConfigPaths, terragruntOptions, howThesePathsWereFound) + modules, err := resolveModules(canonicalTerragruntConfigPaths, terragruntOptions, childTerragruntConfig, howThesePathsWereFound) if err != nil { return []*TerraformModule{}, err } - externalDependencies, err := resolveExternalDependenciesForModules(modules, map[string]*TerraformModule{}, 0, terragruntOptions) + externalDependencies, err := resolveExternalDependenciesForModules(modules, map[string]*TerraformModule{}, 0, terragruntOptions, childTerragruntConfig) if err != nil { return []*TerraformModule{}, err } @@ -82,7 +82,7 @@ return finalModules, nil } -//flagExcludedDirs iterates over a module slice and flags all entries as excluded, which should be ignored via the terragrunt-exclude-dir CLI flag. +// flagExcludedDirs iterates over a module slice and flags all entries as excluded, which should be ignored via the terragrunt-exclude-dir CLI flag. func flagExcludedDirs(modules []*TerraformModule, terragruntOptions *options.TerragruntOptions) ([]*TerraformModule, error) { // If no ExcludeDirs is specified return the modules list instantly @@ -144,7 +144,7 @@ return modules, nil } -//flagIncludedDirs iterates over a module slice and flags all entries not in the list specified via the terragrunt-include-dir CLI flag as excluded. +// flagIncludedDirs iterates over a module slice and flags all entries not in the list specified via the terragrunt-include-dir CLI flag as excluded. func flagIncludedDirs(modules []*TerraformModule, terragruntOptions *options.TerragruntOptions) ([]*TerraformModule, error) { // If no IncludeDirs is specified return the modules list instantly @@ -292,11 +292,11 @@ // Go through each of the given Terragrunt configuration files and resolve the module that configuration file represents // into a TerraformModule struct. Note that this method will NOT fill in the Dependencies field of the TerraformModule // struct (see the crosslinkDependencies method for that). Return a map from module path to TerraformModule struct. -func resolveModules(canonicalTerragruntConfigPaths []string, terragruntOptions *options.TerragruntOptions, howTheseModulesWereFound string) (map[string]*TerraformModule, error) { +func resolveModules(canonicalTerragruntConfigPaths []string, terragruntOptions *options.TerragruntOptions, childTerragruntConfig *config.TerragruntConfig, howTheseModulesWereFound string) (map[string]*TerraformModule, error) { moduleMap := map[string]*TerraformModule{} for _, terragruntConfigPath := range canonicalTerragruntConfigPaths { - module, err := resolveTerraformModule(terragruntConfigPath, terragruntOptions, howTheseModulesWereFound) + module, err := resolveTerraformModule(terragruntConfigPath, terragruntOptions, childTerragruntConfig, howTheseModulesWereFound) if err != nil { return moduleMap, err } @@ -311,7 +311,7 @@ // Create a TerraformModule struct for the Terraform module specified by the given Terragrunt configuration file path. // Note that this method will NOT fill in the Dependencies field of the TerraformModule struct (see the // crosslinkDependencies method for that). -func resolveTerraformModule(terragruntConfigPath string, terragruntOptions *options.TerragruntOptions, howThisModuleWasFound string) (*TerraformModule, error) { +func resolveTerraformModule(terragruntConfigPath string, terragruntOptions *options.TerragruntOptions, childTerragruntConfig *config.TerragruntConfig, howThisModuleWasFound string) (*TerraformModule, error) { modulePath, err := util.CanonicalPath(filepath.Dir(terragruntConfigPath), ".") if err != nil { return nil, err @@ -325,13 +325,22 @@ // from, which is not what any of the modules will want. opts.OriginalTerragruntConfigPath = terragruntConfigPath + // If `childTerragruntConfig.ProcessedIncludes` contains the path `terragruntConfigPath`, then this is a parent config + // which implies that `TerragruntConfigPath` must refer to a child configuration file, and the defined `IncludeConfig` must contain the path to the file itself + // for the built-in functions `read-terragrunt-config()`, `path_relative_to_include()` to work correctly. + var includeConfig *config.IncludeConfig + if childTerragruntConfig != nil && childTerragruntConfig.ProcessedIncludes.ContainsPath(terragruntConfigPath) { + includeConfig = &config.IncludeConfig{Path: terragruntConfigPath} + opts.TerragruntConfigPath = terragruntOptions.OriginalTerragruntConfigPath + } + // We only partially parse the config, only using the pieces that we need in this section. This config will be fully // parsed at a later stage right before the action is run. This is to delay interpolation of functions until right // before we call out to terraform. terragruntConfig, err := config.PartialParseConfigFile( terragruntConfigPath, opts, - nil, + includeConfig, []config.PartialDecodeSectionType{ // Need for initializing the modules config.TerraformSource, @@ -390,7 +399,7 @@ // environment the user is trying to apply-all or destroy-all. Therefore, this method also confirms whether the user wants // to actually apply those dependencies or just assume they are already applied. Note that this method will NOT fill in // the Dependencies field of the TerraformModule struct (see the crosslinkDependencies method for that). -func resolveExternalDependenciesForModules(moduleMap map[string]*TerraformModule, modulesAlreadyProcessed map[string]*TerraformModule, recursionLevel int, terragruntOptions *options.TerragruntOptions) (map[string]*TerraformModule, error) { +func resolveExternalDependenciesForModules(moduleMap map[string]*TerraformModule, modulesAlreadyProcessed map[string]*TerraformModule, recursionLevel int, terragruntOptions *options.TerragruntOptions, childTerragruntConfig *config.TerragruntConfig) (map[string]*TerraformModule, error) { allExternalDependencies := map[string]*TerraformModule{} modulesToSkip := mergeMaps(moduleMap, modulesAlreadyProcessed) @@ -402,7 +411,7 @@ sortedKeys := getSortedKeys(moduleMap) for _, key := range sortedKeys { module := moduleMap[key] - externalDependencies, err := resolveExternalDependenciesForModule(module, modulesToSkip, terragruntOptions) + externalDependencies, err := resolveExternalDependenciesForModule(module, modulesToSkip, terragruntOptions, childTerragruntConfig) if err != nil { return externalDependencies, err } @@ -426,7 +435,7 @@ } if len(allExternalDependencies) > 0 { - recursiveDependencies, err := resolveExternalDependenciesForModules(allExternalDependencies, moduleMap, recursionLevel+1, terragruntOptions) + recursiveDependencies, err := resolveExternalDependenciesForModules(allExternalDependencies, moduleMap, recursionLevel+1, terragruntOptions, childTerragruntConfig) if err != nil { return allExternalDependencies, err } @@ -441,7 +450,7 @@ // dependencies are outside of the current working directory, which means they may not be part of the environment the // user is trying to apply-all or destroy-all. Note that this method will NOT fill in the Dependencies field of the // TerraformModule struct (see the crosslinkDependencies method for that). -func resolveExternalDependenciesForModule(module *TerraformModule, moduleMap map[string]*TerraformModule, terragruntOptions *options.TerragruntOptions) (map[string]*TerraformModule, error) { +func resolveExternalDependenciesForModule(module *TerraformModule, moduleMap map[string]*TerraformModule, terragruntOptions *options.TerragruntOptions, chilTerragruntConfig *config.TerragruntConfig) (map[string]*TerraformModule, error) { if module.Config.Dependencies == nil || len(module.Config.Dependencies.Paths) == 0 { return map[string]*TerraformModule{}, nil } @@ -460,7 +469,7 @@ } howThesePathsWereFound := fmt.Sprintf("dependency of module at '%s'", module.Path) - return resolveModules(externalTerragruntConfigPaths, terragruntOptions, howThesePathsWereFound) + return resolveModules(externalTerragruntConfigPaths, terragruntOptions, chilTerragruntConfig, howThesePathsWereFound) } // Confirm with the user whether they want Terragrunt to assume the given dependency of the given module is already @@ -574,7 +583,7 @@ func FindWhereWorkingDirIsIncluded(terragruntOptions *options.TerragruntOptions, terragruntConfig *config.TerragruntConfig) []*TerraformModule { var pathsToCheck []string var matchedModulesMap = make(map[string]*TerraformModule) - var gitTopLevelDir = "" + gitTopLevelDir, err := shell.GitTopLevelDir(terragruntOptions, terragruntOptions.WorkingDir) if err == nil { // top level detection worked pathsToCheck = append(pathsToCheck, gitTopLevelDir) @@ -587,6 +596,7 @@ pathsToCheck = append(pathsToCheck, path) } } + for _, dir := range pathsToCheck { // iterate over detected paths, build stacks and filter modules by working dir dir = dir + filepath.FromSlash("/") cfgOptions, err := options.NewTerragruntOptions(dir) @@ -594,13 +604,17 @@ terragruntOptions.Logger.Debugf("Failed to build terragrunt options from %s %v", dir, err) return nil } + cfgOptions.Env = terragruntOptions.Env cfgOptions.LogLevel = terragruntOptions.LogLevel + cfgOptions.OriginalTerragruntConfigPath = terragruntOptions.OriginalTerragruntConfigPath + if terragruntOptions.TerraformCommand == "destroy" { var hook = NewForceLogLevelHook(logrus.DebugLevel) cfgOptions.Logger.Logger.AddHook(hook) } - stack, err := FindStackInSubfolders(cfgOptions) + + stack, err := FindStackInSubfolders(cfgOptions, terragruntConfig) if err != nil { // loggign error as debug since in some cases stack building may fail because parent files can be designed // to work with relative paths from downstream modules diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.45.16/configstack/module_test.go new/terragrunt-0.45.17/configstack/module_test.go --- old/terragrunt-0.45.16/configstack/module_test.go 2023-05-24 21:08:10.000000000 +0200 +++ new/terragrunt-0.45.17/configstack/module_test.go 2023-05-30 13:50:03.000000000 +0200 @@ -3,6 +3,7 @@ import ( "bytes" "os" + "path/filepath" "strings" "testing" @@ -23,7 +24,7 @@ configPaths := []string{} expected := []*TerraformModule{} - actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, mockHowThesePathsWereFound) + actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, nil, mockHowThesePathsWereFound) assert.Nil(t, actualErr, "Unexpected error: %v", actualErr) assertModuleListsEqual(t, expected, actualModules) } @@ -41,7 +42,7 @@ configPaths := []string{"../test/fixture-modules/module-a/" + config.DefaultTerragruntConfigPath} expected := []*TerraformModule{moduleA} - actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, mockHowThesePathsWereFound) + actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, nil, mockHowThesePathsWereFound) assert.Nil(t, actualErr, "Unexpected error: %v", actualErr) assertModuleListsEqual(t, expected, actualModules) } @@ -59,7 +60,7 @@ configPaths := []string{"../test/fixture-modules/json-module-a/" + config.DefaultTerragruntJsonConfigPath} expected := []*TerraformModule{moduleA} - actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, mockHowThesePathsWereFound) + actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, nil, mockHowThesePathsWereFound) assert.Nil(t, actualErr, "Unexpected error: %v", actualErr) assertModuleListsEqual(t, expected, actualModules) } @@ -83,7 +84,81 @@ configPaths := []string{"../test/fixture-modules/module-b/module-b-child/" + config.DefaultTerragruntConfigPath} expected := []*TerraformModule{moduleB} - actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, mockHowThesePathsWereFound) + actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, nil, mockHowThesePathsWereFound) + assert.Nil(t, actualErr, "Unexpected error: %v", actualErr) + assertModuleListsEqual(t, expected, actualModules) +} + +func TestResolveTerraformModulesReadConfigFromParentConfig(t *testing.T) { + t.Parallel() + + childDir := "../test/fixture-modules/module-m/module-m-child" + childConfigPath := filepath.Join(childDir, config.DefaultTerragruntConfigPath) + + parentDir := "../test/fixture-modules/module-m" + parentCofnigPath := filepath.Join(parentDir, config.DefaultTerragruntConfigPath) + + localsConfigPaths := map[string]string{ + "env_vars": "../test/fixture-modules/module-m/env.hcl", + "tier_vars": "../test/fixture-modules/module-m/module-m-child/tier.hcl", + } + + localsConfigs := make(map[string]interface{}) + + for name, configPath := range localsConfigPaths { + opts, err := options.NewTerragruntOptions(configPath) + assert.Nil(t, err) + + cfg, err := config.PartialParseConfigFile(configPath, opts, nil, nil) + assert.Nil(t, err) + + localsConfigs[name] = map[string]interface{}{ + "dependencies": interface{}(nil), + "download_dir": "", + "generate": map[string]interface{}{}, + "iam_assume_role_duration": interface{}(nil), + "iam_assume_role_session_name": "", + "iam_role": "", + "inputs": interface{}(nil), + "locals": cfg.Locals, + "retry_max_attempts": interface{}(nil), + "retry_sleep_interval_sec": interface{}(nil), + "retryable_errors": interface{}(nil), + "skip": false, + "terraform_binary": "", + "terraform_version_constraint": "", + "terragrunt_version_constraint": "", + } + } + + moduleM := &TerraformModule{ + Path: canonical(t, childDir), + Dependencies: []*TerraformModule{}, + Config: config.TerragruntConfig{ + Terraform: &config.TerraformConfig{Source: ptr("...")}, + IsPartial: true, + ProcessedIncludes: map[string]config.IncludeConfig{ + "": {Path: canonical(t, "../test/fixture-modules/module-m/terragrunt.hcl")}, + }, + Locals: localsConfigs, + }, + TerragruntOptions: mockOptions.Clone(canonical(t, childConfigPath)), + } + + configPaths := []string{childConfigPath} + childTerragruntConfig := &config.TerragruntConfig{ + ProcessedIncludes: map[string]config.IncludeConfig{ + "": { + Path: parentCofnigPath, + }, + }, + } + expected := []*TerraformModule{moduleM} + + mockOptions, _ := options.NewTerragruntOptionsForTest("running_module_test") + mockOptions.OriginalTerragruntConfigPath = childConfigPath + + actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, childTerragruntConfig, mockHowThesePathsWereFound) assert.Nil(t, actualErr, "Unexpected error: %v", actualErr) assertModuleListsEqual(t, expected, actualModules) } @@ -107,7 +182,7 @@ configPaths := []string{"../test/fixture-modules/json-module-b/module-b-child/" + config.DefaultTerragruntJsonConfigPath} expected := []*TerraformModule{moduleB} - actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, mockHowThesePathsWereFound) + actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, nil, mockHowThesePathsWereFound) assert.Nil(t, actualErr, "Unexpected error: %v", actualErr) assertModuleListsEqual(t, expected, actualModules) } @@ -131,7 +206,7 @@ configPaths := []string{"../test/fixture-modules/hcl-module-b/module-b-child/" + config.DefaultTerragruntConfigPath} expected := []*TerraformModule{moduleB} - actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, mockHowThesePathsWereFound) + actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, nil, mockHowThesePathsWereFound) assert.Nil(t, actualErr, "Unexpected error: %v", actualErr) assertModuleListsEqual(t, expected, actualModules) } @@ -163,7 +238,7 @@ configPaths := []string{"../test/fixture-modules/module-a/" + config.DefaultTerragruntConfigPath, "../test/fixture-modules/module-c/" + config.DefaultTerragruntConfigPath} expected := []*TerraformModule{moduleA, moduleC} - actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, mockHowThesePathsWereFound) + actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, nil, mockHowThesePathsWereFound) assert.Nil(t, actualErr, "Unexpected error: %v", actualErr) assertModuleListsEqual(t, expected, actualModules) } @@ -195,7 +270,7 @@ configPaths := []string{"../test/fixture-modules/module-a/" + config.DefaultTerragruntConfigPath, "../test/fixture-modules/json-module-c/" + config.DefaultTerragruntJsonConfigPath} expected := []*TerraformModule{moduleA, moduleC} - actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, mockHowThesePathsWereFound) + actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, nil, mockHowThesePathsWereFound) assert.Nil(t, actualErr, "Unexpected error: %v", actualErr) assertModuleListsEqual(t, expected, actualModules) } @@ -227,7 +302,7 @@ configPaths := []string{"../test/fixture-modules/json-module-a/" + config.DefaultTerragruntJsonConfigPath, "../test/fixture-modules/hcl-module-c/" + config.DefaultTerragruntConfigPath} expected := []*TerraformModule{moduleA, moduleC} - actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, mockHowThesePathsWereFound) + actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, nil, mockHowThesePathsWereFound) assert.Nil(t, actualErr, "Unexpected error: %v", actualErr) assertModuleListsEqual(t, expected, actualModules) } @@ -261,7 +336,7 @@ configPaths := []string{"../test/fixture-modules/module-a/" + config.DefaultTerragruntConfigPath, "../test/fixture-modules/module-c/" + config.DefaultTerragruntConfigPath} - actualModules, actualErr := ResolveTerraformModules(configPaths, opts, mockHowThesePathsWereFound) + actualModules, actualErr := ResolveTerraformModules(configPaths, opts, nil, mockHowThesePathsWereFound) // construct the expected list moduleA.FlagExcluded = true @@ -311,7 +386,7 @@ configPaths := []string{"../test/fixture-modules/module-a/" + config.DefaultTerragruntConfigPath, "../test/fixture-modules/module-c/" + config.DefaultTerragruntConfigPath, "../test/fixture-modules/module-abba/" + config.DefaultTerragruntConfigPath} - actualModules, actualErr := ResolveTerraformModules(configPaths, opts, mockHowThesePathsWereFound) + actualModules, actualErr := ResolveTerraformModules(configPaths, opts, nil, mockHowThesePathsWereFound) // construct the expected list moduleA.FlagExcluded = true @@ -361,7 +436,7 @@ configPaths := []string{"../test/fixture-modules/module-a/" + config.DefaultTerragruntConfigPath, "../test/fixture-modules/module-c/" + config.DefaultTerragruntConfigPath, "../test/fixture-modules/module-abba/" + config.DefaultTerragruntConfigPath} - actualModules, actualErr := ResolveTerraformModules(configPaths, opts, mockHowThesePathsWereFound) + actualModules, actualErr := ResolveTerraformModules(configPaths, opts, nil, mockHowThesePathsWereFound) // construct the expected list moduleA.FlagExcluded = true @@ -401,7 +476,7 @@ configPaths := []string{"../test/fixture-modules/module-a/" + config.DefaultTerragruntConfigPath, "../test/fixture-modules/module-c/" + config.DefaultTerragruntConfigPath} - actualModules, actualErr := ResolveTerraformModules(configPaths, opts, mockHowThesePathsWereFound) + actualModules, actualErr := ResolveTerraformModules(configPaths, opts, nil, mockHowThesePathsWereFound) // construct the expected list moduleC.FlagExcluded = true @@ -440,7 +515,7 @@ configPaths := []string{"../test/fixture-modules/module-a/" + config.DefaultTerragruntConfigPath, "../test/fixture-modules/module-c/" + config.DefaultTerragruntConfigPath} - actualModules, actualErr := ResolveTerraformModules(configPaths, opts, mockHowThesePathsWereFound) + actualModules, actualErr := ResolveTerraformModules(configPaths, opts, nil, mockHowThesePathsWereFound) // construct the expected list moduleA.FlagExcluded = false @@ -479,7 +554,7 @@ configPaths := []string{"../test/fixture-modules/module-a/" + config.DefaultTerragruntConfigPath, "../test/fixture-modules/module-c/" + config.DefaultTerragruntConfigPath} - actualModules, actualErr := ResolveTerraformModules(configPaths, opts, mockHowThesePathsWereFound) + actualModules, actualErr := ResolveTerraformModules(configPaths, opts, nil, mockHowThesePathsWereFound) // construct the expected list moduleC.FlagExcluded = true @@ -527,7 +602,7 @@ configPaths := []string{"../test/fixture-modules/module-a/" + config.DefaultTerragruntConfigPath, "../test/fixture-modules/module-c/" + config.DefaultTerragruntConfigPath, "../test/fixture-modules/module-f/" + config.DefaultTerragruntConfigPath} - actualModules, actualErr := ResolveTerraformModules(configPaths, opts, mockHowThesePathsWereFound) + actualModules, actualErr := ResolveTerraformModules(configPaths, opts, nil, mockHowThesePathsWereFound) // construct the expected list moduleF.FlagExcluded = true @@ -584,7 +659,7 @@ configPaths := []string{"../test/fixture-modules/module-a/" + config.DefaultTerragruntConfigPath, "../test/fixture-modules/module-b/module-b-child/" + config.DefaultTerragruntConfigPath, "../test/fixture-modules/module-c/" + config.DefaultTerragruntConfigPath, "../test/fixture-modules/module-d/" + config.DefaultTerragruntConfigPath} expected := []*TerraformModule{moduleA, moduleB, moduleC, moduleD} - actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, mockHowThesePathsWereFound) + actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, nil, mockHowThesePathsWereFound) assert.Nil(t, actualErr, "Unexpected error: %v", actualErr) assertModuleListsEqual(t, expected, actualModules) } @@ -636,7 +711,7 @@ configPaths := []string{"../test/fixture-modules/module-a/" + config.DefaultTerragruntConfigPath, "../test/fixture-modules/json-module-b/module-b-child/" + config.DefaultTerragruntJsonConfigPath, "../test/fixture-modules/module-c/" + config.DefaultTerragruntConfigPath, "../test/fixture-modules/json-module-d/" + config.DefaultTerragruntJsonConfigPath} expected := []*TerraformModule{moduleA, moduleB, moduleC, moduleD} - actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, mockHowThesePathsWereFound) + actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, nil, mockHowThesePathsWereFound) assert.Nil(t, actualErr, "Unexpected error: %v", actualErr) assertModuleListsEqual(t, expected, actualModules) } @@ -681,7 +756,7 @@ configPaths := []string{"../test/fixture-modules/module-a/" + config.DefaultTerragruntConfigPath, "../test/fixture-modules/module-b/module-b-child/" + config.DefaultTerragruntConfigPath, "../test/fixture-modules/module-e/module-e-child/" + config.DefaultTerragruntConfigPath} expected := []*TerraformModule{moduleA, moduleB, moduleE} - actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, mockHowThesePathsWereFound) + actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, nil, mockHowThesePathsWereFound) assert.Nil(t, actualErr, "Unexpected error: %v", actualErr) assertModuleListsEqual(t, expected, actualModules) } @@ -711,7 +786,7 @@ configPaths := []string{"../test/fixture-modules/module-g/" + config.DefaultTerragruntConfigPath} expected := []*TerraformModule{moduleF, moduleG} - actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, mockHowThesePathsWereFound) + actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, nil, mockHowThesePathsWereFound) assert.Nil(t, actualErr, "Unexpected error: %v", actualErr) assertModuleListsEqual(t, expected, actualModules) } @@ -763,7 +838,7 @@ configPaths := []string{"../test/fixture-modules/module-j/" + config.DefaultTerragruntConfigPath, "../test/fixture-modules/module-k/" + config.DefaultTerragruntConfigPath} expected := []*TerraformModule{moduleH, moduleI, moduleJ, moduleK} - actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, mockHowThesePathsWereFound) + actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, nil, mockHowThesePathsWereFound) require.NoError(t, actualErr) assertModuleListsEqual(t, expected, actualModules) } @@ -773,7 +848,7 @@ configPaths := []string{"../test/fixture-modules/module-missing-dependency/" + config.DefaultTerragruntConfigPath} - _, actualErr := ResolveTerraformModules(configPaths, mockOptions, mockHowThesePathsWereFound) + _, actualErr := ResolveTerraformModules(configPaths, mockOptions, nil, mockHowThesePathsWereFound) require.Error(t, actualErr) underlying, ok := errors.Unwrap(actualErr).(ErrorProcessingModule) @@ -789,7 +864,7 @@ configPaths := []string{"../test/fixture-modules/module-l/" + config.DefaultTerragruntConfigPath} expected := []*TerraformModule{} - actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, mockHowThesePathsWereFound) + actualModules, actualErr := ResolveTerraformModules(configPaths, mockOptions, nil, mockHowThesePathsWereFound) assert.Nil(t, actualErr, "Unexpected error: %v", actualErr) assertModuleListsEqual(t, expected, actualModules) } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.45.16/configstack/stack.go new/terragrunt-0.45.17/configstack/stack.go --- old/terragrunt-0.45.16/configstack/stack.go 2023-05-24 21:08:10.000000000 +0200 +++ new/terragrunt-0.45.17/configstack/stack.go 2023-05-30 13:50:03.000000000 +0200 @@ -139,14 +139,14 @@ // Find all the Terraform modules in the subfolders of the working directory of the given TerragruntOptions and // assemble them into a Stack object that can be applied or destroyed in a single command -func FindStackInSubfolders(terragruntOptions *options.TerragruntOptions) (*Stack, error) { +func FindStackInSubfolders(terragruntOptions *options.TerragruntOptions, childTerragruntConfig *config.TerragruntConfig) (*Stack, error) { terragruntConfigFiles, err := config.FindConfigFilesInPath(terragruntOptions.WorkingDir, terragruntOptions) if err != nil { return nil, err } howThesePathsWereFound := fmt.Sprintf("Terragrunt config file found in a subdirectory of %s", terragruntOptions.WorkingDir) - return createStackForTerragruntConfigPaths(terragruntOptions.WorkingDir, terragruntConfigFiles, terragruntOptions, howThesePathsWereFound) + return createStackForTerragruntConfigPaths(terragruntOptions.WorkingDir, terragruntConfigFiles, terragruntOptions, childTerragruntConfig, howThesePathsWereFound) } // Sync the TerraformCliArgs for each module in the stack to match the provided terragruntOptions struct. @@ -233,12 +233,12 @@ // Find all the Terraform modules in the folders that contain the given Terragrunt config files and assemble those // modules into a Stack object that can be applied or destroyed in a single command -func createStackForTerragruntConfigPaths(path string, terragruntConfigPaths []string, terragruntOptions *options.TerragruntOptions, howThesePathsWereFound string) (*Stack, error) { +func createStackForTerragruntConfigPaths(path string, terragruntConfigPaths []string, terragruntOptions *options.TerragruntOptions, childTerragruntConfig *config.TerragruntConfig, howThesePathsWereFound string) (*Stack, error) { if len(terragruntConfigPaths) == 0 { return nil, errors.WithStackTrace(NoTerraformModulesFound) } - modules, err := ResolveTerraformModules(terragruntConfigPaths, terragruntOptions, howThesePathsWereFound) + modules, err := ResolveTerraformModules(terragruntConfigPaths, terragruntOptions, childTerragruntConfig, howThesePathsWereFound) if err != nil { return nil, err } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.45.16/configstack/stack_test.go new/terragrunt-0.45.17/configstack/stack_test.go --- old/terragrunt-0.45.16/configstack/stack_test.go 2023-05-24 21:08:10.000000000 +0200 +++ new/terragrunt-0.45.17/configstack/stack_test.go 2023-05-30 13:50:03.000000000 +0200 @@ -36,7 +36,7 @@ terragruntOptions.WorkingDir = envFolder - stack, err := FindStackInSubfolders(terragruntOptions) + stack, err := FindStackInSubfolders(terragruntOptions, nil) require.NoError(t, err) var modulePaths []string diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.45.16/test/fixture-get-path/fixture-path_relative_from_include/lives/dev/base/terragrunt.hcl new/terragrunt-0.45.17/test/fixture-get-path/fixture-path_relative_from_include/lives/dev/base/terragrunt.hcl --- old/terragrunt-0.45.16/test/fixture-get-path/fixture-path_relative_from_include/lives/dev/base/terragrunt.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.45.17/test/fixture-get-path/fixture-path_relative_from_include/lives/dev/base/terragrunt.hcl 2023-05-30 13:50:03.000000000 +0200 @@ -0,0 +1,7 @@ +terraform { + source = "../../../modules//base" +} + +include { + path = find_in_parent_folders() +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.45.16/test/fixture-get-path/fixture-path_relative_from_include/lives/dev/base/tier.hcl new/terragrunt-0.45.17/test/fixture-get-path/fixture-path_relative_from_include/lives/dev/base/tier.hcl --- old/terragrunt-0.45.16/test/fixture-get-path/fixture-path_relative_from_include/lives/dev/base/tier.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.45.17/test/fixture-get-path/fixture-path_relative_from_include/lives/dev/base/tier.hcl 2023-05-30 13:50:03.000000000 +0200 @@ -0,0 +1,3 @@ +locals { + tier = "base" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.45.16/test/fixture-get-path/fixture-path_relative_from_include/lives/dev/cluster/terragrunt.hcl new/terragrunt-0.45.17/test/fixture-get-path/fixture-path_relative_from_include/lives/dev/cluster/terragrunt.hcl --- old/terragrunt-0.45.16/test/fixture-get-path/fixture-path_relative_from_include/lives/dev/cluster/terragrunt.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.45.17/test/fixture-get-path/fixture-path_relative_from_include/lives/dev/cluster/terragrunt.hcl 2023-05-30 13:50:03.000000000 +0200 @@ -0,0 +1,15 @@ +terraform { + source = "../../../modules//cluster" +} + +include { + path = find_in_parent_folders() +} + +dependency "base" { + config_path = "../base" +} + +inputs = { + some_input = dependency.base.outputs.some_output +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.45.16/test/fixture-get-path/fixture-path_relative_from_include/lives/dev/cluster/tier.hcl new/terragrunt-0.45.17/test/fixture-get-path/fixture-path_relative_from_include/lives/dev/cluster/tier.hcl --- old/terragrunt-0.45.16/test/fixture-get-path/fixture-path_relative_from_include/lives/dev/cluster/tier.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.45.17/test/fixture-get-path/fixture-path_relative_from_include/lives/dev/cluster/tier.hcl 2023-05-30 13:50:03.000000000 +0200 @@ -0,0 +1,3 @@ +locals { + tier = "cluster" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.45.16/test/fixture-get-path/fixture-path_relative_from_include/lives/dev/env.hcl new/terragrunt-0.45.17/test/fixture-get-path/fixture-path_relative_from_include/lives/dev/env.hcl --- old/terragrunt-0.45.16/test/fixture-get-path/fixture-path_relative_from_include/lives/dev/env.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.45.17/test/fixture-get-path/fixture-path_relative_from_include/lives/dev/env.hcl 2023-05-30 13:50:03.000000000 +0200 @@ -0,0 +1,3 @@ +locals { + environment = "dev" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.45.16/test/fixture-get-path/fixture-path_relative_from_include/lives/org.hcl new/terragrunt-0.45.17/test/fixture-get-path/fixture-path_relative_from_include/lives/org.hcl --- old/terragrunt-0.45.16/test/fixture-get-path/fixture-path_relative_from_include/lives/org.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.45.17/test/fixture-get-path/fixture-path_relative_from_include/lives/org.hcl 2023-05-30 13:50:03.000000000 +0200 @@ -0,0 +1,3 @@ +locals { + organization_unit = "test" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.45.16/test/fixture-get-path/fixture-path_relative_from_include/lives/terragrunt.hcl new/terragrunt-0.45.17/test/fixture-get-path/fixture-path_relative_from_include/lives/terragrunt.hcl --- old/terragrunt-0.45.16/test/fixture-get-path/fixture-path_relative_from_include/lives/terragrunt.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.45.17/test/fixture-get-path/fixture-path_relative_from_include/lives/terragrunt.hcl 2023-05-30 13:50:03.000000000 +0200 @@ -0,0 +1,27 @@ +locals { + org_vars = read_terragrunt_config("${get_parent_terragrunt_dir()}/org.hcl") + env_vars = read_terragrunt_config("${get_parent_terragrunt_dir()}/dev/env.hcl") + tier_vars = read_terragrunt_config("tier.hcl") + + organization_unit = local.org_vars.locals.organization_unit + environment = local.env_vars.locals.environment + tier = local.tier_vars.locals.tier +} + +generate "provider" { + path = "terraform.tf" + if_exists = "overwrite_terragrunt" + contents = <<-EOF + terraform { + backend "local" { + path = "${local.environment}-${local.tier}.state" + } + } + EOF +} + +inputs = merge( + local.org_vars.locals, + local.env_vars.locals, + local.tier_vars.locals, + ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.45.16/test/fixture-get-path/fixture-path_relative_from_include/modules/base/main.tf new/terragrunt-0.45.17/test/fixture-get-path/fixture-path_relative_from_include/modules/base/main.tf --- old/terragrunt-0.45.16/test/fixture-get-path/fixture-path_relative_from_include/modules/base/main.tf 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.45.17/test/fixture-get-path/fixture-path_relative_from_include/modules/base/main.tf 2023-05-30 13:50:03.000000000 +0200 @@ -0,0 +1,3 @@ +output "some_output" { + value = "something" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.45.16/test/fixture-get-path/fixture-path_relative_from_include/modules/cluster/main.tf new/terragrunt-0.45.17/test/fixture-get-path/fixture-path_relative_from_include/modules/cluster/main.tf --- old/terragrunt-0.45.16/test/fixture-get-path/fixture-path_relative_from_include/modules/cluster/main.tf 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.45.17/test/fixture-get-path/fixture-path_relative_from_include/modules/cluster/main.tf 2023-05-30 13:50:03.000000000 +0200 @@ -0,0 +1,5 @@ +variable "some_input" {} + +output "some_output" { + value = "${var.some_input} else" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.45.16/test/fixture-modules/module-m/env.hcl new/terragrunt-0.45.17/test/fixture-modules/module-m/env.hcl --- old/terragrunt-0.45.16/test/fixture-modules/module-m/env.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.45.17/test/fixture-modules/module-m/env.hcl 2023-05-30 13:50:03.000000000 +0200 @@ -0,0 +1,3 @@ +locals { + environment = "dev" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.45.16/test/fixture-modules/module-m/module-m-child/terragrunt.hcl new/terragrunt-0.45.17/test/fixture-modules/module-m/module-m-child/terragrunt.hcl --- old/terragrunt-0.45.16/test/fixture-modules/module-m/module-m-child/terragrunt.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.45.17/test/fixture-modules/module-m/module-m-child/terragrunt.hcl 2023-05-30 13:50:03.000000000 +0200 @@ -0,0 +1,3 @@ +include { + path = find_in_parent_folders() +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.45.16/test/fixture-modules/module-m/module-m-child/tier.hcl new/terragrunt-0.45.17/test/fixture-modules/module-m/module-m-child/tier.hcl --- old/terragrunt-0.45.16/test/fixture-modules/module-m/module-m-child/tier.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.45.17/test/fixture-modules/module-m/module-m-child/tier.hcl 2023-05-30 13:50:03.000000000 +0200 @@ -0,0 +1,3 @@ +locals { + tier = "base" +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.45.16/test/fixture-modules/module-m/terragrunt.hcl new/terragrunt-0.45.17/test/fixture-modules/module-m/terragrunt.hcl --- old/terragrunt-0.45.16/test/fixture-modules/module-m/terragrunt.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.45.17/test/fixture-modules/module-m/terragrunt.hcl 2023-05-30 13:50:03.000000000 +0200 @@ -0,0 +1,15 @@ +# Configure Terragrunt to automatically store tfstate files in an S3 bucket +remote_state { + backend = "s3" + config = { + bucket = "bucket" + key = "${path_relative_to_include()}/terraform.tfstate" + } +} +terraform { + source = "..." +} +locals { + env_vars = read_terragrunt_config("${get_parent_terragrunt_dir()}/env.hcl") + tier_vars = read_terragrunt_config("tier.hcl") +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.45.16/test/integration_test.go new/terragrunt-0.45.17/test/integration_test.go --- old/terragrunt-0.45.16/test/integration_test.go 2023-05-24 21:08:10.000000000 +0200 +++ new/terragrunt-0.45.17/test/integration_test.go 2023-05-30 13:50:03.000000000 +0200 @@ -115,6 +115,7 @@ TEST_FIXTURE_RELATIVE_INCLUDE_CMD = "fixture-relative-include-cmd" TEST_FIXTURE_AWS_GET_CALLER_IDENTITY = "fixture-get-aws-caller-identity" TEST_FIXTURE_GET_REPO_ROOT = "fixture-get-repo-root" + TEST_FIXTURE_PATH_RELATIVE_FROM_INCLUDE = "fixture-get-path/fixture-path_relative_from_include" TEST_FIXTURE_GET_PATH_FROM_REPO_ROOT = "fixture-get-path/fixture-get-path-from-repo-root" TEST_FIXTURE_GET_PATH_TO_REPO_ROOT = "fixture-get-path/fixture-get-path-to-repo-root" TEST_FIXTURE_GET_PLATFORM = "fixture-get-platform" @@ -2946,6 +2947,46 @@ require.Regexp(t, "/tmp/terragrunt-.*/fixture-get-repo-root", repoRoot.Value) } +func TestPathRelativeFromInclude(t *testing.T) { + t.Parallel() + + cleanupTerraformFolder(t, TEST_FIXTURE_PATH_RELATIVE_FROM_INCLUDE) + tmpEnvPath, _ := filepath.EvalSymlinks(copyEnvironment(t, TEST_FIXTURE_PATH_RELATIVE_FROM_INCLUDE)) + rootPath := util.JoinPath(tmpEnvPath, TEST_FIXTURE_PATH_RELATIVE_FROM_INCLUDE, "lives/dev") + basePath := util.JoinPath(rootPath, "base") + clusterPath := util.JoinPath(rootPath, "cluster") + + output, err := exec.Command("git", "init", tmpEnvPath).CombinedOutput() + if err != nil { + t.Fatalf("Error initializing git repo: %v\n%s", err, string(output)) + } + + runTerragrunt(t, fmt.Sprintf("terragrunt run-all apply -auto-approve --terragrunt-non-interactive --terragrunt-working-dir %s", rootPath)) + + // verify expected outputs are not empty + stdout := bytes.Buffer{} + stderr := bytes.Buffer{} + + err = runTerragruntCommand(t, fmt.Sprintf("terragrunt output -no-color -json --terragrunt-non-interactive --terragrunt-working-dir %s", clusterPath), &stdout, &stderr) + assert.NoError(t, err) + + outputs := map[string]TerraformOutput{} + require.NoError(t, json.Unmarshal([]byte(stdout.String()), &outputs)) + + val, hasVal := outputs["some_output"] + require.True(t, hasVal) + require.Equal(t, "something else", val.Value) + + // try to destroy module and check if warning is printed in output, also test `get_parent_terragrunt_dir()` func in the parent terragrunt config. + stdout = bytes.Buffer{} + stderr = bytes.Buffer{} + + err = runTerragruntCommand(t, fmt.Sprintf("terragrunt destroy -auto-approve --terragrunt-non-interactive --terragrunt-working-dir %s", basePath), &stdout, &stderr) + assert.NoError(t, err) + + assert.Contains(t, stderr.String(), fmt.Sprintf("Detected dependent modules:\n%s", clusterPath)) +} + func TestGetPathFromRepoRoot(t *testing.T) { t.Parallel() ++++++ terragrunt.obsinfo ++++++ --- /var/tmp/diff_new_pack.TaWqSF/_old 2023-05-31 21:54:34.789034608 +0200 +++ /var/tmp/diff_new_pack.TaWqSF/_new 2023-05-31 21:54:34.789034608 +0200 @@ -1,5 +1,5 @@ name: terragrunt -version: 0.45.16 -mtime: 1684955290 -commit: e5b394060e8eb5009b99d15195e64688614a768f +version: 0.45.17 +mtime: 1685447403 +commit: 9154ad0ff23e876c9e2bfe0ad7948e179c2bbdae ++++++ vendor.tar.gz ++++++ /work/SRC/openSUSE:Factory/terragrunt/vendor.tar.gz /work/SRC/openSUSE:Factory/.terragrunt.new.1533/vendor.tar.gz differ: char 5, line 1