hashicorp / terraform-provider-google

Terraform Provider for Google Cloud Platform
https://registry.terraform.io/providers/hashicorp/google/latest/docs
Mozilla Public License 2.0
2.27k stars 1.72k forks source link

google_cloudfunctions_function terraform changes in every plan #18017

Open Shantanu-11 opened 3 months ago

Shantanu-11 commented 3 months ago

Community Note

Terraform Version & Provider Version(s)

Terraform v1.2.7 on

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

b/340347166

alexku7 commented 3 months ago

Same issue

enricojonas commented 3 months ago

Same issue for us,

      ~ event_trigger {
            # (2 unchanged attributes hidden)

          + failure_policy {
              + retry = false
            }
        }

on every apply...

n-oden commented 3 months ago

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.

fcuenca4 commented 3 months ago

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

ggtisc commented 3 months ago

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

Shantanu-11 commented 2 months ago

@ggtisc Any updates on this?

dixuswe commented 2 months ago

@ggtisc Any updates on this?

this should have been fixed for a while