Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Tutorials
    • All tutorials
    • URL shortener
    • Entering data into storage systems
    • Storing application runtime logs
    • Deploying a web application using the Java Servlet API
    • Developing a Slack bot
    • Developing a Telegram bot
    • Developing a custom integration in API Gateway
    • Developing CRUD APIs for movie services
    • Building a CI/CD pipeline in GitLab
    • Working with an API gateway via WebSocket
    • Creating an interactive serverless application using WebSocket
    • Automatically copying objects from one Object Storage bucket to another
    • Visualizing logs in Grafana using the Cloud Logging plugin
    • Canary release of a Cloud Functions function
    • Interactive debugging of Cloud Functions functions
    • Creating a Node.js function using TypeScript
    • Running a containerized app in Serverless Containers
    • Streaming Yandex Cloud Postbox events to Data Streams and analyzing them using DataLens
    • Using API Gateway to set up speech synthesis in SpeechKit
    • Connecting to YDB from a Cloud Functions function in Python
    • Connecting to a YDB database from a Cloud Functions function in Node.js
    • API Gateway protection with Smart Web Security
    • Deploying a web app with JWT authorization in API Gateway and authentication in Firebase
    • Automatic data upload to Yandex SpeechSense using Yandex Workflows
    • Configuring responses in Cloud Logging and Yandex Cloud Functions
    • Setting up Workflows integration with Tracker, YandexGPT, and Yandex Cloud Postbox
    • Developing functions in Functions Framework and deploying them to Yandex Serverless Containers

In this article:

  • Get your cloud ready
  • Required paid resources
  • Install the required utilities
  • Create a service account with admin permissions for the cloud
  • Deploy your resources
  • Run the debugging service
  • How to delete the resources you created
  1. Serverless technologies
  2. Interactive debugging of Cloud Functions functions

Interactive debugging of Yandex Cloud Functions functions

Written by
Yandex Cloud
Improved by
Danila N.
Updated at May 7, 2025
  • Get your cloud ready
    • Required paid resources
  • Install the required utilities
  • Create a service account with admin permissions for the cloud
  • Deploy your resources
  • Run the debugging service
  • How to delete the resources you created

In this tutorial, you will set up a system to interactively debug Yandex Cloud Functions functions by redirecting requests to a local server. For more information about this solution, see the yc-serverless-live-debug repository.

To set up the interactive function debugging system:

  1. Get your cloud ready.
  2. Install the required utilities.
  3. Create a service account with the admin privileges for the cloud.
  4. Deploy your resources.
  5. Run the debugging service.

If you no longer need the resources you created, delete them.

Get your cloud readyGet your cloud ready

Sign up in Yandex Cloud and create a billing account:

  1. Navigate to the management console and log in to Yandex Cloud or register a new account.
  2. On the Yandex Cloud Billing page, make sure you have a billing account linked and it has the ACTIVE or TRIAL_ACTIVE status. If you do not have a billing account, create one and link a cloud to it.

If you have an active billing account, you can navigate to the cloud page to create or select a folder for your infrastructure to operate in.

Learn more about clouds and folders.

Required paid resourcesRequired paid resources

The infrastructure support costs include:

  • Fee for function calls and computing resources allocated to execute the functions (see Yandex Cloud Functions pricing).
  • Fee for the number of requests to the API gateway (see Yandex API Gateway pricing).
  • Fee for YDB operations and data storage (see Yandex Managed Service for YDB pricing).
  • Fee for logging operations and log storage (see Yandex Cloud Logging pricing).

Install the required utilitiesInstall the required utilities

  1. Install Terraform.

  2. Create a folder named live-debug-test and open it:

    mkdir live-debug-test
    cd live-debug-test
    
  3. Install the yc-serverless-live-debug package:

    npm i -D @yandex-cloud/serverless-live-debug
    

