Skip to content

Terraform with Other Local Providers

While VMware is a common local provider used with Terraform, there are several other local providers available for managing on-premises or self-hosted infrastructure. Here's an overview of some other popular local providers.

OpenStack

OpenStack is an open-source cloud computing platform for public and private clouds.

provider "openstack" {
  user_name   = var.openstack_user_name
  tenant_name = var.openstack_tenant_name
  password    = var.openstack_password
  auth_url    = var.openstack_auth_url
  region      = var.openstack_region
}

resource "openstack_compute_instance_v2" "example" {
  name            = "basic"
  image_id        = var.image_id
  flavor_id       = var.flavor_id
  key_pair        = var.key_pair
  security_groups = ["default"]

  network {
    name = var.network_name
  }
}

Proxmox

Proxmox Virtual Environment is an open-source server virtualization management platform.

provider "proxmox" {
    pm_api_url = var.proxmox_api_url
    pm_user = var.proxmox_user
    pm_password = var.proxmox_password
    pm_tls_insecure = true
}

resource "proxmox_vm_qemu" "example" {
    name = "terraform-test"
    target_node = var.proxmox_node

    clone = var.template_name
    os_type = "cloud-init"
    cores = 2
    sockets = 1
    memory = 2048
}

Nutanix

Nutanix is a hyper-converged infrastructure (HCI) vendor.

provider "nutanix" {
  username = var.nutanix_username
  password = var.nutanix_password
  endpoint = var.nutanix_endpoint
  insecure = true
  port     = 9440
}

resource "nutanix_virtual_machine" "example" {
  name = "terraform-test"

  cluster_uuid = var.cluster_uuid

  num_vcpus_per_socket = 1
  num_sockets          = 1
  memory_size_mib      = 1024
}

Kubernetes (for on-premises clusters)

While often used with cloud providers, Kubernetes can also be run on-premises.

provider "kubernetes" {
  config_path = "~/.kube/config"
}

resource "kubernetes_deployment" "example" {
  metadata {
    name = "terraform-example"
    labels = {
      app = "example"
    }
  }

  spec {
    replicas = 3

    selector {
      match_labels = {
        app = "example"
      }
    }

    template {
      metadata {
        labels = {
          app = "example"
        }
      }

      spec {
        container {
          image = "nginx:1.7.8"
          name  = "example"
        }
      }
    }
  }
}

Best Practices for Local Providers

  1. Ensure secure communication between Terraform and local infrastructure
  2. Implement proper backup and disaster recovery for local Terraform states
  3. Use consistent naming conventions across all providers
  4. Manage secrets and credentials securely, potentially using a secrets management tool

Remember to always consult the official Terraform documentation for each provider for the most up-to-date information and best practices.