Skip to content

Setup Yoda Executor Using Google Cloud Function

satawat thitisupakul edited this page Mar 26, 2024 · 7 revisions

Google Cloud Platform provides a function executor service called "Google Cloud Function". Yoda's executor runtime can be deployed on Google Cloud Function by following this instruction.

In your Google cloud platform account, go to Cloud Functions Page and click Create function.

Step 1: Setup HTTP Triggers

Follow the following steps:

  • Choose your Function name and Region
  • Set Trigger type to HTTP
  • For Authentication, choose Allow unauthenticated invocations

Step 2: Configure Runtime and Environment Variables

Scroll further to VARIABLES, NETWORKING, AND ADVANCED SETTINGS in ADVANCED section. We recommend using 1 GiB RAM and 12 seconds timeout.

Then, create new environment variables for the runtime below.

Key Value
MAX_EXECUTABLE 8192
MAX_DATA_SIZE 4096

Click next to go to the code setting.

Step 3: Upload Runtime Source Code

  1. Choose Runtime to Python 3.9
  2. Set Entry point to execute
  3. Choose Source code to ZIP Upload
  4. You need to upload the runtime zip.
  5. For Stage bucket, if you don't have an existing stage bucket, create a new one.

Step 4: Deploy the Function

Click Deploy at the bottom of the current page. If the deployment is successful, You will see the correct symbol.

Step 5: Test the function

Let's get Trigger URL by clicking the function name and go to Trigger tab.

You can test the endpoint using curl with the following command

curl --location --request POST '<your_trigger_url>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "executable": "IyEvdXNyL2Jpbi9lbnYgcHl0aG9uMwoKaW1wb3J0IHN5cwoKZGVmIG1haW4oZGF0YSk6CiAgICByZXR1cm4gZGF0YQoKCmlmIF9fbmFtZV9fID09ICJfX21haW5fXyI6CiAgICB0cnk6CiAgICAgICAgcHJpbnQobWFpbigqc3lzLmFyZ3ZbMTpdKSkKICAgIGV4Y2VwdCBFeGNlcHRpb24gYXMgZToKICAgICAgICBwcmludChzdHIoZSksIGZpbGU9c3lzLnN0ZGVycikKICAgICAgICBzeXMuZXhpdCgxKQo=",
    "calldata": "\"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages.\"",
    "timeout": 3000
}'

The expected result should be:

{
    "err": "",
    "returncode": 0,
    "stderr": "",
    "stdout": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages.\n",
    "version": "google-cloud-function:2.0.4"
}