NewCompare CPU & GPU pricing across AWS, Azure & GCP
Pulumi

Data Sources

Look up existing DevZero resources by name without managing them with Pulumi.

Data Sources

Data sources let you look up existing DevZero resources that were not created by Pulumi — for example, clusters registered manually via the DevZero dashboard or CLI. Use them to retrieve IDs you need to attach policies or pass into other resources.

getClusterIdByName

Looks up an existing cluster by name and returns its ID. This is useful when a cluster was registered outside of Pulumi and you need its ID to attach a WorkloadPolicyTarget or inject it into a Kubernetes secret / values.yaml.

Example

import * as pulumi from "@pulumi/pulumi";
import { resources } from "@devzero/pulumi-devzero";

// Look up a manually registered cluster by name
const existing = await resources.getClusterIdByName({
    name: "my-existing-cluster",
    // teamId is optional — defaults to devzero:teamId from provider config
});

// Attach a workload policy to the existing cluster
const target = new resources.WorkloadPolicyTarget("my-target", {
    name: "my-target",
    policyId: policy.id,
    clusterIds: [existing.clusterId],
    kindFilter: ["Deployment"],
    enabled: true,
});

export const existingClusterId = existing.clusterId;
import pulumi
from pulumi_devzero import resources

# Look up a manually registered cluster by name
existing = resources.get_cluster_id_by_name(
    name="my-existing-cluster",
    # team_id is optional — defaults to devzero:teamId from provider config
)

# Attach a workload policy to the existing cluster
target = resources.WorkloadPolicyTarget("my-target",
    args=resources.WorkloadPolicyTargetArgs(
        name="my-target",
        policy_id=policy.id,
        cluster_ids=[existing.cluster_id],
        kind_filter=["Deployment"],
        enabled=True,
    )
)

pulumi.export("existing_cluster_id", existing.cluster_id)
package main

import (
    "github.com/devzero-inc/pulumi-provider-devzero/sdk/go/devzero/resources"
    "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        // Look up a manually registered cluster by name
        existing, err := resources.GetClusterIdByName(ctx, &resources.GetClusterIdByNameArgs{
            Name: "my-existing-cluster",
            // TeamId is optional — defaults to devzero:teamId from provider config
        })
        if err != nil {
            return err
        }

        // Attach a workload policy to the existing cluster
        _, err = resources.NewWorkloadPolicyTarget(ctx, "my-target", &resources.WorkloadPolicyTargetArgs{
            Name:       pulumi.String("my-target"),
            PolicyId:   policy.ID(),
            ClusterIds: pulumi.StringArray{pulumi.String(existing.ClusterId)},
            KindFilter: pulumi.StringArray{pulumi.String("Deployment")},
            Enabled:    pulumi.BoolPtr(true),
        })
        if err != nil {
            return err
        }

        ctx.Export("existingClusterId", pulumi.String(existing.ClusterId))
        return nil
    })
}

Inputs

FieldTypeRequiredDescription
namestringYesName of the cluster to look up
teamIdstringNoTeam to search within. Defaults to devzero:teamId from provider config

Python uses snake_case: team_id. Go uses PascalCase: TeamId.

Outputs

FieldTypeDescription
clusterIdstringUUID of the matching cluster

Python: cluster_id. Go: ClusterId.

Warning: If multiple clusters share the same name, only the first active (non-deleted) one is returned. Ensure cluster names are unique within your team to avoid unexpected results.

On this page