diff --git a/README.md b/README.md index 704b589..6a06142 100644 --- a/README.md +++ b/README.md @@ -2,39 +2,78 @@ 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 +## Quick Install -- [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 +### Linux (amd64) -## Installation +```bash +VERSION=1.0.0 +curl -Lo terraform-provider-virtfusion.zip \ + https://git.ezscale.cloud/EZSCALE/terraform-provider-virtfusion/releases/download/v${VERSION}/terraform-provider-virtfusion_${VERSION}_linux_amd64.zip +unzip terraform-provider-virtfusion.zip -d ~/.terraform.d/plugins/registry.terraform.io/EZSCALE/virtfusion/${VERSION}/linux_amd64/ +rm terraform-provider-virtfusion.zip +``` -### From Release +### macOS (Apple Silicon) -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. +```bash +VERSION=1.0.0 +curl -Lo terraform-provider-virtfusion.zip \ + https://git.ezscale.cloud/EZSCALE/terraform-provider-virtfusion/releases/download/v${VERSION}/terraform-provider-virtfusion_${VERSION}_darwin_arm64.zip +unzip terraform-provider-virtfusion.zip -d ~/.terraform.d/plugins/registry.terraform.io/EZSCALE/virtfusion/${VERSION}/darwin_arm64/ +rm terraform-provider-virtfusion.zip +``` + +### macOS (Intel) + +```bash +VERSION=1.0.0 +curl -Lo terraform-provider-virtfusion.zip \ + https://git.ezscale.cloud/EZSCALE/terraform-provider-virtfusion/releases/download/v${VERSION}/terraform-provider-virtfusion_${VERSION}_darwin_amd64.zip +unzip terraform-provider-virtfusion.zip -d ~/.terraform.d/plugins/registry.terraform.io/EZSCALE/virtfusion/${VERSION}/darwin_amd64/ +rm terraform-provider-virtfusion.zip +``` + +### Windows (PowerShell) + +```powershell +$VERSION = "1.0.0" +Invoke-WebRequest -Uri "https://git.ezscale.cloud/EZSCALE/terraform-provider-virtfusion/releases/download/v$VERSION/terraform-provider-virtfusion_${VERSION}_windows_amd64.zip" -OutFile tf-vf.zip +Expand-Archive tf-vf.zip -DestinationPath "$env:APPDATA\terraform.d\plugins\registry.terraform.io\EZSCALE\virtfusion\$VERSION\windows_amd64\" +Remove-Item tf-vf.zip +``` ### From Source ```bash git clone https://git.ezscale.cloud/EZSCALE/terraform-provider-virtfusion.git -cd terraform-provider-virtfusion -go install . +cd terraform-provider-virtfusion && go install . ``` -Then configure `~/.terraformrc` for local development: +Then add dev_overrides to `~/.terraformrc`: -```hcl +```bash +cat >> ~/.terraformrc <<'EOF' provider_installation { dev_overrides { - "registry.terraform.io/EZSCALE/virtfusion" = "/path/to/your/gopath/bin" + "registry.terraform.io/EZSCALE/virtfusion" = "${GOPATH}/bin" } direct {} } +EOF ``` ## Quick Start +**1. Set your credentials:** + +```bash +export VIRTFUSION_ENDPOINT="https://cp.example.com" +export VIRTFUSION_API_TOKEN="your-api-token" +``` + +**2. Create `main.tf`:** + ```hcl terraform { required_providers { @@ -44,24 +83,30 @@ terraform { } } -variable "virtfusion_api_token" { - type = string - sensitive = true -} +provider "virtfusion" {} +data "virtfusion_servers" "all" {} + +output "server_count" { + value = length(data.virtfusion_servers.all.servers) +} +``` + +**3. Run it:** + +```bash +terraform plan +``` + +The provider reads `VIRTFUSION_ENDPOINT` and `VIRTFUSION_API_TOKEN` from the environment. You can also set them directly in the provider block: + +```hcl provider "virtfusion" { endpoint = "https://cp.example.com" api_token = var.virtfusion_api_token } ``` -The provider can also be configured using environment variables: - -```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