Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Solutions
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Cloud Functions
  • Getting started
    • Overview
    • Creating a function
      • Overview
      • Python
      • Node.js
      • PHP
      • Go
      • Bash
    • Creating a trigger
      • Overview
      • Timer
      • Trigger for Message Queue
      • Trigger for Object Storage
      • Trigger for Container Registry
      • Trigger for Cloud Logs
      • Trigger for Yandex IoT Core
  • Step-by-step instructions
    • All instructions
    • Using functions to get an IAM token for a service account
    • Managing rights to access functions
    • Managing functions
      • Creating a function
      • Managing function versions
      • Working in the code editor
      • Invoking a function
      • Updating a function
      • View monitoring charts
      • Viewing the execution log
      • Delete function
    • Managing triggers
      • Getting information about a trigger
      • Creating a timer
      • Creating a trigger for Message Queue
      • Creating a trigger for Object Storage
      • Creating a trigger for Container Registry
      • Creating a trigger for Cloud Logs
      • Creating a trigger for Yandex IoT Core
      • Updating a trigger
      • Deleting a trigger
  • Concepts
    • Overview
    • Function
    • Invoking a function
    • Runtime environment
      • Overview
      • Environment
      • Execution context
    • Builder
    • Trigger
      • Overview
      • Timer
      • Trigger for Message Queue
      • Trigger for Object Storage
      • Trigger for Container Registry
      • Trigger for Cloud Logs
      • Trigger for Yandex IoT Core
    • Dead Letter Queue
    • Log groups
    • Monitoring
    • Backups
    • Quotas and limits
  • Developing in Node.js
    • Overview
    • Managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Handling errors
    • Using the SDK
  • Developing in Python
    • Overview
    • Managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Handling errors
    • Using the SDK
  • Developing in Go
    • Overview
    • Managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Handling errors
    • Using the SDK
  • Developing in PHP
    • Overview
    • Managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Handling errors
  • Developing in Bash
    • Overview
    • Request handler
    • Logging
    • Handling errors
    • Using the SDK
  • Developing in Java
    • Overview
    • Programming model
      • Overview
      • Function interface
      • YcFunction interface
      • HttpServlet class
      • Spring Boot
    • Managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Handling errors
    • Using the SDK
  • Developing in R
    • Overview
    • Programming model
    • Managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Handling errors
  • Developing in C#
    • Overview
    • Programming model
      • Overview
      • Function interface
      • YcFunction interface
    • Managing dependencies
    • Request handler
    • Invocation context
    • Logging
    • Handling errors
    • Using the SDK
  • Use cases
    • Creating skills for Alice
  • Pricing policy
  • Access management
  • API Functions reference
    • Authentication in the API
    • gRPC
      • Overview
      • FunctionService
      • OperationService
    • REST
      • Overview
      • Function
        • Overview
        • create
        • createVersion
        • delete
        • get
        • getVersion
        • getVersionByTag
        • list
        • listAccessBindings
        • listOperations
        • listRuntimes
        • listTagHistory
        • listVersions
        • removeTag
        • setAccessBindings
        • setTag
        • update
        • updateAccessBindings
  • API Triggers reference
    • Authentication in the API
    • gRPC
      • Overview
      • TriggerService
      • OperationService
    • REST
      • Overview
      • Trigger
        • Overview
        • create
        • delete
        • get
        • list
        • listOperations
        • pause
        • resume
        • update
  • Questions and answers
  1. Getting started
  2. Creating a trigger
  3. Trigger for Container Registry

Creating a trigger for Yandex Container Registry

  • Creating a trigger
  • Checking the result
  • What's next

Create a trigger for Container Registry that will run your function when you create or delete Docker images of Yandex Container Registry or their tags.

To create a trigger, you need:

  1. Functions that the trigger will call. If you don't have a function:
    • Create a function.
    • Create a function version.
  2. Registries whose Docker image events will fire the trigger. If you don't have a registry, create one.
  3. The Dead Letter Queue where messages that the function couldn't process are moved. If you don't have a queue, create one.
  4. A service account with rights for function call. If you don't have a service account, create one.

