terraform-provider-google icon indicating copy to clipboard operation
terraform-provider-google copied to clipboard

google_cloudfunctions_function terraform changes in every plan

Open Shantanu-11 opened this issue 9 months ago • 4 comments

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.2.7 on

  • provider registry.terraform.io/hashicorp/google v4.34.0
  • provider registry.terraform.io/hashicorp/google-beta v4.34.0

Affected Resource(s)

google_cloudfunctions_function

Terraform Configuration

resource "google_cloudfunctions_function" "function_event" {
  name        = var.function_name
  description = var.function_description
  project     = var.project

  entry_point = var.entry_point

  runtime             = var.runtime
  region              = var.region
  available_memory_mb = var.available_memory_mb
  timeout             = var.timeout
  max_instances       = var.max_instances
  ingress_settings    = var.ingress_settings

  environment_variables = var.environment_variables

  build_environment_variables = var.build_environment_variables


  service_account_email = var.service_account_email
  labels                = var.labels

  vpc_connector                 = var.vpc_connector
  vpc_connector_egress_settings = var.vpc_connector_egress_settings

  source_repository {
    url = "https://source.developers.google.com/projects/${var.source_repository_project}/repos/${var.function_name}/moveable-aliases/${local.environments[split("-", var.project)[1]]}/paths/"
  }

  event_trigger {
    event_type = var.trigger_event_type
    resource   = var.trigger_event_resource
    failure_policy {
      retry = var.trigger_event_retry
    }
  }

  lifecycle {
    ignore_changes = [labels["deployment-tool"], source_repository, max_instances, event_trigger["failure_policy"]]
  }
}

Debug Output

No response

Expected Behavior

No changes were detected in the terraform plan as your configuration matches the infrastructure.

Actual Behavior

There are changes detected in source_archive_bucket and source_archive_object and terraform is trying to set them to null. These values were never being set from our configuration. As for the retry being set to false in the failure_policy block, I have had this as false for a long time and nothing has changed around this

Screenshot from 2024-05-03 16-21-59

Upon applying these changes the apply fails with an error.

image

Steps to reproduce

Create a google_cloud_function without specifying source_archive_bucket OR source_archive_object

  1. The terraform plan generates this plan every time, which fails to apply.

Important Factoids

This has been happening since 1st of May, 2024.

References

No response

Shantanu-11 avatar May 03 '24 11:05 Shantanu-11

Same issue

alexku7 avatar May 05 '24 06:05 alexku7

Same issue for us,

      ~ event_trigger {
            # (2 unchanged attributes hidden)

          + failure_policy {
              + retry = false
            }
        }

on every apply...

enricojonas avatar May 06 '24 09:05 enricojonas

At the risk of adding a me-too comment: we are also seeing this, but with an interesting wrinkle. We have multiple GCP projects in play here, and the same terraform plan produces the spurious diffs but only in one of the projects.

n-oden avatar May 08 '24 15:05 n-oden

as a workaround, but not ideal in some cases. You can add a lifecycle policy to prevent these to appear in your plan

lifecycle {
    ignore_changes = [
      source_archive_bucket,
      source_archive_object,
    ]
  }

use it careful as it ignores changes in source and object

fcuenca4 avatar May 08 '24 19:05 fcuenca4

Multiple users are experiencing the same issue, and due to all the permissions and configurations that this ticket involves I'm forwarding it directly

ggtisc avatar May 13 '24 22:05 ggtisc

@ggtisc Any updates on this?

Shantanu-11 avatar May 28 '24 12:05 Shantanu-11

@ggtisc Any updates on this?

this should have been fixed for a while

dixuswe avatar May 28 '24 21:05 dixuswe