Making a function private
For a function to be invoked only by users with the permission to do so, make the function private.
Note
If all unauthorized users (the All users public group) of a cloud or folder are granted permissions to invoke a function, the function will be public regardless of its settings. For information on how to revoke a role, see this guide.
- In the management console
, navigate to the folder containing the function. - Go to Cloud Functions.
- Select the function you want to make private.
- On the Overview page, disable Public function.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also specify a different folder for any command using --folder-name or --folder-id. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.
To make a function private, run this command:
yc serverless function deny-unauthenticated-invoke <function_name>
Result:
done (1s)