Adding a trigger label in Cloud Functions
If you do not have the Yandex Cloud command line interface yet, install and initialize it.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
To add a label to a trigger, run the command:
yc serverless trigger add-labels <trigger_name> --labels <key>=<value>
Result:
id: a1s9q2li6t**********
folder_id: b1g9hv2loa**********
created_at: "2023-08-01T12:36:14.321Z"
name: my-trigger
description: Trigger for uploaded objects
labels:
version: beta
rule:
object_storage:
event_type:
- OBJECT_STORAGE_EVENT_TYPE_CREATE_OBJECT
bucket_id: **********
batch_settings:
size: "10"
cutoff: 10s
invoke_function:
function_id: d4e5muirrt**********
function_tag: $latest
service_account_id: ajek0fou8e**********
status: ACTIVE
For more information about Terraform, see the documentation.
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the documentation on the Terraform
To add a trigger label:
-
Open the Terraform configuration file and add the
labels
section to the trigger description:... resource "yandex_function_trigger" "my_trigger" { name = "some_name" labels = { tf-label = "tf-label-value" empty-label = "" } description = "any description" timer { cron_expression = "* * * * ? *" } function { id = "tf-test" } } ...
For more information about the
yandex_function_trigger
resource parameters in Terraform, see the provider documentation . -
Check the configuration using this command:
terraform validate
If the configuration is correct, you will get this message:
Success! The configuration is valid.
-
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.
-
Apply the configuration changes:
terraform apply
-
Confirm the changes: type
yes
into the terminal and press Enter.You can check the trigger update using this CLI command:
yc serverless trigger get <trigger_ID>
To add a trigger label, use the update REST API method for the Trigger resource or the TriggerService/Update gRPC API call.