New to Kestra?
Use blueprints to kickstart your first workflows.
Run the Aiven CLI on a schedule with Kestra to power services and databases off at night and on in the morning, cutting Aiven cloud costs automatically.
id: manage-aiven-resources-from-cli
namespace: company.team
tasks:
- id: cli
type: io.kestra.plugin.scripts.python.Commands
taskRunner:
type: io.kestra.plugin.scripts.runner.docker.Docker
containerImage: python:slim
dependencies:
- aiven-client
commands:
- avn --auth-token $AVN_AUTH_TOKEN project list
- avn --auth-token $AVN_AUTH_TOKEN service update YOUR-SERVICE-NAME
--power-off
- avn --auth-token $AVN_AUTH_TOKEN service update YOUR-SERVICE-NAME
--power-on
env:
AVN_AUTH_TOKEN: "{{ secret('AVN_AUTH_TOKEN') }}"
triggers:
- id: every_morning
type: io.kestra.plugin.core.trigger.Schedule
cron: 0 9 * * *
Run the Aiven command line client (avn) on a schedule with Kestra to manage your Aiven cloud services and databases as code. This blueprint lists your Aiven projects to confirm authentication, then powers a managed service off and back on, so idle PostgreSQL, Kafka, OpenSearch, Redis, or ClickHouse services stop billing overnight or on weekends and resume before your team needs them. It is the cost-optimization automation Aiven's console alone cannot run unattended.
cli task of type io.kestra.plugin.scripts.python.Commands runs on a python:slim container through the io.kestra.plugin.scripts.runner.docker.Docker task runner.aiven-client pip dependency, so the avn binary is installed at runtime with no custom image to maintain.avn commands run in sequence: project list to validate the token, then service update YOUR-SERVICE-NAME --power-off and service update YOUR-SERVICE-NAME --power-on.AVN_AUTH_TOKEN environment variable is populated from {{ secret('AVN_AUTH_TOKEN') }} and passed to every command, so the token never appears in plaintext.io.kestra.plugin.core.trigger.Schedule trigger named every_morning fires the flow daily at 0 9 * * *.Aiven's own console has no built-in scheduler to power services off and on around your team's hours. Kestra adds a declarative YAML Schedule trigger, automatic retries on transient CLI failures, full execution logs and lineage for every power cycle, and the ability to chain Aiven actions with the rest of your pipeline (for example, run a backup before power-off). You manage the whole lifecycle as code instead of clicking through a dashboard.
AVN_AUTH_TOKEN: an Aiven authentication token with permission to list projects and update services.AVN_AUTH_TOKEN secret in your Kestra instance.YOUR-SERVICE-NAME in the --power-off and --power-on commands with your real Aiven service name.project list succeeds.every_morning cron to match your desired schedule and enable the trigger.service update for service create, service terminate, or service database-create to provision or tear down resources on demand.inputs to reuse the same flow across many services.io.kestra.plugin.core.flow.ForEach to manage a whole fleet.