Deploy Targets
Deploy target resources manage the Kubernetes clusters registered in Lagoon and the per-project routing rules that determine which branches deploy to which cluster.
DeployTarget
A DeployTarget represents a Kubernetes cluster registered in Lagoon. Each deploy target is available as a destination for project deployments.
Properties
| Property | Type | Required | Description |
|---|---|---|---|
name |
string | Yes | Deploy target name |
consoleUrl |
string | Yes | Kubernetes API console URL |
cloudProvider |
string | No | Cloud provider (e.g., kind, aws, gcp). Defaults to kind |
cloudRegion |
string | No | Cloud region (e.g., us-east-1, local). Defaults to local |
buildImage |
string | No | Custom build image |
disabled |
bool | No | Whether the deploy target is disabled |
routerPattern |
string | No | URL template for autogenerated routes, e.g. ${environment}.${project}.example.com |
sshHost |
string | No | SSH gateway host for this cluster |
sshPort |
string | No | SSH gateway port for this cluster |
Outputs
| Output | Type | Description |
|---|---|---|
lagoonId |
int | Lagoon internal deploy target ID |
created |
string | Creation timestamp |
Import
Import using the numeric Lagoon deploy target ID:
pulumi import lagoon:lagoon:DeployTarget production-cluster 1
Examples
import pulumi
import pulumi_lagoon as lagoon
production_cluster = lagoon.DeployTarget("production-cluster",
lagoon.DeployTargetArgs(
name="production",
console_url="https://api.k8s.production.example.com",
cloud_provider="aws",
router_pattern="${environment}.${project}.production.example.com",
ssh_host="ssh.production.example.com",
ssh_port="22",
)
)
staging_cluster = lagoon.DeployTarget("staging-cluster",
lagoon.DeployTargetArgs(
name="staging",
console_url="https://api.k8s.staging.example.com",
cloud_provider="aws",
router_pattern="${environment}.${project}.staging.example.com",
ssh_host="ssh.staging.example.com",
ssh_port="22",
)
)
pulumi.export("production_target_id", production_cluster.lagoon_id)
pulumi.export("staging_target_id", staging_cluster.lagoon_id)
import * as pulumi from "@pulumi/pulumi";
import * as lagoon from "@tag1consulting/pulumi-lagoon";
const productionCluster = new lagoon.DeployTarget("production-cluster", {
name: "production",
consoleUrl: "https://api.k8s.production.example.com",
cloudProvider: "aws",
routerPattern: "${environment}.${project}.production.example.com",
sshHost: "ssh.production.example.com",
sshPort: "22",
});
export const productionTargetId = productionCluster.lagoonId;
package main
import (
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
lagoon "github.com/tag1consulting/pulumi-lagoon-provider/sdk/go/lagoon/lagoon"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
productionCluster, err := lagoon.NewDeployTarget(ctx, "production-cluster", &lagoon.DeployTargetArgs{
Name: pulumi.String("production"),
ConsoleUrl: pulumi.String("https://api.k8s.production.example.com"),
CloudProvider: pulumi.String("aws"),
RouterPattern: pulumi.String("${environment}.${project}.production.example.com"),
SshHost: pulumi.String("ssh.production.example.com"),
SshPort: pulumi.String("22"),
})
if err != nil {
return err
}
ctx.Export("productionTargetId", productionCluster.LagoonId)
return nil
})
}
using Pulumi;
using Tag1Consulting.Lagoon.Lagoon;
return await Deployment.RunAsync(() =>
{
var productionCluster = new DeployTarget("production-cluster", new DeployTargetArgs
{
Name = "production",
ConsoleUrl = "https://api.k8s.production.example.com",
CloudProvider = "aws",
RouterPattern = "${environment}.${project}.production.example.com",
SshHost = "ssh.production.example.com",
SshPort = "22",
});
return new Dictionary<string, object?>
{
["productionTargetId"] = productionCluster.LagoonId,
};
});
DeployTargetConfig
A DeployTargetConfig routes branches (or pull requests) matching a pattern to a specific deploy target. This allows a single project to deploy production branches to one cluster and development branches to another.
Properties
| Property | Type | Required | Description |
|---|---|---|---|
projectId |
int | Yes | Project ID to configure routing for |
deployTargetId |
int | Yes | Target cluster ID to route matching deployments to |
branches |
string | No | Branch regex pattern — matching branches are routed to this target |
pullrequests |
string | No | Pull request pattern — matching PRs are routed to this target |
weight |
int | No | Routing weight (higher value = higher priority when multiple configs match) |
deployTargetProjectPattern |
string | No | Optional namespace pattern |
Outputs
| Output | Type | Description |
|---|---|---|
lagoonId |
int | Lagoon internal deploy target config ID |
Import
Import using the project ID and config ID, separated by a colon:
pulumi import lagoon:lagoon:DeployTargetConfig prod-routing 123:456
Example: Multi-cluster Routing
This example routes the main branch to a production cluster and all other branches to a staging cluster:
import pulumi
import pulumi_lagoon as lagoon
# Route the main branch to production
prod_routing = lagoon.DeployTargetConfig("prod-routing",
lagoon.DeployTargetConfigArgs(
project_id=123,
deploy_target_id=1, # production cluster ID
branches="^main$",
weight=100,
)
)
# Route all other branches to staging
dev_routing = lagoon.DeployTargetConfig("dev-routing",
lagoon.DeployTargetConfigArgs(
project_id=123,
deploy_target_id=2, # staging cluster ID
branches="^(?!main$).*",
pullrequests="true",
weight=10,
)
)