Question

How to configure Functions settings/annotations in project.yml

One can secure their Functions via UI Settings -tab: the option Secure Web Function can be enabled. However, when re-deploying the function via doctl, the Secure Web Function (or any other) setting doesn’t persist.

The relating properties are available in the function metadata annotations which can be obtained via cmd doctl serverless functions get demo/test_auth for an already existing function:

{
  "annotations": [
    {
      "key": "web-export",
      "value": true
    },
    ...,
    {
      "key": "raw-http",
      "value": false
    },
    {
      "key": "provide-api-key",
      "value": false
    },
    {
      "key": "require-whisk-auth",
      "value": false
    },
    {
      "key": "exec",
      "value": "python:3.9"
    }
  ],
   ...

How to configure the “Raw HTTP”, “Secure Web Function”, etc., settings in the project.yml, what are the correct field names? I’ve tried the snippet below as my project.yml, with no luck:

packages:
  - name: demo
    actions:
      - name: test_auth
        annotations:
          require-whisk-auth: true
          raw-http: true
        runtime: 'python:default'
        limits:
          timeout: 12000
          memory: 128

Thanks in advance!

Show comments

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

The Nimbella docs is a great reference when it comes to the serverless configuration file. It’s a shame DigitalOcean doesn’t make it clear that this is the underlying service that powers DigitalOcean Functions. Just keep in mind that DigitalOcean has renamed the actions: section with functions:

This section specifically explains how the webSecure property can be used: https://docs.nimbella.com/wsk#project-configuration.

In its simplest form:

packages:
  - name: payments
    functions:
      - name: pay
        runtime: nodejs:14
        webSecure: 'myVerySecretSecret'

Cheers, Malcolm

I have the same question. I am also not able to find all config properties in the documentation.

In case this is useful for anyone, I figured out (after some experimentation) how to set the Raw HTTP option in the project.yml. You need to set web: "raw" as a property of the action. For example:

packages:
  - name: foo
    actions:
      - name: foo
        runtime: 'nodejs:18'
        web: "raw"

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up