wihan/dev

docs /dokploy / resources

markdown
browse the dokploy docs

dokploy_environment (Resource)

An environment inside a Dokploy project. Services (dokploy_application, dokploy_postgres) belong to an environment rather than directly to a project. Dokploy creates a production environment with every project, which cannot be deleted — see is_default.

Example Usage

resource "dokploy_project" "example" {
  name = "example"
}

# Dokploy creates a "production" environment with every project; this adds a
# second one alongside it.
resource "dokploy_environment" "staging" {
  project_id  = dokploy_project.example.id
  name        = "staging"
  description = "Pre-production environment"

  # Shared by every service in this environment.
  env = <<-EOT
    LOG_LEVEL=debug
    FEATURE_FLAGS=beta
  EOT
}

Schema

Required

  • name (String) Environment name. Dokploy does not enforce uniqueness within a project, so two environments may share a name.
  • project_id (String) Id of the project this environment belongs to. Changing it replaces the environment: Dokploy has no endpoint that moves one between projects.

Optional

  • description (String) Free-form description. Dokploy stores a cleared description as an empty string rather than null; the provider reports both as null.
  • env (String) Environment-level variables shared by every service in this environment, as KEY=value lines. Dokploy’s create endpoint ignores this field, so setting it on a new environment costs one extra API call. Omitting this attribute and setting it to “” are indistinguishable on read — both come back null. Use omission, not “”, to clear it.

Read-Only

  • id (String) Environment id.
  • is_default (Boolean) True for the production environment Dokploy creates with each project. Dokploy refuses to delete that environment, so destroying a resource with is_default = true fails with an explanatory error.

Import

Import is supported using the following syntax:

The terraform import command can be used, for example:

# Environments are imported by their environment id.
terraform import dokploy_environment.staging Ux7kFq2mNp4RtWvYzAbCd