Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Terraform cloud function: "googleapi: Error 400: The PubSub topic cannot be updated."

Hi!

I'm trying to create an eventTrigger to my 2nd gen cloud function deployed with Terraform. My cloud function works fine with an HTTP trigger, and I'm able to publish it with Terraform, but when I follow the official instructions to change it into a Pub/Sub triggered function, I get:

"googleapi: Error 400: The PubSub topic cannot be updated."

from this section:

  event_trigger {
    trigger_region = "us-central1"
    event_type     = "google.cloud.pubsub.topic.v1.messagePublished"
    pubsub_topic   = google_pubsub_topic.default.id
    retry_policy   = "RETRY_POLICY_RETRY"
  }


I've tried with both a pre-existing Topic or one created with a Terraform "resource" like in the example. The creation of the new topic works, but this error still happens after the creation.

Search engines find nothing related to this error.

Can it be that there's something wrong at Google? I am at "europe-north1".

Solved Solved
1 1 3,982
1 ACCEPTED SOLUTION

As it turns out, this was a cluster of problems with Terraform state getting mixed up, "Eventarc API" not being enabled in the project, the event type being wrong, and existing HTTP triggers not being able to change into event triggers on the fly.

I got it to work after I destroyed my functions and recreated them.

View solution in original post

1 REPLY 1

As it turns out, this was a cluster of problems with Terraform state getting mixed up, "Eventarc API" not being enabled in the project, the event type being wrong, and existing HTTP triggers not being able to change into event triggers on the fly.

I got it to work after I destroyed my functions and recreated them.