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-07-25 11:49:32 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/terragrunt (Old) and /work/SRC/openSUSE:Factory/.terragrunt.new.1467 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "terragrunt" Tue Jul 25 11:49:32 2023 rev:57 rq:1099616 version:0.48.4 Changes: -------- --- /work/SRC/openSUSE:Factory/terragrunt/terragrunt.changes 2023-07-18 22:08:49.803225705 +0200 +++ /work/SRC/openSUSE:Factory/.terragrunt.new.1467/terragrunt.changes 2023-07-25 11:49:52.373020243 +0200 @@ -1,0 +2,6 @@ +Thu Jul 20 04:50:04 UTC 2023 - ka...@b1-systems.de + +- Update to version 0.48.4: + * Add CLI flags to set handling state buckets (#2644) + +------------------------------------------------------------------- Old: ---- terragrunt-0.48.3.obscpio New: ---- terragrunt-0.48.4.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ terragrunt.spec ++++++ --- /var/tmp/diff_new_pack.OWHrYr/_old 2023-07-25 11:49:59.261060573 +0200 +++ /var/tmp/diff_new_pack.OWHrYr/_new 2023-07-25 11:49:59.265060596 +0200 @@ -19,7 +19,7 @@ %define __arch_install_post export NO_BRP_STRIP_DEBUG=true Name: terragrunt -Version: 0.48.3 +Version: 0.48.4 Release: 0 Summary: Thin wrapper for Terraform for working with multiple Terraform modules License: MIT ++++++ _service ++++++ --- /var/tmp/diff_new_pack.OWHrYr/_old 2023-07-25 11:49:59.301060808 +0200 +++ /var/tmp/diff_new_pack.OWHrYr/_new 2023-07-25 11:49:59.305060831 +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.48.3</param> + <param name="revision">v0.48.4</param> <param name="versionformat">@PARENT_TAG@</param> <param name="changesgenerate">enable</param> <param name="versionrewrite-pattern">v(.*)</param> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.OWHrYr/_old 2023-07-25 11:49:59.325060948 +0200 +++ /var/tmp/diff_new_pack.OWHrYr/_new 2023-07-25 11:49:59.329060972 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/gruntwork-io/terragrunt</param> - <param name="changesrevision">11378302f0e70235cc1fa5cb1c3cacc127d44a40</param></service></servicedata> + <param name="changesrevision">2dc7f9157abfe9890931625b64315bf22fa425c0</param></service></servicedata> (No newline at EOF) ++++++ terragrunt-0.48.3.obscpio -> terragrunt-0.48.4.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.48.3/cli/args.go new/terragrunt-0.48.4/cli/args.go --- old/terragrunt-0.48.3/cli/args.go 2023-07-18 11:07:44.000000000 +0200 +++ new/terragrunt-0.48.4/cli/args.go 2023-07-19 16:35:23.000000000 +0200 @@ -237,6 +237,8 @@ opts.AwsProviderPatchOverrides = awsProviderPatchOverrides opts.FetchDependencyOutputFromState = parseBooleanArg(args, optTerragruntFetchDependencyOutputFromState, os.Getenv("TERRAGRUNT_FETCH_DEPENDENCY_OUTPUT_FROM_STATE") == "true") opts.UsePartialParseConfigCache = parseBooleanArg(args, optTerragruntUsePartialParseConfigCache, os.Getenv("TERRAGRUNT_USE_PARTIAL_PARSE_CONFIG_CACHE") == "true") + opts.DisableBucketUpdate = parseBooleanArg(args, optTerragruntDisableBucketUpdate, os.Getenv("TERRAGRUNT_DISABLE_BUCKET_UPDATE") == "true") + opts.FailIfBucketCreationRequired = parseBooleanArg(args, optTerragruntFailOnStateBucketCreation, os.Getenv("TERRAGRUNT_FAIL_ON_STATE_BUCKET_CREATION") == "true") opts.RenderJsonWithMetadata = parseBooleanArg(args, optTerragruntOutputWithMetadata, false) opts.JSONOut, err = parseStringArg(args, optTerragruntJSONOut, "") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.48.3/cli/cli_app.go new/terragrunt-0.48.4/cli/cli_app.go --- old/terragrunt-0.48.3/cli/cli_app.go 2023-07-18 11:07:44.000000000 +0200 +++ new/terragrunt-0.48.4/cli/cli_app.go 2023-07-19 16:35:23.000000000 +0200 @@ -64,6 +64,8 @@ optTerragruntFetchDependencyOutputFromState = "terragrunt-fetch-dependency-output-from-state" optTerragruntUsePartialParseConfigCache = "terragrunt-use-partial-parse-config-cache" optTerragruntIncludeModulePrefix = "terragrunt-include-module-prefix" + optTerragruntFailOnStateBucketCreation = "terragrunt-fail-on-state-bucket-creation" + optTerragruntDisableBucketUpdate = "terragrunt-disable-bucket-update" optTerragruntOutputWithMetadata = "with-metadata" ) @@ -85,6 +87,8 @@ optTerragruntUsePartialParseConfigCache, optTerragruntOutputWithMetadata, optTerragruntIncludeModulePrefix, + optTerragruntFailOnStateBucketCreation, + optTerragruntDisableBucketUpdate, } var allTerragruntStringOpts = []string{ optTerragruntConfig, @@ -272,6 +276,8 @@ terragrunt-json-out The file path that terragrunt should use when rendering the terragrunt.hcl config as json. Only used in the render-json command. Defaults to terragrunt_rendered.json. terragrunt-use-partial-parse-config-cache Enables caching of includes during partial parsing operations. Will also be used for the --terragrunt-iam-role option if provided. terragrunt-include-module-prefix When this flag is set output from Terraform sub-commands is prefixed with module path. + terragrunt-fail-on-state-bucket-creation When this flag is set Terragrunt will fail if the remote state bucket needs to be created. + terragrunt-disable-bucket-update When this flag is set Terragrunt will not update the remote state bucket. VERSION: {{.Version}}{{if len .Authors}} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.48.3/docs/_docs/04_reference/cli-options.md new/terragrunt-0.48.4/docs/_docs/04_reference/cli-options.md --- old/terragrunt-0.48.3/docs/_docs/04_reference/cli-options.md 2023-07-18 11:07:44.000000000 +0200 +++ new/terragrunt-0.48.4/docs/_docs/04_reference/cli-options.md 2023-07-19 16:35:23.000000000 +0200 @@ -502,6 +502,8 @@ - [terragrunt-fetch-dependency-output-from-state](#terragrunt-fetch-dependency-output-from-state) - [terragrunt-use-partial-parse-config-cache](#terragrunt-use-partial-parse-config-cache) - [terragrunt-include-module-prefix](#terragrunt-include-module-prefix) +- [terragrunt-fail-on-state-bucket-creation](#terragrunt-fail-on-state-bucket-creation) +- [terragrunt-disable-bucket-update](#terragrunt-disable-bucket-update) ### terragrunt-config @@ -930,3 +932,17 @@ **Environment Variable**: `TERRAGRUNT_INCLUDE_MODULE_PREFIX` (set to `true`) When this flag is set output from Terraform sub-commands is prefixed with module path. + +### terragrunt-fail-on-state-bucket-creation + +**CLI Arg**: `--terragrunt-fail-on-state-bucket-creation` +**Environment Variable**: `TERRAGRUNT_FAIL_ON_STATE_BUCKET_CREATION` (set to `true`) + +When this flag is set, Terragrunt will wait for execution if it is required to create the remote state bucket. + +### terragrunt-disable-bucket-update + +**CLI Arg**: `--terragrunt-disable-bucket-update` +**Environment Variable**: `TERRAGRUNT_DISABLE_BUCKET_UPDATE` (set to `true`) + +When this flag is set, Terragrunt does not update the remote state bucket, which is useful to set if the state bucket is managed by a third party. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.48.3/options/options.go new/terragrunt-0.48.4/options/options.go --- old/terragrunt-0.48.3/options/options.go 2023-07-18 11:07:44.000000000 +0200 +++ new/terragrunt-0.48.4/options/options.go 2023-07-19 16:35:23.000000000 +0200 @@ -205,6 +205,12 @@ // Controls if a module prefix will be prepended to TF outputs IncludeModulePrefix bool + + // Fail execution if is required to create S3 bucket + FailIfBucketCreationRequired bool + + // Controls if s3 bucket should be updated or skipped + DisableBucketUpdate bool } // IAMOptions represents options that are used by Terragrunt to assume an IAM role. @@ -385,6 +391,8 @@ UsePartialParseConfigCache: terragruntOptions.UsePartialParseConfigCache, OutputPrefix: terragruntOptions.OutputPrefix, IncludeModulePrefix: terragruntOptions.IncludeModulePrefix, + FailIfBucketCreationRequired: terragruntOptions.FailIfBucketCreationRequired, + DisableBucketUpdate: terragruntOptions.DisableBucketUpdate, } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.48.3/remote/remote_state.go new/terragrunt-0.48.4/remote/remote_state.go --- old/terragrunt-0.48.3/remote/remote_state.go 2023-07-18 11:07:44.000000000 +0200 +++ new/terragrunt-0.48.4/remote/remote_state.go 2023-07-19 16:35:23.000000000 +0200 @@ -208,3 +208,9 @@ ErrRemoteBackendMissing = fmt.Errorf("the remote_state.backend field cannot be empty") ErrGenerateCalledWithNoGenerateAttr = fmt.Errorf("generate code routine called when no generate attribute is configured") ) + +type BucketCreationNotAllowed string + +func (bucketName BucketCreationNotAllowed) Error() string { + return fmt.Sprintf("Creation of remote state bucket %s is not allowed", string(bucketName)) +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.48.3/remote/remote_state_gcs.go new/terragrunt-0.48.4/remote/remote_state_gcs.go --- old/terragrunt-0.48.3/remote/remote_state_gcs.go 2023-07-18 11:07:44.000000000 +0200 +++ new/terragrunt-0.48.4/remote/remote_state_gcs.go 2023-07-19 16:35:23.000000000 +0200 @@ -258,6 +258,10 @@ return errors.WithStackTrace(MissingRequiredGCSRemoteStateConfig("location")) } + if terragruntOptions.FailIfBucketCreationRequired { + return BucketCreationNotAllowed(config.remoteStateConfigGCS.Bucket) + } + prompt := fmt.Sprintf("Remote state GCS bucket %s does not exist or you don't have permissions to access it. Would you like Terragrunt to create it?", config.remoteStateConfigGCS.Bucket) shouldCreateBucket, err := shell.PromptUserForYesNo(prompt, terragruntOptions) if err != nil { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.48.3/remote/remote_state_s3.go new/terragrunt-0.48.4/remote/remote_state_s3.go --- old/terragrunt-0.48.3/remote/remote_state_s3.go 2023-07-18 11:07:44.000000000 +0200 +++ new/terragrunt-0.48.4/remote/remote_state_s3.go 2023-07-19 16:35:23.000000000 +0200 @@ -270,7 +270,7 @@ return err } - if !s3ConfigExtended.DisableBucketUpdate { + if !terragruntOptions.DisableBucketUpdate && !s3ConfigExtended.DisableBucketUpdate { if err := updateS3BucketIfNecessary(s3Client, s3ConfigExtended, terragruntOptions); err != nil { return err } @@ -373,6 +373,10 @@ // confirms, create the bucket and enable versioning for it. func createS3BucketIfNecessary(s3Client *s3.S3, config *ExtendedRemoteStateConfigS3, terragruntOptions *options.TerragruntOptions) error { if !DoesS3BucketExist(s3Client, &config.remoteStateConfigS3.Bucket) { + if terragruntOptions.FailIfBucketCreationRequired { + return BucketCreationNotAllowed(config.remoteStateConfigS3.Bucket) + } + prompt := fmt.Sprintf("Remote state S3 bucket %s does not exist or you don't have permissions to access it. Would you like Terragrunt to create it?", config.remoteStateConfigS3.Bucket) shouldCreateBucket, err := shell.PromptUserForYesNo(prompt, terragruntOptions) if err != nil { @@ -401,6 +405,9 @@ func updateS3BucketIfNecessary(s3Client *s3.S3, config *ExtendedRemoteStateConfigS3, terragruntOptions *options.TerragruntOptions) error { if !DoesS3BucketExist(s3Client, &config.remoteStateConfigS3.Bucket) { + if terragruntOptions.FailIfBucketCreationRequired { + return BucketCreationNotAllowed(config.remoteStateConfigS3.Bucket) + } return errors.WithStackTrace(fmt.Errorf("remote state S3 bucket %s does not exist or you don't have permissions to access it", config.remoteStateConfigS3.Bucket)) } @@ -710,6 +717,9 @@ func CreateLogsS3BucketIfNecessary(s3Client *s3.S3, logsBucketName *string, terragruntOptions *options.TerragruntOptions) error { if !DoesS3BucketExist(s3Client, logsBucketName) { + if terragruntOptions.FailIfBucketCreationRequired { + return BucketCreationNotAllowed(*logsBucketName) + } prompt := fmt.Sprintf("Logs S3 bucket %s for the remote state does not exist or you don't have permissions to access it. Would you like Terragrunt to create it?", *logsBucketName) shouldCreateBucket, err := shell.PromptUserForYesNo(prompt, terragruntOptions) if err != nil { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/terragrunt-0.48.3/test/integration_test.go new/terragrunt-0.48.4/test/integration_test.go --- old/terragrunt-0.48.3/test/integration_test.go 2023-07-18 11:07:44.000000000 +0200 +++ new/terragrunt-0.48.4/test/integration_test.go 2023-07-19 16:35:23.000000000 +0200 @@ -4196,6 +4196,32 @@ assert.True(t, aws.BoolValue(publicAccessBlockConfig.RestrictPublicBuckets)) } +// createS3BucketE create test S3 bucket. +func createS3BucketE(t *testing.T, awsRegion string, bucketName string) error { + mockOptions, err := options.NewTerragruntOptionsForTest("integration_test") + if err != nil { + t.Logf("Error creating mockOptions: %v", err) + return err + } + + sessionConfig := &aws_helper.AwsSessionConfig{ + Region: awsRegion, + } + + s3Client, err := remote.CreateS3Client(sessionConfig, mockOptions) + if err != nil { + t.Logf("Error creating S3 client: %v", err) + return err + } + + t.Logf("Creating test s3 bucket %s", bucketName) + if _, err := s3Client.CreateBucket(&s3.CreateBucketInput{Bucket: aws.String(bucketName)}); err != nil { + t.Logf("Failed to create S3 bucket %s: %v", bucketName, err) + return err + } + return nil +} + // deleteS3BucketWithRetry will attempt to delete the specified S3 bucket, retrying up to 3 times if there are errors to // handle eventual consistency issues. func deleteS3BucketWithRetry(t *testing.T, awsRegion string, bucketName string) { @@ -5678,6 +5704,49 @@ assert.True(t, reflect.DeepEqual(expectedInputs, inputs)) } +func TestTerragruntFailIfBucketCreationIsRequired(t *testing.T) { + t.Parallel() + + tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_PATH) + rootPath := util.JoinPath(tmpEnvPath, TEST_FIXTURE_PATH) + cleanupTerraformFolder(t, rootPath) + + s3BucketName := fmt.Sprintf("terragrunt-test-bucket-%s", strings.ToLower(uniqueId())) + lockTableName := fmt.Sprintf("terragrunt-test-locks-%s", strings.ToLower(uniqueId())) + + tmpTerragruntConfigPath := createTmpTerragruntConfig(t, rootPath, s3BucketName, lockTableName, config.DefaultTerragruntConfigPath) + + stdout := bytes.Buffer{} + stderr := bytes.Buffer{} + err := runTerragruntCommand(t, fmt.Sprintf("terragrunt apply --terragrunt-fail-on-state-bucket-creation --terragrunt-non-interactive --terragrunt-config %s --terragrunt-working-dir %s", tmpTerragruntConfigPath, rootPath), &stdout, &stderr) + assert.Error(t, err) +} + +func TestTerragruntDisableBucketUpdate(t *testing.T) { + t.Parallel() + + tmpEnvPath := copyEnvironment(t, TEST_FIXTURE_PATH) + rootPath := util.JoinPath(tmpEnvPath, TEST_FIXTURE_PATH) + cleanupTerraformFolder(t, rootPath) + + s3BucketName := fmt.Sprintf("terragrunt-test-bucket-%s", strings.ToLower(uniqueId())) + lockTableName := fmt.Sprintf("terragrunt-test-locks-%s", strings.ToLower(uniqueId())) + + err := createS3BucketE(t, TERRAFORM_REMOTE_STATE_S3_REGION, s3BucketName) + assert.NoError(t, err) + + defer deleteS3Bucket(t, TERRAFORM_REMOTE_STATE_S3_REGION, s3BucketName) + defer cleanupTableForTest(t, lockTableName, TERRAFORM_REMOTE_STATE_S3_REGION) + + tmpTerragruntConfigPath := createTmpTerragruntConfig(t, rootPath, s3BucketName, lockTableName, config.DefaultTerragruntConfigPath) + + runTerragrunt(t, fmt.Sprintf("terragrunt apply -auto-approve --terragrunt-disable-bucket-update --terragrunt-non-interactive --terragrunt-config %s --terragrunt-working-dir %s", tmpTerragruntConfigPath, rootPath)) + + _, err = bucketPolicy(t, TERRAFORM_REMOTE_STATE_S3_REGION, s3BucketName) + // validate that bucket policy is not updated, because of --terragrunt-disable-bucket-update + assert.Error(t, err) +} + func validateOutput(t *testing.T, outputs map[string]TerraformOutput, key string, value interface{}) { t.Helper() output, hasPlatform := outputs[key] ++++++ terragrunt.obsinfo ++++++ --- /var/tmp/diff_new_pack.OWHrYr/_old 2023-07-25 11:50:00.069065305 +0200 +++ /var/tmp/diff_new_pack.OWHrYr/_new 2023-07-25 11:50:00.073065328 +0200 @@ -1,5 +1,5 @@ name: terragrunt -version: 0.48.3 -mtime: 1689671264 -commit: 11378302f0e70235cc1fa5cb1c3cacc127d44a40 +version: 0.48.4 +mtime: 1689777323 +commit: 2dc7f9157abfe9890931625b64315bf22fa425c0 ++++++ vendor.tar.gz ++++++ /work/SRC/openSUSE:Factory/terragrunt/vendor.tar.gz /work/SRC/openSUSE:Factory/.terragrunt.new.1467/vendor.tar.gz differ: char 5, line 1