Yandex Cloud
Search
Contact UsGet started
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • AI for business
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Yandex API Gateway
  • Getting started
    • All guides
    • Creating an API gateway
      • Updating API gateways and their specifications
      • Adding a domain
      • Specifying a cloud network
      • Setting up variables
      • Setting up a canary release
      • Viewing monitoring charts
      • Removing a domain
      • Migration to the ru-central1-d availability zone
      • Deleting an API gateway
    • Viewing operations with service resources
  • Access management
  • Tools
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Public materials
  • Release notes
  • FAQ
  1. Step-by-step guides
  2. Managing an API gateway
  3. Setting up variables

Setting up variables

Written by
Yandex Cloud
Updated at July 14, 2025

API Gateway supports variables in the OpenAPI specification.

Example of a specification file with a variable
openapi: 3.0.0
info:
  title: Sample API
  version: 1.0.0

x-yc-apigateway:
  variables:
    environment:
      default: "prod"
      enum:
        - "prod"
        - "testing"
        - "dev"
      description: "API Gateway installation."

paths:
  /env/info:
    get:
      x-yc-apigateway-integration:
        type: dummy
        content:
          '*': It is ${var.environment} environment!
        http_code: 200
        http_headers:
          Content-Type: text/plain

By default, variables take the values specified in the default field of the OpenAPI specification. You can override them by providing other values when setting up your API gateway:

Management console
CLI
Terraform
API
  1. In the management console, go to the folder where you want to update an API gateway.
  2. In the list of services, select API Gateway.
  3. In the API gateway row, click and select Edit.
  4. Under Variable settings, list all the variables declared in the specification and their values.
  5. Click Save.

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

By default, the CLI uses the folder specified when creating the profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id parameter.

To set up your variables:

  1. Edit the OpenAPI specification file or create a new one, if required.

  2. View the description of the CLI command for updating an API gateway:

    yc serverless api-gateway update --help
    
  3. Specify the API gateway ID or name in the command and list all the variables declared in the specification as key=value:

    yc serverless api-gateway update \
      --id <API_gateway_ID> \
      --variables <list_of_variables>
    

With Terraform, you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.

Terraform is distributed under the Business Source License. The Yandex Cloud provider for Terraform is distributed under the MPL-2.0 license.

For more information about the provider resources, see the relevant documentation on the Terraform website or its mirror.

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

To provide the values of the variables declared in the API gateway specification:

  1. Open the Terraform configuration file and add the variables section to it:

    resource "yandex_api_gateway" "<API_gateway_name>" {
      ...
      variables = {
        <list_of_variables>
      }
      ...
    }
    

    List the variables in key = value format, such as:

    resource "yandex_api_gateway" "<API_gateway_name>" {
      ...
      variables = {
        environment = "testing"
      }
      ...
    }
    
  2. Check the configuration using this command:

    terraform validate
    

    If the configuration is correct, you will get this message:

    Success! The configuration is valid.
    
  3. Run this command:

    terraform plan
    

    The terminal will display a list of resources with their properties. No changes will be made at this step. If the configuration contains any errors, Terraform will point them out.

  4. Apply the changes:

    terraform apply
    
  5. Type yes and press Enter to confirm the changes.

    You can check the API gateway update using the management console or this CLI command:

    yc serverless api-gateway get <API_gateway_name>
    

To set up variables for an API gateway specification, use the update REST API method for the ApiGateway resource or the ApiGatewayService/Update gRPC API call.

See alsoSee also

  • How specification parameterization works
  • How to update an API gateway specification

Was the article helpful?

Previous
Specifying a cloud network
Next
Setting up a canary release
© 2025 Direct Cursus Technology L.L.C.