Vultr Terraform Provider

repository·master·Indexed 42 days ago

https://github.com/vultr/terraform-provider-vultr

The Vultr Terraform Provider allows users to manage Vultr cloud resources, including VPS, DNS, Load Balancers, and Firewalls, using Terraform HCL configuration. Version 2.22.1 introduces UUIDs for all resource identifiers and descriptive string formats for Plan and Region IDs. The provider supports data sources for account information, applications, backups, and block storage.

Tokens
49.5K
Snippets
187
Records
311
Agent score
52%

What's inside Vultr Terraform Provider

  1. Manage Vultr database topics with vultr_database_topic

    master

    The vultr_database_topic resource allows you to create, read, modify, and delete topics for a managed database on your Vultr account.

    Important Note: Updating the database_id will trigger a force new operation, meaning the existing topic will be destroyed and a new one created. This is because a database topic cannot be moved from one managed database to another.

    resource "vultr_database_topic" "my_database_topic" {
    	database_id = vultr_database.my_database.id
    	name = "my_database_topic"
    	partitions = "3"
    	replication = "2"
    	retention_hours = "120"
    	retention_bytes = "-1"
    }
  2. Manage Vultr Users with vultr_user

    master

    The vultr_user resource allows you to create, read, modify, and delete users within your Vultr account via Terraform. You can define basic user credentials or create highly privileged users by specifying Access Control Lists (ACLs), assigning them to specific groups or roles, and designating them as service users.

    resource "vultr_user" "my_user" {
    	name = "my user"
    	email = "user@vultr.com"
    	password = "myP@ssw0rd"
    	api_enabled = true
    }
  3. Manage Vultr bare metal servers with vultr_bare_metal_server

    master

    The vultr_bare_metal_server resource allows you to create, read, modify, and delete bare metal servers on your Vultr account using Terraform. You can specify the hardware plan, region, operating system, and various networking and configuration options like IPv6, SSH keys, and user data.

    resource "vultr_bare_metal_server" "my_server" {
    	plan = "vbm-4c-32gb"
    	region = "ewr"
    	os_id = 1743
    }
  4. Manage Vultr Managed Databases with vultr_database

    master

    The vultr_database resource allows you to create, read, modify, and delete managed databases on your Vultr account. This includes support for various engines like PostgreSQL, MySQL, Kafka, and Valkey.

    Important Note on Engine Updates: Updating the database_engine will trigger a force new (destruction and recreation) because Vultr does not support changing the engine type of an existing database. However, updating the database_engine_version is supported if an upgrade is available.

    resource "vultr_database" "my_database" {
    	database_engine = "pg"
    	database_engine_version = "15"
        region = "ewr"
        plan = "vultr-dbaas-startup-cc-1-55-2"
        label = "my_database_label"
    }
  5. Use UUIDs for all resource identifiers in V2

    master

    In the V2 provider, all resource IDs are now UUIDs. References to previous ID formats are no longer supported. This applies to the following resource types:

    • Instances
    • Bare Metal
    • Block Storage
    • Object Storage
    • Reserved IP
    • Load Balancer
    • Snapshots & Backups
    • DNS Records
    • ISOs (Private & Public)
    • Private Networks
    • Startup Scripts
    • SSH Keys
    • Firewall Groups
    • Container Registry

    Actionable Requirements:

    • Data Sources: When filtering by ID or any other resource ID, you must use the resource's UUID.
    • Resource Arguments: Any argument that accepts another resource as a reference (e.g., snapshot_id when creating an instance) must be provided as a UUID.
  6. Manage Vultr PostgreSQL database connection pools with vultr_database_connection_pool

    master

    The vultr_database_connection_pool resource allows you to create, read, modify, and delete connection pools for PostgreSQL managed databases on Vultr.

    Important Note on Updates: Updating the database_id or the name will trigger a force new operation (the resource will be destroyed and recreated). This is because connection pools cannot be moved between managed databases and pool names are immutable once created.

    resource "vultr_database_connection_pool" "my_database_connection_pool" {
    	database_id = vultr_database.my_database.id
    	name = "my_database_connection_pool_name"
    	database = "defaultdb"
    	username = "vultradmin"
    	mode = "transaction"
    	size = 3
    }
  7. Manually install the Vultr provider locally

    master

    If you need to install the provider manually (e.g., in air-gapped environments), follow these steps:

    1. Download and extract the appropriate binary for your OS and architecture from the GitHub releases page.
    2. Create the local plugins directory using the following structure:
      • Linux: ~/.terraform.d/plugins/local/vultr/vultr/${VERSION}/${OS}_${ARCH}/
      • macOS: ~/.terraform.d/plugins/local/vultr/vultr/${VERSION}/${OS}_${ARCH}/
    3. Move the binary into that directory, ensuring it is named terraform-provider-vultr_v${VERSION}.
    4. Update your Terraform configuration to use the local/vultr/vultr source instead of the registry source.
    5. Run terraform init to verify the installation.
    # Example for Linux
    export VERSION=2.22.1 OS=linux ARCH=amd64 
    mkdir -p ~/.terraform.d/plugins/local/vultr/vultr/${VERSION}/${OS}_${ARCH}/
    
    # Move the binary
    mv terraform-provider-vultr_v${VERSION} ~/.terraform.d/plugins/local/vultr/vultr/${VERSION}/${OS}_${ARCH}/terraform-provider-vultr_v${VERSION}
    # Updated configuration for local provider
    terraform {
      required_providers {
        vultr = {
          source = "local/vultr/vultr"
          version = "2.22.1"
        }
      }
    }
    
    provider "vultr" {
      api_key = "..."
    }
  8. Import a VKE Node Pool into Terraform

    master

    To import an existing node pool, you must provide both the Cluster UUID and the Node Pool UUID. The import format requires a space-delimited string where the first ID is the clusterID and the second is the nodePoolID.

    # Format: "clusterID nodePoolID"
    terraform import vultr_kubernetes_node_pools.my-k8s-np "7365a98b-5a43-450f-bd27-d768827100e5 ec330340-4f50-4526-858f-a39199f568ac"