Skip to content

decentralized-infrastructure/terraform-provider-fluence

Repository files navigation

Fluence Terraform Provider

This repository contains the Fluence Cloudless VMs Terraform Provider.

Features

  • SSH Key Management: Create, read, update, and delete SSH keys
  • Virtual Machine Management: Full CRUD operations for VMs with advanced configuration options
  • State Management: Robust state management with retry logic for eventual consistency

Supported Resources

Resources

  • fluence_ssh_key - Manage SSH keys for VM access
  • fluence_vm - Manage virtual machines with full configuration options

Data Sources

  • fluence_ssh_keys - List all SSH keys in your account
  • fluence_vms - List all virtual machines in your account
  • fluence_basic_configurations - Get available VM configurations
  • fluence_available_countries - Get available datacenter countries
  • fluence_available_hardware - Get available hardware options

Requirements

Quick Start

  1. Set your API key:

    export FLUENCE_API_KEY="your-api-key-here"
  2. Create a basic configuration:

    terraform {
      required_providers {
        fluence = {
          source = "hashicorp.com/decentralized-infrastructure/fluence"
        }
      }
    }
    
    provider "fluence" {
      # API key from environment variable FLUENCE_API_KEY
    }
    
    # Create an SSH key
    resource "fluence_ssh_key" "example" {
      name       = "my-key"
      # Replace with your actual public key associated with a private key you control
      public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKgJIjnDg1DjqOOxINs78oU3f7PJXIyq9uiNocNVhXNx [email protected]"
    }
    
    # Create a VM
    resource "fluence_vm" "example" {
      name     = "my-vm"
      os_image = "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64.img"
      ssh_keys = [fluence_ssh_key.example.fingerprint]
      
      open_ports = [{
        port     = 22
        protocol = "tcp"
      }]
      
      instances           = 1
      basic_configuration = "small"
    }
  3. Deploy:

    terraform init
    terraform plan
    terraform apply

Examples

See the examples/ directory for comprehensive usage examples.

Building The Provider

  1. Clone the repository
  2. Enter the repository directory
  3. Build the provider:
go build -o terraform-provider-fluence

Adding Dependencies

This provider uses Go modules.

To add a new dependency:

go get github.com/author/dependency
go mod tidy

Developing the Provider

If you wish to work on the provider, you'll first need Go installed on your machine.

To compile the provider, run go build. This will build the provider and put the provider binary in the current directory.

For development testing, you can use a .terraformrc file to override the provider location:

provider_installation {
  dev_overrides {
    "hashicorp.com/decentralized-infrastructure/fluence" = "/path/to/your/go/bin"
  }
  direct {}
}

Documenting the Provider

In order to generate documentation for the provider, the following command can be run:

go get github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs

About

Terraform provider to create Fluence VMs and resources using the Fluence API.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages