Report this

What is the reason for this report?

How to configure Functions settings/annotations in project.yml

Posted on September 11, 2022

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!



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!

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.

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

@sebrem, did you ever solve this? I am in a similar position where I want to disable web access (and use scheduling instead), but each time I deploy my functions, it re-enables web access.

Here is my project.yml

parameters: {}
environment: {}
packages:
    - name: orders
      shared: false
      environment: {}
      parameters: {}
      annotations: {}
      functions:
        - name: check
          binary: false
          main: ""
          runtime: go:default
          web: false
          parameters: {}
          environment: {}
          annotations: {}
          limits:
            timeout: 5000

Thanks in advance.

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.