Develop your codes for Cloud Functions in the local environment.
~$ mkdir functions_test
~$ cd functions_test
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 (Google Cloud Storage) bucket for saving your script.
~/functions_test$ gsutil mb gs://YOUR_BUCKET_NAME/
Creating gs://YOUR_BUCKET_NAME/...
~/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: [email protected]
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'