I accidentally lost my up to date source file of a cloud function and then deployed again the cloud function with an old version of it.
Each time I deploy a cloud function I see on the console the version id of the deploy.
Is there something I can do to roll back to the previous version of the source file?
Google Cloud Platform was launched on April 7th, 2008. A brief history of Google Cloud involves launching an App Engine to make it easy for companies to start work and release new apps. Initially, they released it only to a few customers and developers – companies that had millions of users.
I finally figured this out:
Each time you make a deploy to a cloud function you get an output line like this:
sourceArchiveUrl: gs://my-store-bucket/us-central1-function_name-xxoxtdxvxaxx.zip
I entered my Google Cloud Platform Developer Console -> Cloud Functions -> function_name -> Source tab
and there almost at the bottom it says: Source location
my-store-bucket/us-central1-function_name-xxoxtdxvxaxx.zip
the same as it was shown in the CLI, but without gs:// that link lead me to the following: https://storage.cloud.google.com/my-store-bucket/us-central1-function_name-........
I removed from the link everything that came after
https://storage.cloud.google.com/my-store-bucket
and that lead me to a huge list of files that each one of them represented a an image of all my cloud functions at the time point of each time i have made a deploy, exactly what i needed!
The only thing left to do was to locate the file with the last date before my mistaken deploy
The following shows where to locate and restore a previous deployment version of your Google Cloud Function.
You can select each of your previous versions on the scrolldown menu at the top left of your GCF screen once you enter a function.
On this overview page, while NOT entering EDIT mode, you can select some previous versions (although not all) from the menu - the selected version is then deployed (here: Version 5).
When you deploy a new version of a CF the code is store in a GCS bucket.This bucket only stores the last 2 deployed versions. You can set a retention policy to keep older versions of the CF.
The name of the bucket it's similar to something like this:
gcf-source-[ID]-[region of the function]
A workaround to restore old version of a CF would be to download the code from the bucket and redeploy the function with it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With