Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google cloud functions command to package without deploying

I must be missing something because I cant find this option here: https://cloud.google.com/sdk/gcloud/reference/beta/functions/deploy

I want to package and upload my function to a bucket: --stage-bucket But not actually deploy the function

I'm going to deploy multiple functions (different handlers) from the same package with a Deployment Manager template: type: 'gcp-types/cloudfunctions-v1:projects.locations.functions'

gcloud beta functions deploy insists on packaging AND deploying the function. Where is the gcloud beta functions package command?

Here is an example of the DM template I plan to run:

resources:
  - name: resource-name
    type: 'gcp-types/cloudfunctions-v1:projects.locations.functions'
    properties:
      labels:
        testlabel1: testlabel1value
        testlabel2: testlabel2value
      parent: projects/my-project/locations/us-central1
      location: us-central1
      function: function-name
      sourceArchiveUrl: 'gs://my-bucket/some-zip-i-uploaded.zip'
      environmentVariables:
        test: '123'
      entryPoint: handler
      httpsTrigger: {}
      timeout: 60s
      availableMemoryMb: 256
      runtime: nodejs8

EDIT: I realized I have another question. When I upload a zip does that zip need to include dependencies? Do I have to do npm install or pip install first and include those packages in the zip or does cloud functions read my requirements.txt and packages.json and do that for me?

like image 323
red888 Avatar asked Nov 25 '25 13:11

red888


1 Answers

The SDK CLI does not provide a command to package your function.

This link will provide you with detail on how to zip your files together. There are just two points to follow:

  • File type should be a zip file.
  • File size should not exceed 100MB limit.

Then you need to call an API, which returns a Signed URL to upload the package.

Once uploaded you can specify the URL minus the extra parameters as the location.

like image 103
John Hanley Avatar answered Nov 27 '25 23:11

John Hanley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!