1

Apparently what happen to me - GCP n00b - removed all my cloud storage buckets after some demo/tutorials not being aware I remove source code of my cloud functions.

Is there any way to restore buckets or get at least the source code somehow?

details:

  • this was python function
  • these functions are still running,

so the python code have to live somewhere as python is interpreted language...

leasons learned:

  • I didn't manage to get my code back in any of proposed ways
  • incautious deleting of buckets may lead you end up without source code of your google function
  • using repo GCP Cloud Source and in parallel another remote (e.g gitlab or github) makes work much more safe, and comfortable than coping pasting stuff which you can quite easily lose your source irreversibly
  • some bits/gnotcha parts can be found when reading logs
andilabs
  • 22,159
  • 14
  • 114
  • 151

1 Answers1

1

I don't think you can recover the buckets, unless you had enabled object versioning for them before (see this question). But I think you are still fine, because you should still be able to access the container image.

Please refer to this passage in the Cloud Functions documentation:

When you deploy your function's source code to Cloud Functions, that source is stored in a Cloud Storage bucket. Cloud Build then automatically builds your code into a container image and pushes that image to a image registry (either Container Registry or Artifact Registry). Cloud Functions accesses this image when it needs to run the container to execute your function.

Even if you don't have the source code available anywhere, I think that at least you should be able to download the container image. Once downloaded, you could inspect it the layers of the container image with a tool like dive and view the original python code.

jackdbd
  • 4,583
  • 3
  • 26
  • 36
  • 2
    Just as a note, the container image can be recovered if it is in Artifact Registry. If the images were in container registry, this will not be possible since it depends on the GCP buckets – Puteri Jul 17 '22 at 00:45