Daniel Wyatt
Daniel Wyatt

Reputation: 1151

Do pub/sub messages get deleted if cloud function is deleted?

If I delete a google cloud function and redeploy the same function a day later will I have lost the pub/sub messages that trigger it for that day?

Upvotes: 1

Views: 714

Answers (1)

guillaume blaquiere
guillaume blaquiere

Reputation: 75930

It depends how you have deployed your Cloud Functions

  1. HTTP Functions: You deployed your Cloud Functions with an HTTP trigger. In this case, you have to create a PubSub Push subscription manually that call the Cloud Functions when a message arrived.

If you delete your Cloud Functions, the Pubsub subscription continue to live and to receive the messages. They are kept up to their expiration deadline. The push HTTP call fails in error continuously because the Cloud Functions no longer exists.

If you redeploy the Cloud Functions, on the same project, with the same name, the HTTP url will again exist and the messages will be delivered, without lost.

  1. Background Functions: You have deployed your function with a trigger topic. In this case a PubSub subscription is created automatically with the function is created

If you delete the Cloud Functions, the PubSub subscription, created automatically, will be deleted automatically. So, the existing messages and the new ones will be lost, because there is no subscription to accept and store them.

Upvotes: 3

Related Questions