commit terragrunt for openSUSE:Factory
Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package terragrunt for openSUSE:Factory checked in at 2022-09-30 17:58:22 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/terragrunt (Old) and /work/SRC/openSUSE:Factory/.terragrunt.new.2275 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "terragrunt" Fri Sep 30 17:58:22 2022 rev:14 rq:1007141 version:0.39.0 Changes: -------- --- /work/SRC/openSUSE:Factory/terragrunt/terragrunt.changes 2022-09-15 23:00:13.961391958 +0200 +++ /work/SRC/openSUSE:Factory/.terragrunt.new.2275/terragrunt.changes 2022-09-30 17:58:39.977360434 +0200 @@ -1,0 +2,7 @@ +Fri Sep 30 05:12:17 UTC 2022 - kastl@b1-systems.de + +- Update to version 0.39.0: + * #2259 Improve handling of failures in outputs reading (#2288) + * Docs: update to mention run-all commands not xxx-all (#2266) + +------------------------------------------------------------------- Old: ---- terragrunt-0.38.12.tar.gz New: ---- terragrunt-0.39.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ terragrunt.spec ++++++ --- /var/tmp/diff_new_pack.Y26cZr/_old 2022-09-30 17:58:40.741362067 +0200 +++ /var/tmp/diff_new_pack.Y26cZr/_new 2022-09-30 17:58:40.745362075 +0200 @@ -19,7 +19,7 @@ %define __arch_install_post export NO_BRP_STRIP_DEBUG=true Name: terragrunt -Version: 0.38.12 +Version: 0.39.0 Release: 0 Summary: Thin wrapper for Terraform for working with multiple Terraform modules License: MIT ++++++ _service ++++++ --- /var/tmp/diff_new_pack.Y26cZr/_old 2022-09-30 17:58:40.773362135 +0200 +++ /var/tmp/diff_new_pack.Y26cZr/_new 2022-09-30 17:58:40.777362143 +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.38.12</param> + <param name="revision">v0.39.0</param> <param name="versionformat">@PARENT_TAG@</param> <param name="changesgenerate">enable</param> <param name="versionrewrite-pattern">v(.*)</param> @@ -16,7 +16,7 @@ <param name="compression">gz</param> </service> <service name="go_modules" mode="disabled"> - <param name="archive">terragrunt-0.38.12.tar.gz</param> + <param name="archive">terragrunt-0.39.0.tar.gz</param> </service> </services> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.Y26cZr/_old 2022-09-30 17:58:40.793362178 +0200 +++ /var/tmp/diff_new_pack.Y26cZr/_new 2022-09-30 17:58:40.793362178 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/gruntwork-io/terragrunt</param> - <param name="changesrevision">3a23346e08ee574a4a3a23112350ea625d577a02</param></service></servicedata> + <param name="changesrevision">b93f6ef963edc8aa5a3927c2727494244ba5e7fa</param></service></servicedata> (No newline at EOF) ++++++ terragrunt-0.38.12.tar.gz -> terragrunt-0.39.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.38.12/config/dependency.go new/terragrunt-0.39.0/config/dependency.go --- old/terragrunt-0.38.12/config/dependency.go 2022-09-14 22:06:21.000000000 +0200 +++ new/terragrunt-0.39.0/config/dependency.go 2022-09-29 16:59:03.000000000 +0200 @@ -31,6 +31,8 @@ "github.com/gruntwork-io/terragrunt/util" ) +const renderJsonCommand = "render-json" + type Dependency struct { Name string `hcl:",label" cty:"name"` ConfigPath string `hcl:"config_path,attr" cty:"config_path"` @@ -379,7 +381,7 @@ dependencyConfig.MockOutputsAllowedTerraformCommands == nil || len(*dependencyConfig.MockOutputsAllowedTerraformCommands) == 0 || util.ListContainsElement(*dependencyConfig.MockOutputsAllowedTerraformCommands, terragruntOptions.OriginalTerraformCommand) - return defaultOutputsSet && allowedCommand + return defaultOutputsSet && allowedCommand || isRenderJsonCommand(terragruntOptions) } // Return the output from the state of another module, managed by terragrunt. This function will parse the provided @@ -395,7 +397,14 @@ jsonBytes, err := getOutputJsonWithCaching(targetConfig, terragruntOptions) if err != nil { - return nil, true, err + if !isRenderJsonCommand(terragruntOptions) { + return nil, true, err + } + terragruntOptions.Logger.Warnf("Failed to read outputs from %s referenced in %s as %s, fallback to mock outputs. Error: %v", targetConfig, terragruntOptions.TerragruntConfigPath, dependencyConfig.Name, err) + jsonBytes, err = json.Marshal(dependencyConfig.MockOutputs) + if err != nil { + return nil, true, err + } } isEmpty := string(jsonBytes) == "{}" @@ -412,6 +421,11 @@ return &convertedOutput, isEmpty, errors.WithStackTrace(err) } +// This function will true if terragrunt was invoked with renderJsonCommand +func isRenderJsonCommand(terragruntOptions *options.TerragruntOptions) bool { + return util.ListContainsElement(terragruntOptions.TerraformCliArgs, renderJsonCommand) +} + // getOutputJsonWithCaching will run terragrunt output on the target config if it is not already cached. func getOutputJsonWithCaching(targetConfig string, terragruntOptions *options.TerragruntOptions) ([]byte, error) { // Acquire synchronization lock to ensure only one instance of output is called per config. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.38.12/configstack/stack.go new/terragrunt-0.39.0/configstack/stack.go --- old/terragrunt-0.38.12/configstack/stack.go 2022-09-14 22:06:21.000000000 +0200 +++ new/terragrunt-0.39.0/configstack/stack.go 2022-09-29 16:59:03.000000000 +0200 @@ -123,7 +123,7 @@ dependenciesMsg = fmt.Sprintf(" contains dependencies to %v and", stack.Modules[i].Config.Dependencies.Paths) } terragruntOptions.Logger.Infof("%v%v refers to remote state "+ - "you may have to apply your changes in the dependencies prior running terragrunt plan-all.\n", + "you may have to apply your changes in the dependencies prior running terragrunt run-all plan.\n", stack.Modules[i].Path, dependenciesMsg, ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.38.12/docs/_docs/02_features/execute-terraform-commands-on-multiple-modules-at-once.md new/terragrunt-0.39.0/docs/_docs/02_features/execute-terraform-commands-on-multiple-modules-at-once.md --- old/terragrunt-0.38.12/docs/_docs/02_features/execute-terraform-commands-on-multiple-modules-at-once.md 2022-09-14 22:06:21.000000000 +0200 +++ new/terragrunt-0.39.0/docs/_docs/02_features/execute-terraform-commands-on-multiple-modules-at-once.md 2022-09-29 16:59:03.000000000 +0200 @@ -86,7 +86,7 @@ Note: It is important to realize that you could get errors running `run-all plan` if you have dependencies between your projects and some of those dependencies haven���t been applied yet. -*Ex: If module A depends on module B and module B hasn���t been applied yet, then plan-all will show the plan for B, but exit with an error when trying to show the plan for A.* +*Ex: If module A depends on module B and module B hasn���t been applied yet, then run-all plan will show the plan for B, but exit with an error when trying to show the plan for A.* cd root terragrunt run-all plan @@ -160,11 +160,11 @@ Terragrunt will return an error indicating the dependency hasn���t been applied yet if the terraform module managed by the terragrunt config referenced in a `dependency` block has not been applied yet. This is because you cannot actually fetch outputs out of an unapplied Terraform module, even if there are no resources being created in the module. -This is most problematic when running commands that do not modify state (e.g `plan-all` and `validate-all`) on a completely new setup where no infrastructure has been deployed. You won���t be able to `plan` or `validate` a module if you can���t determine the `inputs`. If the module depends on the outputs of another module that hasn���t been applied yet, you won���t be able to compute the `inputs` unless the dependencies are all applied. However, in real life usage, you would want to run `validate-all` or `plan-all` on a completely new set of infrastructure. +This is most problematic when running commands that do not modify state (e.g `run-all plan` and `run-all validate`) on a completely new setup where no infrastructure has been deployed. You won���t be able to `plan` or `validate` a module if you can���t determine the `inputs`. If the module depends on the outputs of another module that hasn���t been applied yet, you won���t be able to compute the `inputs` unless the dependencies are all applied. However, in real life usage, you would want to run `run-all validate` or `run-all plan` on a completely new set of infrastructure. To address this, you can provide mock outputs to use when a module hasn���t been applied yet. This is configured using the `mock_outputs` attribute on the `dependency` block and it corresponds to a map that will be injected in place of the actual dependency outputs if the target config hasn���t been applied yet. -For example, in the previous example with a `mysql` module and `vpc` module, suppose you wanted to place in a temporary, dummy value for the `vpc_id` during a `validate-all` for the `mysql` module. You can specify in `mysql/terragrunt.hcl`: +For example, in the previous example with a `mysql` module and `vpc` module, suppose you wanted to place in a temporary, dummy value for the `vpc_id` during a `run-all validate` for the `mysql` module. You can specify in `mysql/terragrunt.hcl`: dependency "vpc" { config_path = "../vpc" @@ -197,7 +197,7 @@ vpc_id = dependency.vpc.outputs.vpc_id } -Note that indicating `validate` means that the `mock_outputs` will be used either with `validate` or with `validate-all`. +Note that indicating `validate` means that the `mock_outputs` will be used either with `validate` or with `run-all validate`. You can also use `skip_outputs` on the `dependency` block to specify the dependency without pulling in the outputs: @@ -292,7 +292,7 @@ If any of the modules fail to deploy, then Terragrunt will not attempt to deploy the modules that depend on them. Once you���ve fixed the error, it���s usually safe to re-run the `run-all apply` or `run-all destroy` command again, since it���ll be a no-op for the modules that already deployed successfully, and should only affect the ones that had an error the last time around. -To check all of your dependencies and validate the code in them, you can use the `validate-all` command. +To check all of your dependencies and validate the code in them, you can use the `run-all validate` command. To check the dependency graph you can use the `graph-dependencies` command (similar to the `terraform graph` command), the graph is output in DOT format The typical program that can read this format is GraphViz, but many web services are also available to read this format. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.38.12/docs/_docs/04_reference/cli-options.md new/terragrunt-0.39.0/docs/_docs/04_reference/cli-options.md --- old/terragrunt-0.38.12/docs/_docs/04_reference/cli-options.md 2022-09-14 22:06:21.000000000 +0200 +++ new/terragrunt-0.39.0/docs/_docs/04_reference/cli-options.md 2022-09-29 16:59:03.000000000 +0200 @@ -79,10 +79,10 @@ [`dependency`](/docs/reference/config-blocks-and-attributes/#dependency) and [`dependencies`](/docs/reference/config-blocks-and-attributes/#dependencies) blocks. -**[WARNING] Using `run-all` with `plan` is currently broken for certain use cases**. If you have a stack of Terragrunt modules with -dependencies between them���either via `dependency` blocks or `terraform_remote_state` data sources���and you've never -deployed them, then `plan-all` will fail as it will not be possible to resolve the `dependency` blocks or -`terraform_remote_state` data sources! Please [see here for more +**[WARNING] Using `run-all` with `plan` is currently broken for certain use cases**. If you have a stack of Terragrunt +modules with dependencies between them���either via `dependency` blocks or `terraform_remote_state` data sources���and +you've never deployed them, then `run-all plan` will fail as it will not be possible to resolve the `dependency` blocks +or `terraform_remote_state` data sources! Please [see here for more information](https://github.com/gruntwork-io/terragrunt/issues/720#issuecomment-497888756). **[NOTE]** Using `run-all` with `apply` or `destroy` silently adds the `-auto-approve` flag to the command line @@ -103,7 +103,7 @@ Example: ```bash -terragrunt plan-all +terragrunt run-all plan ``` This will recursively search the current working directory for any folders that contain Terragrunt modules and run @@ -111,9 +111,9 @@ [`dependency`](/docs/reference/config-blocks-and-attributes/#dependency) and [`dependencies`](/docs/reference/config-blocks-and-attributes/#dependencies) blocks. -**[WARNING] `plan-all` is currently broken for certain use cases**. If you have a stack of Terragrunt modules with +**[WARNING] `run-all plan` is currently broken for certain use cases**. If you have a stack of Terragrunt modules with dependencies between them���either via `dependency` blocks or `terraform_remote_state` data sources���and you've never -deployed them, then `plan-all` will fail as it will not be possible to resolve the `dependency` blocks or +deployed them, then `run-all plan` will fail as it will not be possible to resolve the `dependency` blocks or `terraform_remote_state` data sources! Please [see here for more information](https://github.com/gruntwork-io/terragrunt/issues/720#issuecomment-497888756). @@ -511,8 +511,7 @@ A custom path to the `terragrunt.hcl` or `terragrunt.hcl.json` file. The default path is `terragrunt.hcl` (preferred) or `terragrunt.hcl.json` in the current directory (see [Configuration]({{site.baseurl}}/docs/getting-started/configuration/#configuration) for a slightly more nuanced -explanation). This argument is not used with the `apply-all`, `destroy-all`, `output-all`, `validate-all`, and -`plan-all` commands. +explanation). This argument is not used with the `run-all` commands. ### terragrunt-tfpath @@ -584,9 +583,9 @@ **Requires an argument**: `--terragrunt-working-dir /path/to/working-directory` Set the directory where Terragrunt should execute the `terraform` command. Default is the current working directory. -Note that for the `apply-all`, `destroy-all`, `output-all`, `validate-all`, and `plan-all` commands, this parameter has -a different meaning: Terragrunt will apply or destroy all the Terraform modules in the subfolders of the -`terragrunt-working-dir`, running `terraform` in the root of each module it finds. +Note that for the `run-all` commands, this parameter has a different meaning: Terragrunt will apply or destroy all the +Terraform modules in the subfolders of the `terragrunt-working-dir`, running `terraform` in the root of each module it +finds. ### terragrunt-download-dir @@ -608,10 +607,10 @@ Download Terraform configurations from the specified source into a temporary folder, and run Terraform in that temporary folder. The source should use the same syntax as the [Terraform module -source](https://www.terraform.io/docs/modules/sources.html) parameter. If you specify this argument for the `apply-all`, -`destroy-all`, `output-all`, `validate-all`, or `plan-all` commands, Terragrunt will assume this is the local file path -for all of your Terraform modules, and for each module processed by the `xxx-all` command, Terragrunt will automatically -append the path of `source` parameter in each module to the `--terragrunt-source` parameter you passed in. +source](https://www.terraform.io/docs/modules/sources.html) parameter. If you specify this argument for the `run-all` +commands, Terragrunt will assume this is the local file path for all of your Terraform modules, and for each module +processed by the `run-all` command, Terragrunt will automatically append the path of `source` parameter in each module +to the `--terragrunt-source` parameter you passed in. ### terragrunt-source-map diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.38.12/test/fixture-render-json-mock-outputs/app/terragrunt.hcl new/terragrunt-0.39.0/test/fixture-render-json-mock-outputs/app/terragrunt.hcl --- old/terragrunt-0.38.12/test/fixture-render-json-mock-outputs/app/terragrunt.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.39.0/test/fixture-render-json-mock-outputs/app/terragrunt.hcl 2022-09-29 16:59:03.000000000 +0200 @@ -0,0 +1,13 @@ +include "root" { + path = find_in_parent_folders() +} + +dependency "module" { + config_path = "../dependency" + + mock_outputs = { + security_group_id = "sg-abcd1234" + bastion_host_security_group_id = "123" + } + mock_outputs_allowed_terraform_commands = ["validate" ] +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.38.12/test/fixture-render-json-mock-outputs/dependency/terragrunt.hcl new/terragrunt-0.39.0/test/fixture-render-json-mock-outputs/dependency/terragrunt.hcl --- old/terragrunt-0.38.12/test/fixture-render-json-mock-outputs/dependency/terragrunt.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.39.0/test/fixture-render-json-mock-outputs/dependency/terragrunt.hcl 2022-09-29 16:59:03.000000000 +0200 @@ -0,0 +1,3 @@ +include "root" { + path = find_in_parent_folders() +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.38.12/test/fixture-render-json-mock-outputs/terragrunt.hcl new/terragrunt-0.39.0/test/fixture-render-json-mock-outputs/terragrunt.hcl --- old/terragrunt-0.38.12/test/fixture-render-json-mock-outputs/terragrunt.hcl 1970-01-01 01:00:00.000000000 +0100 +++ new/terragrunt-0.39.0/test/fixture-render-json-mock-outputs/terragrunt.hcl 2022-09-29 16:59:03.000000000 +0200 @@ -0,0 +1,14 @@ +remote_state { + backend = "s3" + config = { + encrypt = true + bucket = "test-tf-state" + key = "${path_relative_to_include()}/terraform.tfstate" + dynamodb_table = "test-terraform-locks" + accesslogging_bucket_name = "test-tf-logs" + } + generate = { + path = "backend.tf" + if_exists = "overwrite_terragrunt" + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.38.12/test/integration_test.go new/terragrunt-0.39.0/test/integration_test.go --- old/terragrunt-0.38.12/test/integration_test.go 2022-09-14 22:06:21.000000000 +0200 +++ new/terragrunt-0.39.0/test/integration_test.go 2022-09-29 16:59:03.000000000 +0200 @@ -130,6 +130,7 @@ TEST_FIXTURE_BROKEN_LOCALS = "fixture-broken-locals" TEST_FIXTURE_BROKEN_DEPENDENCY = "fixture-broken-dependency" TEST_FIXTURE_RENDER_JSON_METADATA = "fixture-render-json-metadata" + TEST_FIXTURE_RENDER_JSON_MOCK_OUTPUTS = "fixture-render-json-mock-outputs" TERRAFORM_BINARY = "terraform" TERRAFORM_FOLDER = ".terraform" TERRAFORM_STATE = "terraform.tfstate" @@ -4699,6 +4700,55 @@ assert.True(t, reflect.DeepEqual(expectedDependencies, dependencies)) } +func TestRenderJsonWithMockOutputs(t *testing.T) { + t.Parallel() + + tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_RENDER_JSON_MOCK_OUTPUTS) + cleanupTerraformFolder(t, tmpEnvPath) + tmpDir := util.JoinPath(tmpEnvPath, TEST_FIXTURE_RENDER_JSON_MOCK_OUTPUTS, "app") + + var expectedMetadata = map[string]interface{}{ + "found_in_file": util.JoinPath(tmpDir, "terragrunt.hcl"), + } + + jsonOut := filepath.Join(tmpDir, "terragrunt_rendered.json") + + runTerragrunt(t, fmt.Sprintf("terragrunt render-json --with-metadata --terragrunt-non-interactive --terragrunt-log-level debug --terragrunt-working-dir %s --terragrunt-json-out %s", tmpDir, jsonOut)) + + jsonBytes, err := ioutil.ReadFile(jsonOut) + require.NoError(t, err) + + var renderedJson = map[string]interface{}{} + require.NoError(t, json.Unmarshal(jsonBytes, &renderedJson)) + + dependency := renderedJson[config.MetadataDependency] + + var expectedDependency = map[string]interface{}{ + "module": map[string]interface{}{ + "metadata": expectedMetadata, + "value": map[string]interface{}{ + "config_path": "../dependency", + "mock_outputs": map[string]interface{}{ + "bastion_host_security_group_id": "123", + "security_group_id": "sg-abcd1234", + }, + "mock_outputs_allowed_terraform_commands": [1]string{"validate"}, + "mock_outputs_merge_strategy_with_state": nil, + "mock_outputs_merge_with_state": nil, + "name": "module", + "outputs": nil, + "skip": nil, + }, + }, + } + serializedDependency, err := json.Marshal(dependency) + assert.NoError(t, err) + + serializedExpectedDependency, err := json.Marshal(expectedDependency) + assert.NoError(t, err) + assert.Equal(t, string(serializedExpectedDependency), string(serializedDependency)) +} + func TestRenderJsonMetadataIncludes(t *testing.T) { t.Parallel() ++++++ vendor.tar.gz ++++++ /work/SRC/openSUSE:Factory/terragrunt/vendor.tar.gz /work/SRC/openSUSE:Factory/.terragrunt.new.2275/vendor.tar.gz differ: char 5, line 1
participants (1)
-
Source-Sync