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 Serverless Containers
  • Comparison with other Yandex Cloud services
    • All guides
    • Getting an IAM token for a service account using a container
      • Making a revision active
      • Changing the container operation mode
      • Adding environment variables
      • Specifying a cloud network
      • Transferring Yandex Lockbox secrets
        • Adding a label
        • Updating a label
        • Deleting a label
      • Viewing monitoring charts
      • Migration to the ru-central1-d availability zone
      • Deleting a container
    • Viewing operations with service resources
  • Access management
  • Pricing policy
  • Terraform reference
  • Audit Trails events
  • Release notes
  • FAQ
  1. Step-by-step guides
  2. Managing a container
  3. Managing labels
  4. Adding a label

Adding a container label

Written by
Yandex Cloud
Updated at May 5, 2025
CLI
Terraform
API

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 add a label to a container, run this command:

yc serverless container add-labels <container_name> --labels <key>=<value>

Result:

id: flh7r96juaqq********
folder_id: aoek6qrs8tjh********
created_at: "2021-08-17T07:53:10.219Z"
name: my-beta-container
description: my beta container description
labels:
  label: test
url: https://flh7r96juaqq********.containers.yandexcloud.net/
status: ACTIVE

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 add a label to a container created using Terraform:

  1. Open the Terraform configuration file and add the labels section to the yandex_serverless_container resource:

    ...
    resource "yandex_serverless_container" "test-container" {
      name   = "my first container with description"
      memory = 256
      image {
         url = "cr.yandex/yc/test-image:v1"
      }
      labels = {
         label1 = "test"
      }
    }
    ...
    

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

  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 verify that you have created the container labels using the CLI:

yc serverless container get <container_name_or_ID>

To add a container label, use the update REST API method for the Container resource or the ContainerService/Update gRPC API call.

Was the article helpful?

Previous
Mounting an ephemeral disk
Next
Updating a label
Yandex project
© 2025 Yandex.Cloud LLC