Skip to content

Instantly share code, notes, and snippets.

@momota
Last active February 7, 2018 06:34
Show Gist options
  • Save momota/c065294962d9ec2bc7b4dc48e60ff40b to your computer and use it in GitHub Desktop.
Save momota/c065294962d9ec2bc7b4dc48e60ff40b to your computer and use it in GitHub Desktop.

Develop your codes for Cloud Functions in the local environment.

Make a work directory

~$ mkdir functions_test
~$ cd functions_test

Create your sctipts for Cloud Functions

Write the code with your favorite editor in the local environment.

~$ vim index.js

Like this.

exports.helloGET = function helloGET(req, res) {
        res.send('Hello world!');
}

Create a GCS bucket

Create a GCS (Google Cloud Storage) bucket for saving your script.

~/functions_test$ gsutil mb gs://YOUR_BUCKET_NAME/
Creating gs://YOUR_BUCKET_NAME/...

Deploy

~/functions_test$ gcloud beta functions deploy helloGET --trigger-http --stage-bucket YOUR_BUCKET_NAME
Deploying function (may take a while - up to 2 minutes)...done.
availableMemoryMb: 256
entryPoint: helloGET
httpsTrigger:
  url: https://REGION-PROJECT-ID.cloudfunctions.net/helloGET
labels:
  deployment-tool: cli-gcloud
name: projects/PROJECT-ID/locations/REGION/functions/helloGET
serviceAccountEmail: PROJECT-ID@appspot.gserviceaccount.com
sourceArchiveUrl: gs://YOUR_BUCKET_NAME/REGION-projects/PROJECT-ID/locations/REGION/functions/helloGET-zxmpxrxyrape.zip
status: ACTIVE
timeout: 60s
updateTime: '2018-02-07T06:11:31Z'
versionId: '1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment