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 Lockbox
  • Getting started
    • All guides
    • Creating secrets
    • Updating a secret
    • Configuring access to a secret
    • Getting information about a secret
    • Deleting a secret
    • Deactivating and activating a secret
    • Secret version management
      • Transmitting a secret to Yandex Serverless Containers
      • Transmitting a secret to Yandex Cloud Functions
    • Viewing operations with a secret
  • Quotas and limits
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes
  • FAQ
  1. Step-by-step guides
  2. Serverless
  3. Transmitting a secret to Yandex Serverless Containers

Transmitting a secret to Yandex Serverless Containers

Written by
Yandex Cloud
Updated at July 29, 2025

Note

This feature is in the Preview stage.

To provide the container with access to the secret, specify a service account with the following roles in the container parameters:

  • lockbox.payloadViewer to access the secret (see Granting permissions to access a secret).
  • kms.keys.encrypterDecrypter to access the encryption key if the secret was created using a Yandex Key Management Service key (see Granting permissions to access an encryption key).

A Lockbox secret transmitted to a container is cached in Serverless Containers. As soon as the service account can no longer access the secret, the container may store it for up to 5 minutes.

A new revision of a container is created when Yandex Lockbox secrets are transmitted. You cannot transmit secrets to an existing revision.

Management console
CLI
Terraform
API
  1. In the management console, go to the folder with your container.

  2. Open Serverless Containers.

  3. Select a container you want to transmit a secret to.

  4. Go to the Editor tab.

  5. In the window that opens, under Image settings, in the Lockbox secrets field, specify:

    • Name of the environment variable to store the secret.
    • Secret ID.
    • Secret version ID.
    • Key of one of the key-value pairs in the secret version.
  6. Click Add.

    You can transmit multiple secrets to a container. To do this, click Add.

  7. Click Create revision. A new container revision with the specified secrets will be created.

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 transmit Yandex Lockbox secrets to a container, run this command:

Warning

If the secrets were already sent to the previous revision, they will be overwritten.

yc serverless container revision deploy \
   --container-name test \
   --image cr.yandex/<registry_ID>/repository:tag \
   --cores 1 \
   --memory 1GB \
   --service-account-id <service_account_ID> \
   --secret environment-variable=<environment_variable_name>,id=<secret_ID>,version-id=<secret_version_ID>,key=<secret_key>

Where:

  • --container-name: Container name.

  • --image: Docker image URL.

  • --cores: Number of cores available to the container.

  • --memory: Required memory. The default value is 128 MB.

  • --service-account-id: ID of the service account with the lockbox.payloadViewer role.

  • --secret:

    • environment-variable: Name of the environment variable that will store the secret.
    • id: Secret ID.
    • version-id: Secret version ID.
    • key: Key of one of the key-value pairs in the secret version.

    You can transmit multiple secrets to a container. To do this, specify the --secret parameter as many times as needed.

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

  1. Open the Terraform configuration file and add the secrets section to the function description:

    resource "yandex_serverless_container" "test-container" {
      name               = "<container_name>"
      memory             = <memory_size>
      service_account_id = "<service_account_ID>"
      secrets {
        id                   = "<secret_ID>"
        version_id           = "secret_version_ID>"
        key                  = "<secret_1_key>"
        environment_variable = "<environment_variable_1_name>"
      }
      secrets {
        id                   = "<secret_ID>"
        version_id           = "<secret_version_ID>"
        key                  = "<secret_2_key>"
        environment_variable = "<environment_variable_2_name>"
      }
      image {
        url = "<Docker_image_URL>"
      }
    }
    

    Where:

    • secrets: Section with secret settings. It contains the following parameters:
      • id: Secret ID. This is a required parameter.
      • version_id: Secret version ID. This is a required parameter.
      • key: Key of one of the secret version's key-value pairs that will be stored in the environment variable. This is a required parameter.
      • environment_variable: Name of the environment variable that will store the secret. This is a required parameter.

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

  2. Apply the changes:

    1. In the terminal, go to the directory where you edited the configuration file.

    2. Make sure the configuration file is correct 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
      

      You will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.

    4. Apply the changes:

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

You can check the function's update settings in the management console.

To transmit a Yandex Lockbox secret to a container, use the deployRevision REST API method for the Container resource or the ContainerService/DeployRevision gRPC API call.

Was the article helpful?

Previous
Secret version management
Next
Transmitting a secret to Yandex Cloud Functions
© 2025 Direct Cursus Technology L.L.C.