Import ID Reference

Use pulumi import to bring existing Lagoon resources under Pulumi management without recreating them.

Syntax

pulumi import <resource-type> <resource-name> <import-id>
  • <resource-type> — the fully-qualified Pulumi type token (e.g., lagoon:lagoon:Project)
  • <resource-name> — the logical name to assign in your Pulumi program
  • <import-id> — the resource-specific ID described in the table below

Import ID Formats

Resource Import ID Format Example
lagoon:lagoon:Project {numeric_id} 123
lagoon:lagoon:DeployTarget {numeric_id} 1
lagoon:lagoon:DeployTargetConfig {project_id}:{config_id} 123:5
lagoon:lagoon:Environment {project_id}:{env_name} 123:main
lagoon:lagoon:Variable (environment-level) {project_id}:{env_id}:{var_name} 123:456:DATABASE_HOST
lagoon:lagoon:Variable (project-level) {project_id}::{var_name} 123::API_KEY
lagoon:lagoon:NotificationSlack {name} deploy-alerts
lagoon:lagoon:NotificationRocketChat {name} deploy-alerts
lagoon:lagoon:NotificationEmail {name} deploy-alerts
lagoon:lagoon:NotificationMicrosoftTeams {name} deploy-alerts
lagoon:lagoon:ProjectNotification {project_name}:{type}:{notification_name} my-project:slack:deploy-alerts
lagoon:lagoon:Task {numeric_id} 456
lagoon:lagoon:Group {name} my-team
lagoon:lagoon:Route {project_name}:{domain} my-project:example.com
lagoon:lagoon:ProjectAutogeneratedRouteConfig {project_name} my-project
lagoon:lagoon:EnvironmentAutogeneratedRouteConfig {project_name}:{env_name} my-project:main
lagoon:lagoon:User {email} user@example.com
lagoon:lagoon:UserGroupAssignment {email}:{group_name} user@example.com:my-team
lagoon:lagoon:UserPlatformRole {email}:{role} user@example.com:OWNER

Import IDs are case-sensitive. Use the exact values from the Lagoon API or CLI — project names, environment names, notification names, and email addresses must match exactly.

Example Import Commands

Import a project by its numeric ID:

pulumi import lagoon:lagoon:Project my-site 123

Import an environment (project ID 123, branch main):

pulumi import lagoon:lagoon:Environment main-env 123:main

Import a project-level variable (double colon, no environment ID):

pulumi import lagoon:lagoon:Variable api-key 123::EXTERNAL_API_KEY

Import a ProjectNotification:

pulumi import lagoon:lagoon:ProjectNotification project-slack my-site:slack:deploy-alerts

Finding Resource IDs

Use the Lagoon CLI to discover numeric IDs before running pulumi import. See the Lagoon CLI Setup guide for installation and authentication.

# Find a project's numeric ID
lagoon list projects

# Find an environment's numeric ID (needed for variable imports)
lagoon list environments --project my-site

# Find deploy target IDs
lagoon list deploy-targets

# Find notification names
lagoon get project-notifications --project my-site

# Find a user's internal Lagoon ID
lagoon get user --email user@example.com

After Importing

After running pulumi import, add the matching resource declaration to your Pulumi program. The import command generates a code snippet in the target language that you can paste directly. Run pulumi preview to confirm there are no unexpected diffs between the imported state and your code.

If pulumi preview shows changes after import, your code does not exactly match the values Lagoon returned. Common causes are optional fields with API defaults (e.g., branches, pullrequests on a project) or fields the provider does not manage. Align your code to the imported state before running pulumi up.