-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Labels
awsRelates to integration with AWSRelates to integration with AWSbugSomething isn't workingSomething isn't workingcontributions-requestedRequesting contributions from the communityRequesting contributions from the communitypreservedPreserved issues never go stalePreserved issues never go stale
Description
Describe the bug
The s3 state backend policy does not get updated as expected. Given the current state bucket policy is empty, so I would expect terragrunt to detect it and prompt me to add EnforcedTLS and RootAccess.
Maybe this feature has been removed or flagged, but I haven't found anything in that sense searching in issues and documentation.
Steps To Reproduce
- Ensure
remote_stateblock doesn't include anyskip_nordisable_bucket_updateproperty:
remote_state {
backend = "s3"
config = {
bucket = "tg-state-store"
key = "${path_relative_to_include()}/terraform.tfstate"
region = local.merged.tf_state_bucket_region
encrypt = true
dynamodb_table = "tg-state-lock"
}
generate = {
path = "backend.tf"
if_exists = "overwrite_terragrunt"
}
}- Ensure the state bucket policy is empty:
aws s3api get-bucket-policy --bucket tg-state-store
An error occurred (NoSuchBucketPolicy) when calling the GetBucketPolicy operation: The bucket policy does not exist
-
Create whatever unit (I used a policy because it is small)
-
Run terragrunt:
terragrunt run --log-level trace -- apply
Find the logs below:
12:30:21.257 DEBUG Terragrunt Version: 0.88.1
12:30:21.258 DEBUG Skipping stack generation in .
12:30:21.262 DEBUG Found locals block: evaluating the expressions.
12:30:21.264 DEBUG Found locals block: evaluating the expressions.
12:30:21.272 DEBUG Evaluated 2 locals (remaining 1): merged, custom_tags
12:30:21.272 DEBUG Evaluated 1 locals (remaining 0): full_name
12:30:21.272 DEBUG Found locals block: evaluating the expressions.
12:30:21.275 DEBUG Evaluated 2 locals (remaining 1): merged, custom_tags
12:30:21.275 DEBUG Evaluated 1 locals (remaining 0): full_name
12:30:21.275 DEBUG Exposing include block 'root'
12:30:21.275 DEBUG Evaluated 1 locals (remaining 0): name
12:30:21.276 DEBUG Found locals block: evaluating the expressions.
12:30:21.280 DEBUG Evaluated 2 locals (remaining 1): merged, custom_tags
12:30:21.280 DEBUG Evaluated 1 locals (remaining 0): full_name
12:30:21.280 DEBUG Exposing include block 'root'
12:30:21.281 DEBUG Found locals block: evaluating the expressions.
12:30:21.283 DEBUG Evaluated 2 locals (remaining 1): merged, custom_tags
12:30:21.283 DEBUG Evaluated 1 locals (remaining 0): full_name
12:30:21.284 DEBUG [Partial] Included config ../../../../root.hcl has strategy deep merge: merging config in (deep).
12:30:21.285 DEBUG using cache key for version files: r01AJjVD7VSXCQk1ORuh_no_NRY
12:30:21.285 DEBUG Running command: terraform -version
12:30:21.285 DEBUG Engine is not enabled, running command directly in .
12:30:21.483 DEBUG terraform version: 1.7.5
12:30:21.483 DEBUG Reading Terragrunt config file at ./terragrunt.hcl
12:30:21.485 DEBUG Found locals block: evaluating the expressions.
12:30:21.487 DEBUG Found locals block: evaluating the expressions.
12:30:21.490 DEBUG Evaluated 2 locals (remaining 1): custom_tags, merged
12:30:21.491 DEBUG Evaluated 1 locals (remaining 0): full_name
12:30:21.492 DEBUG Found locals block: evaluating the expressions.
12:30:21.501 DEBUG Evaluated 2 locals (remaining 1): merged, custom_tags
12:30:21.501 DEBUG Evaluated 1 locals (remaining 0): full_name
12:30:21.501 DEBUG Exposing include block 'root'
12:30:21.501 DEBUG Evaluated 1 locals (remaining 0): name
12:30:21.502 DEBUG Found locals block: evaluating the expressions.
12:30:21.506 DEBUG Evaluated 2 locals (remaining 1): merged, custom_tags
12:30:21.506 DEBUG Evaluated 1 locals (remaining 0): full_name
12:30:21.507 DEBUG Exposing include block 'root'
12:30:21.507 DEBUG Found locals block: evaluating the expressions.
12:30:21.515 DEBUG Evaluated 2 locals (remaining 1): merged, custom_tags
12:30:21.516 DEBUG Evaluated 1 locals (remaining 0): full_name
12:30:21.516 DEBUG [Partial] Included config ../../../../root.hcl has strategy deep merge: merging config in (deep).
12:30:21.516 DEBUG Found locals block: evaluating the expressions.
12:30:21.517 DEBUG Found locals block: evaluating the expressions.
12:30:21.521 DEBUG Evaluated 2 locals (remaining 1): merged, custom_tags
12:30:21.521 DEBUG Evaluated 1 locals (remaining 0): full_name
12:30:21.521 DEBUG Found locals block: evaluating the expressions.
12:30:21.524 DEBUG Evaluated 2 locals (remaining 1): merged, custom_tags
12:30:21.524 DEBUG Evaluated 1 locals (remaining 0): full_name
12:30:21.525 DEBUG Exposing include block 'root'
12:30:21.525 DEBUG Evaluated 1 locals (remaining 0): name
12:30:21.529 DEBUG Found locals block: evaluating the expressions.
12:30:21.532 DEBUG Evaluated 2 locals (remaining 1): merged, custom_tags
12:30:21.532 DEBUG Evaluated 1 locals (remaining 0): full_name
12:30:21.532 DEBUG Exposing include block 'root'
12:30:21.532 DEBUG Found locals block: evaluating the expressions.
12:30:21.536 DEBUG Evaluated 2 locals (remaining 1): custom_tags, merged
12:30:21.536 DEBUG Evaluated 1 locals (remaining 0): full_name
12:30:21.536 DEBUG Included config ../../../../root.hcl has strategy deep merge: merging config in (deep) for dependency.
12:30:21.537 DEBUG Found locals block: evaluating the expressions.
12:30:21.540 DEBUG Evaluated 2 locals (remaining 1): merged, custom_tags
12:30:21.540 DEBUG Evaluated 1 locals (remaining 0): full_name
12:30:21.541 DEBUG Exposing include block 'root'
12:30:21.542 DEBUG Found locals block: evaluating the expressions.
12:30:21.546 DEBUG Evaluated 2 locals (remaining 1): merged, custom_tags
12:30:21.546 DEBUG Evaluated 1 locals (remaining 0): full_name
12:30:21.547 DEBUG Included config ../../../../root.hcl has strategy deep merge: merging config in (deep).
12:30:21.547 DEBUG Detected 1 Hooks
12:30:21.547 INFO Downloading Terraform configurations from git::https://github.com/terraform-aws-modules/terraform-aws-iam.git?ref=v5.38.0 into ./.terragrunt-cache/uE2FDFUEmDsr_lfiOTEB7_a9wmE/3EnVVUCmsbqTbM1RfixO5_z_Z2w
12:30:24.069 DEBUG Copying files from . into ./.terragrunt-cache/uE2FDFUEmDsr_lfiOTEB7_a9wmE/3EnVVUCmsbqTbM1RfixO5_z_Z2w/modules/iam-policy
12:30:24.070 DEBUG Setting working directory to ./.terragrunt-cache/uE2FDFUEmDsr_lfiOTEB7_a9wmE/3EnVVUCmsbqTbM1RfixO5_z_Z2w/modules/iam-policy
12:30:24.070 DEBUG Generated file ./.terragrunt-cache/uE2FDFUEmDsr_lfiOTEB7_a9wmE/3EnVVUCmsbqTbM1RfixO5_z_Z2w/modules/iam-policy/versions_override.tf.
12:30:24.070 DEBUG Generated file ./.terragrunt-cache/uE2FDFUEmDsr_lfiOTEB7_a9wmE/3EnVVUCmsbqTbM1RfixO5_z_Z2w/modules/iam-policy/provider-aws.tf.
12:30:24.070 DEBUG No encryption block in remote_state config
12:30:24.071 DEBUG Generated file ./.terragrunt-cache/uE2FDFUEmDsr_lfiOTEB7_a9wmE/3EnVVUCmsbqTbM1RfixO5_z_Z2w/modules/iam-policy/backend.tf.
12:30:24.071 DEBUG Detected 1 Hooks
12:30:24.071 DEBUG Running command: terraform init
12:30:24.071 DEBUG Engine is not enabled, running command directly in ./.terragrunt-cache/uE2FDFUEmDsr_lfiOTEB7_a9wmE/3EnVVUCmsbqTbM1RfixO5_z_Z2w/modules/iam-policy
12:30:24.158 INFO terraform: Initializing the backend...
12:30:25.979 INFO terraform:
12:30:25.980 INFO terraform: Successfully configured the backend "s3"! Terraform will automatically
12:30:25.980 INFO terraform: use this backend unless the backend configuration changes.
12:30:26.517 INFO terraform: Initializing provider plugins...
12:30:26.517 INFO terraform: - Finding hashicorp/aws versions matching "~> 5.83"...
12:30:26.825 INFO terraform: - Installing hashicorp/aws v5.100.0...
12:30:31.651 INFO terraform: - Installed hashicorp/aws v5.100.0 (signed by HashiCorp)
12:30:31.652 INFO terraform: Terraform has created a lock file .terraform.lock.hcl to record the provider
12:30:31.652 INFO terraform: selections it made above. Include this file in your version control repository
12:30:31.652 INFO terraform: so that Terraform can guarantee to make the same selections by default when
12:30:31.652 INFO terraform: you run "terraform init" in the future.
12:30:31.652 INFO terraform: Terraform has been successfully initialized!
12:30:31.653 INFO terraform:
12:30:31.653 INFO terraform: You may now begin working with Terraform. Try running "terraform plan" to see
12:30:31.653 INFO terraform: any changes that are required for your infrastructure. All Terraform commands
12:30:31.653 INFO terraform: should now work.
12:30:31.653 INFO terraform: If you ever set or change modules or backend configuration for Terraform,
12:30:31.653 INFO terraform: rerun this command to reinitialize your working directory. If you forget, other
12:30:31.653 INFO terraform: commands will detect it and remind you to do so if necessary.
12:30:31.654 DEBUG Copying lock file from ./.terragrunt-cache/uE2FDFUEmDsr_lfiOTEB7_a9wmE/3EnVVUCmsbqTbM1RfixO5_z_Z2w/modules/iam-policy/.terraform.lock.hcl to .
12:30:31.656 DEBUG Detected 1 Hooks
12:30:31.656 DEBUG Running command: terraform apply
12:30:31.656 DEBUG Engine is not enabled, running command directly in ./.terragrunt-cache/uE2FDFUEmDsr_lfiOTEB7_a9wmE/3EnVVUCmsbqTbM1RfixO5_z_Z2w/modules/iam-policy
12:30:43.460 STDOUT terraform: Terraform used the selected providers to generate the following execution
12:30:43.460 STDOUT terraform: plan. Resource actions are indicated with the following symbols:
12:30:43.460 STDOUT terraform: + create
12:30:43.460 STDOUT terraform: Terraform will perform the following actions:
12:30:43.460 STDOUT terraform: # aws_iam_policy.policy[0] will be created
12:30:43.460 STDOUT terraform: + resource "aws_iam_policy" "policy" {
12:30:43.460 STDOUT terraform: + arn = (known after apply)
12:30:43.460 STDOUT terraform: + attachment_count = (known after apply)
12:30:43.460 STDOUT terraform: + description = "IAM Policy"
12:30:43.460 STDOUT terraform: + id = (known after apply)
12:30:43.460 STDOUT terraform: + name = "test"
12:30:43.460 STDOUT terraform: + name_prefix = (known after apply)
12:30:43.460 STDOUT terraform: + path = "/"
12:30:43.460 STDOUT terraform: + policy = jsonencode(
12:30:43.460 STDOUT terraform: {
12:30:43.460 STDOUT terraform: + Statement = [
12:30:43.460 STDOUT terraform: + {
12:30:43.460 STDOUT terraform: + Action = [
12:30:43.460 STDOUT terraform: + "secretsmanager:GetSecretValue",
12:30:43.460 STDOUT terraform: ]
12:30:43.460 STDOUT terraform: + Effect = "Deny"
12:30:43.460 STDOUT terraform: + Resource = "*"
12:30:43.460 STDOUT terraform: + Sid = "DenySecretsManagerDataAccess"
12:30:43.460 STDOUT terraform: },
12:30:43.460 STDOUT terraform: ]
12:30:43.460 STDOUT terraform: + Version = "2012-10-17"
12:30:43.460 STDOUT terraform: }
12:30:43.460 STDOUT terraform: )
12:30:43.460 STDOUT terraform: + policy_id = (known after apply)
12:30:43.460 STDOUT terraform: + tags_all = (known after apply)
12:30:43.460 STDOUT terraform: }
12:30:43.460 STDOUT terraform: Plan: 1 to add, 0 to change, 0 to destroy.
12:30:43.460 STDOUT terraform:
12:30:43.460 STDOUT terraform: Changes to Outputs:
12:30:43.460 STDOUT terraform: + arn = (known after apply)
12:30:43.460 STDOUT terraform: + description = "IAM Policy"
12:30:43.460 STDOUT terraform: + id = (known after apply)
12:30:43.461 STDOUT terraform: + name = "test"
12:30:43.461 STDOUT terraform: + path = "/"
12:30:43.461 STDOUT terraform: + policy = jsonencode(
12:30:43.461 STDOUT terraform: {
12:30:43.461 STDOUT terraform: + Statement = [
12:30:43.461 STDOUT terraform: + {
12:30:43.461 STDOUT terraform: + Action = [
12:30:43.461 STDOUT terraform: + "secretsmanager:GetSecretValue",
12:30:43.461 STDOUT terraform: ]
12:30:43.461 STDOUT terraform: + Effect = "Deny"
12:30:43.461 STDOUT terraform: + Resource = "*"
12:30:43.461 STDOUT terraform: + Sid = "DenySecretsManagerDataAccess"
12:30:43.461 STDOUT terraform: },
12:30:43.461 STDOUT terraform: ]
12:30:43.461 STDOUT terraform: + Version = "2012-10-17"
12:30:43.461 STDOUT terraform: }
12:30:43.461 STDOUT terraform: )
12:30:43.461 STDOUT terraform:
12:30:43.461 STDOUT terraform: Do you want to perform these actions?
12:30:43.461 STDOUT terraform: Terraform will perform the actions described above.
12:30:43.461 STDOUT terraform: Only 'yes' will be accepted to approve.
12:30:43.461 STDOUT terraform: Enter a value:
yes
12:30:58.785 STDOUT terraform: aws_iam_policy.policy[0]: Creating...
12:30:59.465 STDOUT terraform: aws_iam_policy.policy[0]: Creation complete after 0s [id=arn:aws:iam::242454459143:policy/test]
12:31:00.284 STDOUT terraform:
12:31:00.284 STDOUT terraform: Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
12:31:00.284 STDOUT terraform:
12:31:00.284 STDOUT terraform: Outputs:
12:31:00.284 STDOUT terraform:
12:31:00.284 STDOUT terraform: arn = "arn:aws:iam::0123456789012:policy/test"
12:31:00.284 STDOUT terraform: description = "IAM Policy"
12:31:00.284 STDOUT terraform: id = "arn:aws:iam::0123456789012:policy/test"
12:31:00.284 STDOUT terraform: name = "test"
12:31:00.284 STDOUT terraform: path = "/"
12:31:00.284 STDOUT terraform: policy = "{\"Statement\":[{\"Action\":[\"secretsmanager:GetSecretValue\"],\"Effect\":\"Deny\",\"Resource\":\"*\",\"Sid\":\"DenySecretsManagerDataAccess\"}],\"Version\":\"2012-10-17\"}"
Expected behavior
I would expect terragrunt to prompt me with this:
Remote state S3 bucket tg-state-store is out of date. Would you like Terragrunt to update it?
or at least, since I'm running in --log-level trace, to display in the logs S3 bucket is already up to date.
Must haves
- Steps for reproduction provided.
Nice to haves
- Terminal output
- Screenshots
Versions
- Terragrunt version: 0.88.1
- OpenTofu/Terraform version: 1.7.5
- Environment details (Ubuntu 20.04, Windows 10, etc.): MacOS 26.0.1
Additional context
I tested with terragrunt run -- init, terragrunt run --backend-bootstrap -- init, terragrunt run -- plan and terragrunt run -- apply with the same result.
Metadata
Metadata
Assignees
Labels
awsRelates to integration with AWSRelates to integration with AWSbugSomething isn't workingSomething isn't workingcontributions-requestedRequesting contributions from the communityRequesting contributions from the communitypreservedPreserved issues never go stalePreserved issues never go stale