Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Referenced computed attributes in google_storage_bucket_object are not updated on the same plan/apply cycle #19379

Closed
athak opened this issue Sep 5, 2024 · 6 comments

Comments

@athak
Copy link

athak commented Sep 5, 2024

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to a user, that user is claiming responsibility for the issue.
  • Customers working with a Google Technical Account Manager or Customer Engineer can ask them to reach out internally to expedite investigation and resolution of this issue.

Terraform Version & Provider Version(s)

Terraform v1.8.5
on darwin_arm64

  • provider registry.terraform.io/hashicorp/google v6.1.0 (also happening with 5.43.1)

Affected Resource(s)

google_storage_bucket_object

Terraform Configuration

resource "google_storage_bucket_object" "test_bug" {
  name    = "test.txt"
  content = "123"
  bucket  = "test-bucket"
}

resource "terraform_data" "test_bug" {
  triggers_replace = [
    google_storage_bucket_object.test_bug.generation,
    google_storage_bucket_object.test_bug.media_link,
  ]
}

Debug Output

No response

Expected Behavior

When modifying the contents of the google_storage_bucket_object, the referenced attributes in other resources should be updated on the same plan/apply.

Actual Behavior

The referenced attributes are updated in the next plan/apply.

Steps to reproduce

  1. terraform apply
  2. Modify the content of the bucket object
  3. terraform plan
    The referenced attributes in the terraform_data resource are not shown as being modified.
  4. terraform apply
  5. terraform plan
    The referenced attributes in the terraform_data resource are now shown as modified and will be updated.

Important Factoids

No response

References

No response

b/367722415

@athak athak added the bug label Sep 5, 2024
@github-actions github-actions bot added forward/review In review; remove label to forward service/storage labels Sep 5, 2024
@ggtisc ggtisc self-assigned this Sep 11, 2024
@ggtisc
Copy link
Collaborator

ggtisc commented Sep 11, 2024

Hi @athak !

For this purpose already exists the versioning in google_storage_bucket. For example if you set it to enabled then each version of your google_storage_bucket_object is going to be forced to be updated. This is enabled at google_storage_bucket level where your object was placed

@ggtisc
Copy link
Collaborator

ggtisc commented Sep 12, 2024

@athak after a second review it seems to me that what you are looking for is for terraform_data.test_bug.triggers_replace to be updated when you make changes to the google_storage_bucket_object. Is this correct?

@athak
Copy link
Author

athak commented Sep 13, 2024

@athak after a second review it seems to me that what you are looking for is for terraform_data.test_bug.triggers_replace to be updated when you make changes to the google_storage_bucket_object. Is this correct?

@ggtisc yes, that is correct, within the same plan/apply cycle. As it stands now, the changes are reflected in the next cycle.

@ggtisc
Copy link
Collaborator

ggtisc commented Sep 13, 2024

Confirmed issue!

After doing some changes on the google_storage_bucket_object the terraform_data.test_bug.triggers_replace was not updated

@ggtisc ggtisc removed their assignment Sep 13, 2024
@ggtisc ggtisc removed the forward/review In review; remove label to forward label Sep 17, 2024
@rileykarson
Copy link
Collaborator

This is a Terraform Core issue, Terraform plans greedily assume that output values are not volatile and can be carried forward later into plan when the resource is updated. There are technically ways to trigger values becoming unknown on a plan from within the provider, but they require substantial custom logic to achieve and are not done in practice by providers to my knowledge.

Here's the same issue across different resources/features:

resource "google_compute_address" "my-address" {
  name        = "my-test-address"
  description = "foo"
+  labels = {
+    foo = "bar"
+  }
}

resource "google_compute_global_address" "gladress" {
  name = "my-test-gladress"
  lifecycle {
    replace_triggered_by = [google_compute_address.my-address.address]
  }
}
$ terraform apply
google_compute_address.my-address: Refreshing state... [id=projects/graphite-test-rileykarson/regions/us-central1/addresses/my-test-address]
google_compute_global_address.gladress: Refreshing state... [id=projects/graphite-test-rileykarson/global/addresses/my-test-gladress]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # google_compute_address.my-address will be updated in-place
  ~ resource "google_compute_address" "my-address" {
      ~ effective_labels   = {
          + "foo" = "bar"
        }
        id                 = "projects/graphite-test-rileykarson/regions/us-central1/addresses/my-test-address"
      ~ labels             = {
          + "foo" = "bar"
        }
        name               = "my-test-address"
      ~ terraform_labels   = {
          + "foo" = "bar"
        }
        # (11 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value:

I looked for an issue upstream but couldn't seem to get the right terms together to find a preexisting issue against Core.

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants