Add project CLAUDE.md and rewrite README.md for current provider
Some checks failed
CI / build (push) Failing after 34s
Some checks failed
CI / build (push) Failing after 34s
- CLAUDE.md: architecture guide, conventions, type mapping quirks, build commands, and common pitfalls for AI-assisted development - README.md: full resource/data source tables, quick start guide, environment variable configuration, and usage examples Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
230
README.md
230
README.md
@@ -1,73 +1,201 @@
|
||||
# Virtfusion Terraform Provider
|
||||
# Terraform Provider for VirtFusion
|
||||
|
||||
<p style="color: red">NOTE: This is a work in progress and is not yet ready for production use.</p>
|
||||
A Terraform provider for managing [VirtFusion](https://virtfusion.com) virtualization platform resources. Automate server provisioning, user management, networking, and self-service billing through infrastructure as code.
|
||||
|
||||
## Requirements
|
||||
|
||||
## Overview
|
||||
- [Terraform](https://developer.hashicorp.com/terraform/install) >= 1.0
|
||||
- [Go](https://golang.org/doc/install) >= 1.21 (for building from source)
|
||||
- A VirtFusion control panel instance with API access
|
||||
|
||||
This is a Terraform provider for the Virtfusion API. It allows you to manage your Virtfusion resources using Terraform.
|
||||
## Installation
|
||||
|
||||
# What can I do with this provider?
|
||||
### From Release
|
||||
|
||||
Currently, you're able to manage the following resources:
|
||||
* Create and delete virtual machines
|
||||
* Create and delete SSH keys
|
||||
Download the appropriate binary from the [Releases](https://git.ezscale.cloud/EZSCALE/terraform-provider-virtfusion/releases) page and place it in your Terraform plugins directory.
|
||||
|
||||
# How do I use this provider?
|
||||
### From Source
|
||||
|
||||
Below is an example of how to use this provider to create a virtual machine and an SSH key.
|
||||
```bash
|
||||
git clone https://git.ezscale.cloud/EZSCALE/terraform-provider-virtfusion.git
|
||||
cd terraform-provider-virtfusion
|
||||
go install .
|
||||
```
|
||||
|
||||
Then configure `~/.terraformrc` for local development:
|
||||
|
||||
```hcl
|
||||
provider_installation {
|
||||
dev_overrides {
|
||||
"registry.terraform.io/EZSCALE/virtfusion" = "/path/to/your/gopath/bin"
|
||||
}
|
||||
direct {}
|
||||
}
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
```hcl
|
||||
terraform {
|
||||
required_providers {
|
||||
virtfusion = {
|
||||
source = "ezscale/virtfusion"
|
||||
version = "0.0.3"
|
||||
source = "registry.terraform.io/EZSCALE/virtfusion"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
variable "virtfusion_api_token" {
|
||||
type = string
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
provider "virtfusion" {
|
||||
endpoint = "virtfusion.example.com"
|
||||
api_token = ""
|
||||
}
|
||||
|
||||
variable "common" {
|
||||
type = map(string)
|
||||
default = {
|
||||
hypervisor_id = 1
|
||||
package_id = 12
|
||||
user_id = 1
|
||||
}
|
||||
}
|
||||
|
||||
# Create a SSH key
|
||||
resource "virtfusion_ssh" "key1" {
|
||||
name = "My Test Key"
|
||||
public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKWyBR+dk5M5MMfmH6Ss5QDSgcAvbCYu0DkqgPKH8O5T testkey@example.com"
|
||||
user_id = var.common["user_id"]
|
||||
}
|
||||
|
||||
# Create a server
|
||||
resource "virtfusion_server" "node1" {
|
||||
hypervisor_id = var.common["hypervisor_id"]
|
||||
package_id = var.common["package_id"]
|
||||
user_id = var.common["user_id"]
|
||||
}
|
||||
|
||||
# Initialize the server with the OS we want, the SSH key we want, and the hostname we want.
|
||||
resource "virtfusion_build" "node1" {
|
||||
server_id = virtfusion_server.node1.id
|
||||
name = "node1-demo"
|
||||
hostname = "node1.example.com"
|
||||
osid = 34
|
||||
vnc = true
|
||||
ipv6 = true
|
||||
ssh_keys = [virtfusion_ssh.key1.id]
|
||||
email = true
|
||||
endpoint = "https://cp.example.com"
|
||||
api_token = var.virtfusion_api_token
|
||||
}
|
||||
```
|
||||
|
||||
# How can I contribute?
|
||||
The provider can also be configured using environment variables:
|
||||
|
||||
If you'd like to contribute, please feel free to open a pull request. If you're unsure of what to work on, please check the issues tab for any open issues.
|
||||
```bash
|
||||
export VIRTFUSION_ENDPOINT="https://cp.example.com"
|
||||
export VIRTFUSION_API_TOKEN="your-api-token"
|
||||
```
|
||||
|
||||
## Usage Examples
|
||||
|
||||
### Create a user, SSH key, server, and build it
|
||||
|
||||
```hcl
|
||||
resource "virtfusion_user" "customer" {
|
||||
name = "Jane Doe"
|
||||
email = "jane@example.com"
|
||||
ext_relation_id = "cust-001"
|
||||
}
|
||||
|
||||
resource "virtfusion_ssh_key" "key" {
|
||||
user_id = virtfusion_user.customer.id
|
||||
name = "deploy-key"
|
||||
public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExample deploy@example.com"
|
||||
}
|
||||
|
||||
resource "virtfusion_server" "web" {
|
||||
package_id = 19
|
||||
user_id = virtfusion_user.customer.id
|
||||
hypervisor_id = 8
|
||||
}
|
||||
|
||||
resource "virtfusion_server_build" "web" {
|
||||
server_id = virtfusion_server.web.id
|
||||
name = "web-server"
|
||||
hostname = "web.example.com"
|
||||
osid = 13
|
||||
vnc = true
|
||||
ipv6 = true
|
||||
ssh_keys = [virtfusion_ssh_key.key.id]
|
||||
}
|
||||
```
|
||||
|
||||
### Read infrastructure data
|
||||
|
||||
```hcl
|
||||
data "virtfusion_servers" "all" {}
|
||||
data "virtfusion_packages" "all" {}
|
||||
data "virtfusion_hypervisors" "all" {}
|
||||
|
||||
output "server_count" {
|
||||
value = length(data.virtfusion_servers.all.servers)
|
||||
}
|
||||
```
|
||||
|
||||
List data sources support a `results` parameter (default: 300) and automatically paginate through all pages:
|
||||
|
||||
```hcl
|
||||
data "virtfusion_servers" "all" {
|
||||
results = 100 # override per-page limit
|
||||
}
|
||||
```
|
||||
|
||||
## Resources
|
||||
|
||||
| Resource | Description |
|
||||
|----------|-------------|
|
||||
| `virtfusion_server` | Create and manage servers |
|
||||
| `virtfusion_server_build` | Build (install OS on) a server |
|
||||
| `virtfusion_server_firewall` | Manage server firewall rules |
|
||||
| `virtfusion_server_ipv4` | Add IPv4 addresses to a server |
|
||||
| `virtfusion_server_network_whitelist` | Manage network whitelist entries |
|
||||
| `virtfusion_server_traffic_block` | Manage traffic blocks |
|
||||
| `virtfusion_server_power_action` | Control server power state |
|
||||
| `virtfusion_server_password_reset` | Reset server root password |
|
||||
| `virtfusion_ssh_key` | Manage SSH keys |
|
||||
| `virtfusion_user` | Manage users |
|
||||
| `virtfusion_user_auth_token` | Generate user authentication tokens |
|
||||
| `virtfusion_user_server_auth_token` | Generate server-scoped authentication tokens |
|
||||
| `virtfusion_user_password_reset` | Reset user passwords |
|
||||
| `virtfusion_ip_block_range` | Add IPv4 ranges to IP blocks |
|
||||
| `virtfusion_self_service_credit` | Manage self-service billing credits |
|
||||
| `virtfusion_self_service_resource_pack` | Manage resource packs |
|
||||
| `virtfusion_self_service_hourly_group_profile` | Manage hourly billing group profiles |
|
||||
| `virtfusion_self_service_hourly_resource_pack` | Manage hourly resource packs |
|
||||
| `virtfusion_self_service_resource_group_profile` | Manage resource group profiles |
|
||||
| `virtfusion_self_service_pack_servers_action` | Suspend/unsuspend/delete pack servers |
|
||||
|
||||
## Data Sources
|
||||
|
||||
| Data Source | Description |
|
||||
|-------------|-------------|
|
||||
| `virtfusion_server` | Read a single server by ID |
|
||||
| `virtfusion_servers` | List all servers |
|
||||
| `virtfusion_servers_by_user` | List servers owned by a user |
|
||||
| `virtfusion_server_backups` | List server backups |
|
||||
| `virtfusion_server_firewall` | Read server firewall configuration |
|
||||
| `virtfusion_server_templates` | List available templates for a server |
|
||||
| `virtfusion_server_traffic` | Read server traffic usage |
|
||||
| `virtfusion_server_traffic_blocks` | List server traffic blocks |
|
||||
| `virtfusion_server_vnc` | Get VNC connection info |
|
||||
| `virtfusion_hypervisor` | Read a single hypervisor |
|
||||
| `virtfusion_hypervisors` | List all hypervisors |
|
||||
| `virtfusion_hypervisor_group` | Read a single hypervisor group |
|
||||
| `virtfusion_hypervisor_groups` | List all hypervisor groups |
|
||||
| `virtfusion_hypervisor_group_resources` | Read aggregated resources for a group |
|
||||
| `virtfusion_package` | Read a single package |
|
||||
| `virtfusion_packages` | List all packages |
|
||||
| `virtfusion_package_templates` | List templates for a package |
|
||||
| `virtfusion_ip_block` | Read a single IP block |
|
||||
| `virtfusion_ip_blocks` | List all IP blocks |
|
||||
| `virtfusion_ssh_key` | Read a single SSH key |
|
||||
| `virtfusion_ssh_keys_by_user` | List SSH keys for a user |
|
||||
| `virtfusion_user` | Read a user by external relation ID |
|
||||
| `virtfusion_dns_service` | Read DNS service configuration |
|
||||
| `virtfusion_iso` | Read ISO media info |
|
||||
| `virtfusion_queue_item` | Read a queue item status |
|
||||
| `virtfusion_self_service_currencies` | List available currencies |
|
||||
| `virtfusion_self_service_resource_pack` | Read a resource pack |
|
||||
| `virtfusion_self_service_hourly_stats` | Read hourly billing stats |
|
||||
| `virtfusion_self_service_report` | Read self-service reports |
|
||||
| `virtfusion_self_service_usage` | Read self-service usage |
|
||||
|
||||
## Development
|
||||
|
||||
### Build
|
||||
|
||||
```bash
|
||||
go build ./...
|
||||
```
|
||||
|
||||
### Install locally
|
||||
|
||||
```bash
|
||||
go install .
|
||||
```
|
||||
|
||||
### Run linter
|
||||
|
||||
```bash
|
||||
golangci-lint run
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MPL-2.0](LICENSE)
|
||||
|
||||
Reference in New Issue
Block a user