Update/Replace resource when source code has changed

I would like to ask how to configure an update/replace to a Google Cloud Function whenever it’s source code it’s changed.

The terraform is running on a gitlab ci and not storing state. It creates the cloud function when it does not exist but if I run the CI again I get error: 409 Function unzip already exists.

I wonder if someone could explain me how to detect a change to a specific resource and redeploy it.

Currently I have the following tf file:

 provider "google" {
      project     = "test-project"
      region      = "europe-west1"
    }


resource "google_cloudfunctions_function" "unzip" {
  name        = "unzip"
  runtime     = "python37"
  entry_point = "extractor"
  project     = "test-project"
  available_memory_mb   = 256

  event_trigger   {
    event_type = "google.storage.object.finalize"
    resource = "temp-bucket"
  }
  
  source_repository{
    url = "https://source.developers.google.com/projects/test-project/repos/infra/moveable-aliases/develop/paths/cloud_functions/unzip"
  } 
}