๐Ÿ“ฆ japerry911 / pulumi-kestra-example

๐Ÿ“„ flow.py ยท 33 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33import pulumi
import pulumi_kestra as kestra
from pathlib import Path


def create_flow(provider: kestra.Provider, namespace: kestra.Namespace) -> kestra.Flow:
    """Create the main greeting flow and language-specific flows.

    Args:
        provider: Kestra provider resource
        namespace: Kestra Namespace resource (has .namespace_id)

    Returns:
        The main greeting Flow resource
    """
    # Load the flow source from a YAML file next to this module.
    # File path: kestra_pulumi_example/flows/utils/upload_file_to_gcs_app/flow.yaml
    yaml_path = Path(__file__).parent / "flow.yaml"
    if not yaml_path.exists():
        raise FileNotFoundError(f"Flow YAML file not found: {yaml_path}")
    flow_source = yaml_path.read_text(encoding="utf-8")

    # Create the flow; it depends on the namespace and uses the provider
    flow = kestra.Flow(
        resource_name="upload_file_to_gcs_flow",
        namespace=namespace.namespace_id,
        flow_id="upload_file_to_gcs",
        content=flow_source,
        opts=pulumi.ResourceOptions(provider=provider, depends_on=namespace),
    )

    return flow