Skip to content

Instantly share code, notes, and snippets.

@desnudopenguino
Last active November 4, 2017 08:53
Show Gist options
  • Save desnudopenguino/4848c77374fb5e937e50e669c9fbe84f to your computer and use it in GitHub Desktop.
Save desnudopenguino/4848c77374fb5e937e50e669c9fbe84f to your computer and use it in GitHub Desktop.
A sample config to set up openbsd on vultr
// 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 = "<api key>"
}
// Find the ID of the Silicon Valley region.
data "vultr_region" "seattle" {
filter {
name = "name"
values = ["Seattle"]
}
}
// Find the ID for CoreOS Container Linux.
data "vultr_os" "openbsd" {
filter {
name = "family"
values = ["openbsd"]
}
}
// Find the ID for a starter plan.
data "vultr_plan" "starter" {
filter {
name = "price_per_month"
values = ["5.00"]
}
filter {
name = "ram"
values = ["1024"]
}
}
// Create a Vultr virtual machine.
resource "vultr_instance" "example" {
name = "example"
region_id = "${data.vultr_region.seattle.id}"
plan_id = "${data.vultr_plan.starter.id}"
os_id = "${data.vultr_os.openbsd.id}"
hostname = "example"
tag = "openbsd-test"
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
}
// Add a firewall rule to the group allowing ICMP.
resource "vultr_firewall_rule" "icmp" {
firewall_group_id = "${vultr_firewall_group.example.id}"
cidr_block = "0.0.0.0/0"
protocol = "icmp"
}
// Create a DNS domain.
//resource "vultr_dns_domain" "<your domain>" {
// domain = "<your domain>"
// ip = "<main ip, could be ${vultr_instance.example.ipv4_address} as well"
//}
// Create a new DNS record.
resource "vultr_dns_record" "example_web" {
domain = "<main domain>"
name = "subdomain"
type = "A"
data = "${vultr_instance.example.ipv4_address}"
ttl = 300
}
// Create a new SSH key.
resource "vultr_ssh_key" "laptop" {
name = "laptop"
public_key = "<public key text>"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment