0
votes

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?

1
"Do pub/sub messages get deleted if cloud function is deleted?" The answer to this specific question is "no", there is no implicit clean up of the messages upon deletion of a Cloud Function. But that doesn't mean the existing messages will still be there a day later, nor that new messages will be published when there's no listener.Frank van Puffelen

1 Answers

1
votes

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.