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, asKEY=valuelines. 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 theproductionenvironment Dokploy creates with each project. Dokploy refuses to delete that environment, so destroying a resource withis_default = truefails 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