> For the complete documentation index, see [llms.txt](https://docs.verge.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.verge.io/knowledge-base/zh/automation-api/terraform-vergeio-provider.md).

# Terraform VergeIO 提供程序

该 **Terraform VergeIO 提供程序** 可实现 VergeOS 基础设施与 **Terraform**的集成和自动化。它允许用户将 VergeOS 资源定义、管理和扩展，作为基础设施即代码（IaC）工作流的一部分。

有关最新的提供程序文档和示例，请参阅以下内容：

* [GitHub 仓库](https://github.com/verge-io/terraform-provider-vergeio) 适用于 VergeIO Terraform 提供程序。
* [Terraform Registry 文档](https://registry.terraform.io/providers/verge-io/vergeio/latest) 用于官方用法和更新。

***

## 示例用法

如需更详细的使用示例，请查看 [docs 文件夹](https://github.com/verge-io/terraform-provider-vergeio/tree/main/docs) 在 GitHub 仓库中。

### 示例配置

```hcl
provider "vergeio" {
  host     = "https://some_url_or_ip"
  username = "my_user"
  password = "my_password"
  insecure = false  # 如果使用自签名 SSL 证书，则使用 true
}

resource "vergeio_vm" "new_vm" {
  name        = "NEW VM"
  description = "NEW TF VM"
  enabled     = true
  os_family   = "linux"
  cpu_cores   = 4
  machine_type = "q35"
  ram         = 8192
}
```

### 初始化并应用

要应用该配置：

```bash
terraform init && terraform apply
```

配置参考

```
host（必填）：VergeOS 系统或租户的 URL 或 IP 地址。
username（必填）：VergeOS 系统或租户的用户名。
password（必填）：所提供用户名的密码。
insecure（可选）：对于使用自签名 SSL 证书的系统，请设为 true。
```

### 资源

以下 VergeOS 资源可以通过 Terraform 进行管理：

```
vergeio_drive
vergeio_member
vergeio_network
vergeio_nic
vergeio_user
vergeio_vm
```

### 数据源

以下数据源可用于查询 VergeOS 资源：

```
vergeio_clusters
vergeio_groups
vergeio_mediasources
vergeio_networks
vergeio_nodes
vergeio_version
vergeio_vms
```

## 测试示例配置

要测试您的配置，请在 Terraform 工作区中创建一个 main.tf 文件：

```hcl

terraform {
  required_providers {
    vergeio = {
      source = "vergeio/cloud/vergeio"
    }
  }
}

provider "vergeio" {
  host     = "https://someURLorIP"
  username = "username"
  password = "password"
}

resource "vergeio_vm" "new_vm" {
  name        = "NEW VM"
  description = "NEW TF VM"
  enabled     = true
  os_family   = "linux"
  cpu_cores   = 4
  machine_type = "q35"
  ram         = 8192
}
```

然后，运行以下命令：

```bash

terraform init && terraform apply
```

***

{% hint style="info" %}
**文档信息**

* 最后更新：2024-09-03
* VergeOS 版本：4.12.6
  {% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.verge.io/knowledge-base/zh/automation-api/terraform-vergeio-provider.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