Creating a trigger

Note

The trigger is initiated within 5 minutes of being created.

Management console
CLI
API
  1. In the management console, go to the folder where you want to create a trigger.
  2. Open Cloud Functions.
  3. Go to the Triggers tab.
  4. Click Create trigger.
  5. Under Basic parameters:
    • Enter a name and description for the trigger.
    • In the Type field, select Container Registry.
  6. Under Container Registry settings:
    • In the Registry field, select the registry where you want to create a trigger for image events.
    • In the Event types field, select the events that will fire the trigger.
    • (optional) In the Docker image name field, enter the image name for filtering.
    • (optional) In the Docker image tag field, enter the image tag for filtering.
  7. Under Function settings:
    • Select the function for the trigger to call.
    • Specify the function version tag.
    • Specify the service account to be used to call the function.
  8. Under Repeat request settings:
    • In the Interval field, specify the time after which the function will be invoked again if the current attempt fails. Acceptable values are from 10 to 60 seconds.
    • In the Number of attempts field, specify the number of invocation retries before the trigger moves a message to the Dead Letter Queue. Acceptable values are from 1 to 5.
  9. Under Dead Letter Queue settings, select the Dead Letter Queue and service account with rights to write messages to it.
  10. Click Create trigger.

If you don't 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 create a trigger, run the command:

yc serverless trigger create container-registry \
    --name <trigger name> \
    --registry-id <registry ID> \
    --events 'create-image', 'delete-image', 'create-image-tag', 'delete-image-tag' \
    --invoke-function-id <function ID> \
    --invoke-function-service-account-id <service account ID> \
    --retry-attempts 1 \
    --retry-interval 10s \
    --dlq-queue-id <Dead Letter Queue ID> \
    --dlq-service-account-id <service account ID>

where:

  • --name: Trigger name.
  • --registry-id: Registry ID.
  • --events: Events that will fire the trigger.
  • --invoke-function-id: Function ID.
  • --invoke-function-service-account-id: Service account with rights to call the function.
  • --retry-attempts: The time after which the function will be invoked again if the current attempt fails. Values can be from 10 to 60 seconds. The default is 10 seconds.
  • --retry-interval: The number of invocation retries before the trigger moves a message to the Dead Letter Queue. Values can be from 1 to 5. The default is 1.
  • --dlq-queue-id: ID of the Dead Letter Queue.
  • --dlq-service-account-id: Service account with rights to write messages to the Dead Letter Queue.

Result:

id: a1s92agr8mpgeo3kjt48
folder_id: b1g88tflru0ek1omtsu0
created_at: "2020-09-08T06:26:22.651656Z"
name: registry-trigger
rule:
  container_registry:
    event_type:
    - CONTAINER_REGISTRY_EVENT_TYPE_CREATE_IMAGE
    - CONTAINER_REGISTRY_EVENT_TYPE_DELETE_IMAGE
    - CONTAINER_REGISTRY_EVENT_TYPE_CREATE_IMAGE_TAG
    - CONTAINER_REGISTRY_EVENT_TYPE_DELETE_IMAGE_TAG
    registry_id: crtlds4tdfg12kil77sdfg345ghj
    invoke_function:
      function_id: d4eofc7n0m03lmudsk7y
      function_tag: $latest
      service_account_id: aje3932acd0c5ur7drte
      retry_settings:
        retry_attempts: "1"
        interval: 10s
      dead_letter_queue:
        queue-id: yrn:yc:ymq:ru-central1:aoek49ghmknnpj1ll45e:dlq
        service-account-id: aje3932acd0c5ur7dagp
status: ACTIVE

You can create a trigger for Container Registry using the create API method.

Checking the result

Make sure the trigger is working properly. To do this, view the function logs that show information about its invocations.

What's next

  • Read about trigger concepts.
  • Read more about the trigger for Container Registry.
  • For information about what you can do with triggers, see our step-by-step instructions.
В этой статье:
  • Creating a trigger
  • Checking the result
  • What's next
Language / Region
Careers
Privacy policy
Terms of use
Brandbook
© 2021 Yandex.Cloud LLC