Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 03-May-2022 | - | ||||
examples/ | H | 01-Aug-2019 | - | |||
structs/ | H | 01-Aug-2019 | - | |||
vendor/ | H | 01-Aug-2019 | - | |||
vultr/ | H | 01-Aug-2019 | - | |||
.gitignore | H A D | 01-Aug-2019 | 58 | |||
.travis.yml | H A D | 01-Aug-2019 | 193 | |||
LICENSE | H A D | 01-Aug-2019 | 16.3 KiB | |||
Makefile | H A D | 01-Aug-2019 | 3.4 KiB | |||
README.md | H A D | 01-Aug-2019 | 3.7 KiB | |||
glide.lock | H A D | 01-Aug-2019 | 10.3 KiB | |||
glide.yaml | H A D | 01-Aug-2019 | 367 | |||
main.go | H A D | 01-Aug-2019 | 203 |
README.md
1# Vultr Terraform Provider 2 3This is a Terraform provider for Vultr. Find out more about [Vultr](https://www.vultr.com/about/). 4 5[![Build Status](https://travis-ci.org/squat/terraform-provider-vultr.svg?branch=master)](https://travis-ci.org/squat/terraform-provider-vultr) 6[![Go Report Card](https://goreportcard.com/badge/github.com/squat/terraform-provider-vultr)](https://goreportcard.com/report/github.com/squat/terraform-provider-vultr) 7 8## Requirements 9 10* A Vultr account and API key 11* [Terraform](https://www.terraform.io/downloads.html) 0.12+ 12* [Go](https://golang.org/doc/install) 1.8 (to build the provider plugin) 13 14## Usage 15 16Download `terraform-provider-vultr` from the [releases page](https://github.com/squat/terraform-provider-vultr/releases) and follow the instructions to [install it as a plugin](https://www.terraform.io/docs/plugins/basics.html#installing-a-plugin). After placing it into your plugins directory, run `terraform init` to initialize it. 17 18*Note*: in order to build and install the provider from the latest commit on master, run: 19```sh 20go get -u github.com/squat/terraform-provider-vultr 21``` 22 23and then register the plugin by symlinking the binary to the [third-party plugins directory](https://www.terraform.io/docs/configuration/providers.html#third-party-plugins): 24```sh 25mkdir -p ~/.terraform.d/plugins 26ln -s "$GOPATH/bin/terraform-provider-vultr" ~/.terraform.d/plugins/terraform-provider-vultr 27``` 28 29Set an environment variable containing the Vultr API key: 30``` 31export VULTR_API_KEY=<your-vultr-api-key> 32``` 33*Note*: as an alternative, the API key can be specified in configuration as shown below. 34 35## Examples 36 37```tf 38// Configure the Vultr provider. 39// Alternatively, export the API key as an environment variable: `export VULTR_API_KEY=<your-vultr-api-key>`. 40provider "vultr" { 41 api_key = "<your-vultr-api-key>" 42} 43 44// Find the ID of the Silicon Valley region. 45data "vultr_region" "silicon_valley" { 46 filter { 47 name = "name" 48 values = ["Silicon Valley"] 49 } 50} 51 52// Find the ID for CoreOS Container Linux. 53data "vultr_os" "container_linux" { 54 filter { 55 name = "family" 56 values = ["coreos"] 57 } 58} 59 60// Find the ID for a starter plan. 61data "vultr_plan" "starter" { 62 filter { 63 name = "price_per_month" 64 values = ["5.00"] 65 } 66 67 filter { 68 name = "ram" 69 values = ["1024"] 70 } 71} 72 73// Find the ID of an existing SSH key. 74data "vultr_ssh_key" "squat" { 75 filter { 76 name = "name" 77 values = ["squat"] 78 } 79} 80 81// Create a Vultr virtual machine. 82resource "vultr_instance" "example" { 83 name = "example" 84 region_id = "${data.vultr_region.silicon_valley.id}" 85 plan_id = "${data.vultr_plan.starter.id}" 86 os_id = "${data.vultr_os.container_linux.id}" 87 ssh_key_ids = ["${data.vultr_ssh_key.squat.id}"] 88 hostname = "example" 89 tag = "container-linux" 90 firewall_group_id = "${vultr_firewall_group.example.id}" 91} 92 93// Create a new firewall group. 94resource "vultr_firewall_group" "example" { 95 description = "example group" 96} 97 98// Add a firewall rule to the group allowing SSH access. 99resource "vultr_firewall_rule" "ssh" { 100 firewall_group_id = "${vultr_firewall_group.example.id}" 101 cidr_block = "0.0.0.0/0" 102 protocol = "tcp" 103 from_port = 22 104 to_port = 22 105} 106``` 107 108## Development 109 110To develop the plugin locally, install the following dependencies: 111* [Go](https://golang.org/doc/install) 1.8 (to build the provider plugin) 112* [Glide](https://github.com/Masterminds/glide#install) (to install and maintain dependencies) 113* [glide-vc](https://github.com/sgotti/glide-vc#install) (to clean up dependencies) 114 115To build the plugin run: 116```sh 117make build 118``` 119 120To update Go dependencies run: 121```sh 122make vendor 123``` 124