This repository has been archived by the owner on Nov 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
Google Cloud Function executor setup
Max edited this page May 24, 2021
·
5 revisions
In your Google cloud platform account, go to Cloud Functions Page and click Create function.
Follow the following steps:
- Choose your Function name and Region
- Set Trigger type to HTTP
- For Authenication, choose Allow unauthenicated invocations
Scroll further to VARIABLES, NETWORKING, AND ADVANCED SETTINGS in ADVANCED section. We recommend using 1 GiB RAM and 12 seconds timeout.
for ENVIRONMENT VARIABLES section, add 2 Runtime environment variables: MAX_EXECUTABLE
to 8192 (8 MB) and MAX_DATA_SIZE
to 256.
Click next go to the code setting.
Follow the following steps:
- Choose Runtime to
Python 3.7.
- Set Entry point to
execute
- Choose Source code to
ZIP Upload
- You need to upload the runtime zip.
- For Stage bucket, if you don't have an existing stage bucket, create a new one.
- Then click Deploy
If the deployment is successful, You will see the correct symbol.
Let's get Trigger URL
by clicking the function name and go to Trigger
tab.
You can test the endpoint using curl
curl --location --request POST '<your_trigger_url>' \
--header 'Content-Type: application/json' \
--data-raw '{
"executable": "IyEvdXNyL2Jpbi9lbnYgcHl0aG9uMwoKaW1wb3J0IHN5cwoKZGVmIG1haW4oZGF0YSk6CiAgICByZXR1cm4gZGF0YQoKCmlmIF9fbmFtZV9fID09ICJfX21haW5fXyI6CiAgICB0cnk6CiAgICAgICAgcHJpbnQobWFpbigqc3lzLmFyZ3ZbMTpdKSkKICAgIGV4Y2VwdCBFeGNlcHRpb24gYXMgZToKICAgICAgICBwcmludChzdHIoZSksIGZpbGU9c3lzLnN0ZGVycikKICAgICAgICBzeXMuZXhpdCgxKQo=",
"calldata": "\"Hello lambda\"",
"timeout": 3000
}'
The expected result should be:
{
"returncode": 0,
"stdout": "Hello lambda\n",
"stderr": "",
"error": "",
"version": "google-cloud-function:1.1.2"
}