# dokploy_environment (Data Source)

Look up a Dokploy environment by id, or by name within a project. The usual reason to use this is to get the id of the `production` environment Dokploy creates with every project.

## Example Usage

```terraform
# By id.
data "dokploy_environment" "by_id" {
  id = "Ux7kFq2mNp4RtWvYzAbCd"
}

# By name within a project — the usual way to reach the production
# environment Dokploy creates automatically.
data "dokploy_environment" "production" {
  project_id = dokploy_project.example.id
  name       = "production"
}

resource "dokploy_postgres" "db" {
  name              = "db"
  environment_id    = data.dokploy_environment.production.id
  database_name     = "app"
  database_user     = "app"
  database_password = var.db_password
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `id` (String) Environment id. Set either this or both `project_id` and `name`.
- `name` (String) Exact environment name, searched within `project_id`. Errors when zero or multiple environments match — Dokploy does not enforce unique names.
- `project_id` (String) Id of the project to search. Required with `name`.

### Read-Only

- `description` (String) Free-form description.
- `env` (String, Sensitive) Environment-level variables shared by every service in this environment, exactly as stored in Dokploy. Marked sensitive because it typically holds credentials that this provider did not author; it is redacted in plan output but, like all Terraform data, stored in plain text in state.
- `is_default` (Boolean) True for the `production` environment Dokploy creates with each project.