Create a service account with admin permissions for the cloudCreate a service account with admin permissions for the cloud

  1. Create a service account:

    Management console
    CLI
    Terraform
    API
    1. In the management console, select the folder where you want to create a service account.

    2. From the list of services, select Identity and Access Management.

    3. Click Create service account.

    4. Enter a name for the service account, e.g., sa-live-debug.

      The naming requirements are as follows:

      • It must be from 2 to 63 characters long.
      • It may contain lowercase Latin letters, numbers, and hyphens.
      • It must start with a letter and cannot end with a hyphen.
    5. Click Create.

    If you do not have the Yandex Cloud CLI yet, install and initialize it.

    The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

    To create a service account, run the following command:

    yc iam service-account create --name sa-live-debug
    

    Where name is the service account name in the following format:

    • It must be from 2 to 63 characters long.
    • It may contain lowercase Latin letters, numbers, and hyphens.
    • It must start with a letter and cannot end with a hyphen.

    Result:

    id: ajehr0to1g8b********
    folder_id: b1gv87ssvu49********
    created_at: "2023-03-04T09:03:11.665153755Z"
    name: sa-live-debug
    

    If you do not have Terraform yet, install it and configure its Yandex Cloud provider.

    1. In the configuration file, define the parameters of the resources you want to create:

      resource "yandex_iam_service_account" "sa" {
        name        = "sa-live-debug"
        description = "<service_account_description>"
        folder_id   = "<folder_ID>"
      }
      

      Where:

      • name: Service account name. This is a required parameter.
      • description: Service account description. This is an optional parameter.
      • folder_id: Folder ID. This is an optional parameter. By default, the value specified in the provider settings is used.

      For more information about the yandex_iam_service_account resource parameters in Terraform, see the provider documentation.

    2. Make sure the configuration files are correct.

      1. In the command line, go to the directory where you created the configuration file.

      2. Run a check using this command:

        terraform plan
        

      If the configuration is specified correctly, the terminal will display information about the service account. If there are errors in the configuration, Terraform will point them out.

    3. Deploy the cloud resources.

      1. If the configuration does not contain any errors, run this command:

        terraform apply
        

    To create a service account, use the create REST API method for the ServiceAccount resource or the ServiceAccountService/Create gRPC API call.

  2. Assign the service account the admin role for the cloud:

    Management console
    CLI
    Terraform
    API
    1. On the management console home page, select the cloud.
    2. Navigate to the Access bindings tab.
    3. Find the sa-live-debug account in the list and click .
    4. Click Edit roles.
    5. Click Add role in the window that opens and select the admin role.
    6. Click Save.

    Run this command:

    yc resource-manager cloud add-access-binding <cloud_ID> \
       --role admin \
       --subject serviceAccount:<service_account_ID>
    

    Result:

    done (1s)
    
    1. In the configuration file, define the parameters of the resources you want to create:

      resource "yandex_resourcemanager_cloud_iam_member" "admin" {
        cloud_id = "<cloud_ID>"
        role     = "admin"
        member   = "serviceAccount:<service_account_ID>"
      }
      

      Where:

      • cloud_id: Cloud ID. This is a required parameter.
      • role: Role to assign. This is a required parameter.
      • member: User or service account getting the role. Specify it as userAccount:<user_ID> or serviceAccount:<service_account_ID>. This is a required parameter.

      For more information about the yandex_resourcemanager_folder_iam_member resource parameters, see the relevant provider documentation.

    2. Make sure the configuration files are correct.

      1. In the command line, go to the directory where you created the configuration file.

      2. Run a check using this command:

         terraform plan
        

        If you described the configuration correctly, the terminal will display a list of the resources being created and their parameters. If the configuration contains any errors, Terraform will point them out.

    3. Deploy the cloud resources.

      1. If the configuration does not contain any errors, run this command:

        terraform apply
        

    To assign cloud roles to the service account, use the setAccessBindings REST API method for the ServiceAccount resource or the ServiceAccountService/SetAccessBindings gRPC API call.

Deploy your resourcesDeploy your resources

  1. Set up the CLI profile to perform operations under the service account:

    CLI
    1. Create an authorized key for the service account and save it to the file:

      yc iam key create \
        --service-account-id <service_account_ID> \
        --folder-id <folder_ID> \
        --output key.json
      

      Where:

      • --service-account-id: sa-live-debug service account ID.
      • --folder-id: ID of the service account folder.
      • --output: Name of the file with the authorized key.

      Result:

      id: aje8nn871qo4********
      service_account_id: ajehr0to1g8********
      created_at: "2023-03-04T09:16:43.479156798Z"
      key_algorithm: RSA_2048
      
    2. Create a CLI profile to perform operations under the service account:

      yc config profile create sa-live-debug
      

      Result:

      Profile 'sa-live-debug' created and activated
      
    3. Set the profile configuration:

      yc config set service-account-key key.json
      yc config set cloud-id <cloud_ID>
      

      Where:

      • service-account-key: File with the service account authorized key.
      • cloud-id: Cloud ID.
    4. Add the credentials to the environment variables:

      export YC_TOKEN=$(yc iam create-token)
      export YC_CLOUD_ID=$(yc config get cloud-id)
      
  2. Deploy the resources in the cloud by running this command:

    npx serverless-live-debug deploy
    

    As a result, the command will create a folder named live-debug in the cloud and deploy all the required resources there.

Run the debugging serviceRun the debugging service

  1. In the live-debug-test folder, create a file named live-debug.config.ts:

    nano live-debug.config.ts
    
  2. Copy the code with the following configuration to the live-debug.config.ts file:

    import { defineConfig } from '@yandex-cloud/serverless-live-debug';
    import { Handler } from '@yandex-cloud/function-types';
    
    export default defineConfig({
      handler: <Handler.Http>(event => {
        console.log('got request', event);
        return {
          statusCode: 200,
          body: `Hello from local code!`,
        };
      })
    });
    
  3. Start the debugging service by running the following command:

    npx serverless-live-debug run
    

    Result:

    Using config: live-debug.config.ts
    Running local client...
    Starting child...
    Child started
    Watching changes in: live-debug.config.ts
    WS connection opened
    Local client ready.
    Check url: https://d5dm1lba80md********.i9******.apigw.yandexcloud.net
    Waiting requests...
    

    Where Check url is the public address of the API gateway in API Gateway.

  4. Make sure the debug code is working properly. To do this, open another terminal and run this command:

    curl https://d5dm1lba80md********.i9******.apigw.yandexcloud.net
    

    Result:

    Hello from local code!
    

For more information about usage examples, see the yc-serverless-live-debug repository.

How to delete the resources you createdHow to delete the resources you created

Delete the folder with the resources required for interactive debugging of Cloud Functions functions:

Management console
API
  1. In the management console, select live-debug.
  2. Click next to the folder and select Delete.
  3. In the Folder deletion period field, select Delete now.
  4. Click Delete.

To delete a folder, use the delete REST API method for the Folder resource or the FolderService/Delete gRPC API call.

Was the article helpful?

Previous
Canary release of a Cloud Functions function
Next
Creating a Node.js function using TypeScript
Yandex project
© 2025 Yandex.Cloud LLC