Search code examples
google-cloud-functions

Retrieving an old version of a Google Cloud function source


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?


Solution

  • 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