# Data Sources

### Overview

Data sources allow Terraform to query and use information about existing infrastructure that isn't managed by your current Terraform configuration. Use data sources to:

* Reference servers created outside of Terraform
* Look up information about existing resources
* Share data between separate Terraform configurations

### Available Data Sources

| Data Source                                             | Description                       |
| ------------------------------------------------------- | --------------------------------- |
| [teraswitch\_metal](/integrations/terraform/metal-1.md) | Query existing bare metal servers |

### When to Use Data Sources

#### Referencing Existing Infrastructure

Query servers that were created manually or by another team:

```hcl
data "teraswitch_metal" "legacy_db" {
  id = 12345
}

output "legacy_db_ip" {
  value = data.teraswitch_metal.legacy_db.ip_addresses
}
```

#### Cross-Configuration References

When infrastructure is split across multiple Terraform configurations, use data sources to reference resources managed elsewhere:

```hcl
# In networking configuration
output "network_id" {
  value = teraswitch_network.shared.id
}

# In application configuration
data "teraswitch_metal" "shared_server" {
  id = var.shared_server_id
}
```

#### Migration to Terraform

When gradually migrating existing infrastructure to Terraform management:

1. Use data sources to reference existing resources
2. Plan your migration incrementally
3. Import resources when ready to manage them with Terraform

{% hint style="info" %}
Data sources are read-only. To manage a resource with Terraform, use the corresponding resource type and import if needed.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.teraswitch.com/integrations/terraform/data-sources.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
