Revolutionize Your Workflow with Kestra: A 2025 Tutorial on Dynamic Inputs

Revolutionize Your Workflow with Kestra: A 2025 Tutorial on Dynamic Inputs

In the ever-evolving landscape of workflow automation, Kestra has emerged as a powerful contender, offering robust features that cater to the dynamic needs of modern businesses. This tutorial delves into one of Kestra’s most potent capabilities: the use of inputs to create flexible and reusable workflows.

Understanding Kestra Inputs

Inputs in Kestra allow you to parameterize your workflows, making them adaptable to various scenarios without the need for constant rewrites. This feature is crucial for teams looking to streamline their processes and reduce redundancy in their automation efforts.

Types of Inputs

Kestra supports several input types, including:

  • Strings
  • Integers
  • Booleans
  • Arrays
  • Objects

Each type serves a specific purpose, allowing you to fine-tune your workflows to handle different data structures and requirements.

Implementing Inputs in Your Workflow

To illustrate the power of inputs, let’s walk through a simple example:

id: input_example
namespace: my_project
inputs:
  - name: user
    type: string
    required: true
    default: 'World'

tasks:
  - id: greet
    type: io.kestra.core.tasks.scripts.Bash
    script: echo "Hello, {{ inputs.user }}!"

In this example, we’ve defined an input named ‘user’ of type string. It’s set as required, but we’ve also provided a default value of ‘World’. This means if no value is provided at runtime, the workflow will use ‘World’ as the input.

Dynamic Workflow Execution

The real power of inputs shines when executing workflows. You can now run the same workflow with different parameters:

kestra run input_example -i user="Alice"
kestra run input_example -i user="Bob"

These commands will result in different outputs without any changes to the workflow definition.

Advanced Input Usage

As your workflows become more complex, you can leverage inputs in more sophisticated ways:

Conditional Execution

Use inputs to determine which tasks should run:

tasks:
  - id: conditional_task
    type: io.kestra.core.tasks.flows.Switch
    value: '{{ inputs.environment }}'
    cases:
      production:
        - id: prod_task
          type: io.kestra.core.tasks.scripts.Bash
          script: echo "Running in production"
      development:
        - id: dev_task
          type: io.kestra.core.tasks.scripts.Bash
          script: echo "Running in development"

Dynamic API Requests

Use inputs to customize API endpoints or payloads:

tasks:
  - id: api_request
    type: io.kestra.core.tasks.scripts.Http
    uri: '{{ inputs.api_url }}'
    method: POST
    body: '{{ inputs.payload | json_encode }}'

Best Practices for Input Management

  1. Document Your Inputs: Clearly describe each input’s purpose and expected values in your workflow documentation.
  2. Use Sensible Defaults: Provide default values where appropriate to make your workflows more user-friendly.
  3. Validate Inputs: Implement input validation to ensure your workflows receive the correct data types and values.
  4. Version Your Workflows: As you modify inputs, maintain version control to track changes and ensure backward compatibility.

Conclusion

Mastering Kestra’s input system opens up a world of possibilities for creating flexible, reusable workflows. By parameterizing your processes, you can build a library of versatile automations that adapt to your organization’s evolving needs. As we move further into 2025, the ability to create dynamic, input-driven workflows will become increasingly crucial for businesses looking to stay agile and efficient in a rapidly changing technological landscape.

Remember, the key to successful workflow automation lies not just in the tools you use, but in how creatively and effectively you apply them. With Kestra’s input system, you’re well-equipped to tackle the complex automation challenges of today and tomorrow.


References: