Skip to content

Latest commit

 

History

History
121 lines (99 loc) · 3.09 KB

README.md

File metadata and controls

121 lines (99 loc) · 3.09 KB

Vultr Terraform Provider

This is a Terraform provider for the Vultr cloud. Find out more about Vultr.

Build Status Go Report Card

Requirements

  • A Vultr account and API key
  • Terraform 0.9+
  • Go 1.8 (to build the provider plugin)

Usage

Download terraform-provider-vultr and install the plugin binary on the filesystem:

go get -u github.com/squat/terraform-provider-vultr

Register the plugin binary in ~/.terraformrc:

providers {
  vultr = "$GOPATH/bin/terraform-provider-vultr"
}

Set an environment variable containing the Vultr API key:

export VULTR_API_KEY=<your-vultr-api-key>

Note: as an alternative, the API key can be specified in configuration as shown below.

Examples

// Configure the Vultr provider. 
// Alternatively, export the API key as an environment variable: `export VULTR_API_KEY=<your-vultr-api-key>`.
provider "vultr" {
  api_key = "<your-vultr-api-key>"
}

// Find the ID of the Silicon Valley region.
data "vultr_region" "silicon_valley" {
  filter {
    name   = "name"
    values = ["Silicon Valley"]
  }
}

// Find the ID for CoreOS Container Linux.
data "vultr_os" "container_linux" {
  filter {
    name   = "family"
    values = ["coreos"]
  }
}

// Find the ID for a starter plan.
data "vultr_plan" "starter" {
  filter {
    name   = "price_per_month"
    values = ["5.00"]
  }

  filter {
    name   = "ram"
    values = ["1024"]
  }
}

// Find the ID of an existing SSH key.
data "vultr_ssh_key" "squat" {
  filter {
    name   = "name"
    values = ["squat"]
  }
}

// Create a Vultr virtual machine.
resource "vultr_instance" "example" {
  name              = "example"
  region_id         = "${data.vultr_region.silicon_valley.id}"
  plan_id           = "${data.vultr_plan.starter.id}"
  os_id             = "${data.vultr_os.container_linux.id}"
  ssh_key_ids       = ["${data.vultr_ssh_key.squat.id}"]
  hostname          = "example"
  tag               = "container-linux"
  firewall_group_id = "${vultr_firewall_group.example.id}"
}

// Create a new firewall group.
resource "vultr_firewall_group" "example" {
  description = "example group"
}

// Add a firewall rule to the group allowing SSH access.
resource "vultr_firewall_rule" "ssh" {
  firewall_group_id = "${vultr_firewall_group.example.id}"
  cidr_block        = "0.0.0.0/0"
  protocol          = "tcp"
  from_port         = 22
  to_port           = 22
}

Development

To develop the plugin locally, install the following dependencies:

  • Go 1.8 (to build the provider plugin)
  • Glide (to install and maintain dependencies)

To build the plugin run:

make build

To update Go dependencies run:

make vendor