Use Terraform to provision, manage, and automate changes to Kestra resources.

Overview

The official Kestra Terraform Provider lets you manage Kestra resources as code.
You can define flows, templates, and namespaces declaratively — Terraform will handle creation, updates, and deletions automatically.


Multitenancy

The Kestra Terraform provider supports multitenancy, allowing you to manage resources across multiple tenants from a single configuration.
When configuring the provider, include the tenant_id parameter to specify the tenant you want to target.

hcl
provider "kestra" {
  tenant_id = "kestra-tech"
  url       = "http://your-kestra-url:8080"
}

Example configuration

Start by creating a Terraform configuration file — typically named provider.tf or main.tf — to set up the Kestra provider.

provider.tf

hcl
provider "kestra" {
  # Required: Kestra server URL
  url = "http://localhost:8080"

  # Required for multitenant environments
  tenant_id = "kestra-tech"

  # Optional: basic authentication
  username = "john"
  password = "my-password"

  # Optional: API token (Enterprise Edition)
  api_token = "my-api-token"

  # Optional: JWT authentication
  jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6Iktlc3RyYS5pbyIsImlhdCI6MTUxNjIzOTAyMn0.hm2VKztDJP7CUsI69Th6Y5NLEQrXx7OErLXay55GD5U"
}

version.tf

Define the provider source and version to ensure compatibility.

hcl
terraform {
  required_providers {
    kestra = {
      source  = "kestra-io/kestra"
      version = "~> 0.18.1"
    }
  }
}

flows.tf

Create a flow resource referencing a YAML file containing your flow definition.

hcl
resource "kestra_flow" "flow_example" {
  namespace = "company.team"
  flow_id   = "myflow"
  content   = file("kestra/flows/my-flow.yml")
}

templates.tf

Define a template resource. Use the depends_on attribute to ensure flows are deployed first.

hcl
resource "kestra_template" "template_example" {
  namespace   = "company.team"
  template_id = "my-template"
  content     = file("kestra/templates/my-template.yml")
  depends_on  = [kestra_flow.flow_example]
}

Next steps

Was this page helpful?