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
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
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • 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 May 13, 2025

API Gateway supports variables in an OpenAPI specification.

Sample 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) command line interface 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 set up your variables:

  1. If necessary, edit the OpenAPI specification file or create a new one.

  2. View a 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 documentation on the Terraform website or mirror website.

If you do not have Terraform yet, install it and configure its 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 parameters. No changes will be made at this step. If the configuration contains any errors, Terraform will point them out.

  4. Apply the configuration changes:

    terraform apply
    
  5. Confirm the changes: type yes into the terminal and press Enter.

    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 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
Yandex project
© 2025 Yandex.Cloud LLC