# dokploy_server (Data Source)

Looks up a remote server that already exists in Dokploy (Settings > Servers), so that a service can run on it by name:

```terraform
data "dokploy_server" "worker" {
  name = "worker-1"
}

resource "dokploy_postgres" "db" {
  server_id = data.dokploy_server.worker.id
  # ...
}
```

~> Dokploy does not enforce name uniqueness. If two servers share a name, this data source fails instead of a guess. Look the record up by `id` in that case.

## Example Usage

```terraform
# Look up a remote server that already exists in Dokploy, by name.
data "dokploy_server" "worker" {
  name = "worker-1"
}

# Or by id, when the name is ambiguous or you already hold the id.
data "dokploy_server" "by_id" {
  id = "cnWbR6INlpglaAu8MML5X"
}

# The usual purpose of a lookup: run a service on a server that the Dokploy
# UI already manages.
resource "dokploy_redis" "cache" {
  name           = "cache"
  environment_id = dokploy_project.app.production_environment_id
  server_id      = data.dokploy_server.worker.id
}
```

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

### Optional

- `id` (String) Server id. Set it for a lookup by id, or leave it unset and set `name`.
- `name` (String) Display name as shown in Dokploy. Set exactly one of `id` or `name`.

### Read-Only

- `app_name` (String) Internal name that Dokploy generates for the server.
- `command` (String) Custom setup command, or null.
- `created_at` (String) Creation timestamp from the server.
- `description` (String) Free-text description, or null.
- `enable_docker_cleanup` (Boolean) Whether the daily Docker cleanup runs on the server.
- `ip_address` (String) IP address or hostname that Dokploy connects to.
- `organization_id` (String) Id of the organization that owns the server.
- `port` (Number) SSH port.
- `server_type` (String) `deploy` or `build`.
- `ssh_key_id` (String) Id of the SSH key that Dokploy authenticates with, or null.
- `status` (String) Connection status that Dokploy reports, `active` or `inactive`. It changes when Dokploy loses the SSH connection.
- `username` (String) SSH user.