Skip to content

Commit

Permalink
examples: update for terraform 0.12.0
Browse files Browse the repository at this point in the history
squat committed Aug 1, 2019
1 parent 48cd5bc commit f356bbd
Showing 18 changed files with 82 additions and 47 deletions.
8 changes: 4 additions & 4 deletions examples/application/example.tf
Original file line number Diff line number Diff line change
@@ -45,8 +45,8 @@ data "vultr_plan" "starter" {
resource "vultr_instance" "openvpn" {
name = "openvpn"
hostname = "openvpn"
region_id = "${data.vultr_region.silicon_valley.id}"
plan_id = "${data.vultr_plan.starter.id}"
os_id = "${data.vultr_os.application.id}"
application_id = "${data.vultr_application.openvpn.id}"
region_id = data.vultr_region.silicon_valley.id
plan_id = data.vultr_plan.starter.id
os_id = data.vultr_os.application.id
application_id = data.vultr_application.openvpn.id
}
3 changes: 3 additions & 0 deletions examples/application/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
terraform {
required_version = ">= 0.12"
}
6 changes: 3 additions & 3 deletions examples/bare_metal/example.tf
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ data "vultr_bare_metal_plan" "eightcpus" {
resource "vultr_bare_metal" "example" {
name = "example"
hostname = "example"
region_id = "${data.vultr_region.silicon_valley.id}"
plan_id = "${data.vultr_bare_metal_plan.eightcpus.id}"
os_id = "${data.vultr_os.container_linux.id}"
region_id = data.vultr_region.silicon_valley.id
plan_id = data.vultr_bare_metal_plan.eightcpus.id
os_id = data.vultr_os.container_linux.id
}
3 changes: 3 additions & 0 deletions examples/bare_metal/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
terraform {
required_version = ">= 0.12"
}
27 changes: 15 additions & 12 deletions examples/basic/example.tf
Original file line number Diff line number Diff line change
@@ -36,16 +36,16 @@ data "vultr_plan" "starter" {
// 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 = ["${vultr_ssh_key.squat.id}"]
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 = [vultr_ssh_key.squat.id]
hostname = "example"
tag = "container-linux"
firewall_group_id = "${vultr_firewall_group.example.id}"
firewall_group_id = vultr_firewall_group.example.id

connection {
host = "${vultr_instance.example.ipv4_address}"
host = vultr_instance.example.ipv4_address
}

provisioner "remote-exec" {
@@ -60,7 +60,7 @@ resource "vultr_firewall_group" "example" {

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

// Add a firewall rule to the group allowing ICMP.
resource "vultr_firewall_rule" "icmp" {
firewall_group_id = "${vultr_firewall_group.example.id}"
firewall_group_id = vultr_firewall_group.example.id
cidr_block = "0.0.0.0/0"
protocol = "icmp"
notes = "icmp"
@@ -79,17 +79,20 @@ resource "vultr_firewall_rule" "icmp" {
// Create a new SSH key.
resource "vultr_ssh_key" "squat" {
name = "squat"
public_key = "${file("~/lserven.ssh")}"
public_key = file("~/lserven.ssh")
}

// Add two extra IPv4 addresses to the virtual machine.
resource "vultr_ipv4" "example" {
instance_id = "${vultr_instance.example.id}"
instance_id = vultr_instance.example.id
reboot = false
count = 2
}

// Output all of the virtual machine's IPv4 addresses to STDOUT when the infrastructure is ready.
output ip_addresses {
value = "${concat(vultr_ipv4.example.*.ipv4_address, list(vultr_instance.example.ipv4_address))}"
output "ip_addresses" {
value = concat(
vultr_ipv4.example.*.ipv4_address,
[vultr_instance.example.ipv4_address],
)
}
3 changes: 3 additions & 0 deletions examples/basic/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
terraform {
required_version = ">= 0.12"
}
2 changes: 1 addition & 1 deletion examples/block_storage/example.tf
Original file line number Diff line number Diff line change
@@ -15,6 +15,6 @@ data "vultr_region" "has_block_storage" {
// Create block storage.
resource "vultr_block_storage" "example" {
name = "example"
region_id = "${data.vultr_region.has_block_storage.id}"
region_id = data.vultr_region.has_block_storage.id
size = 50
}
3 changes: 3 additions & 0 deletions examples/block_storage/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
terraform {
required_version = ">= 0.12"
}
4 changes: 2 additions & 2 deletions examples/dns/example.tf
Original file line number Diff line number Diff line change
@@ -12,9 +12,9 @@ resource "vultr_dns_domain" "example" {

// Create a new DNS record.
resource "vultr_dns_record" "example_web" {
domain = "${vultr_dns_domain.example.id}"
domain = vultr_dns_domain.example.id
name = "www"
type = "A"
data = "${vultr_dns_domain.example.ip}"
data = vultr_dns_domain.example.ip
ttl = 300
}
3 changes: 3 additions & 0 deletions examples/dns/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
terraform {
required_version = ">= 0.12"
}
19 changes: 12 additions & 7 deletions examples/kubernetes/example.tf
Original file line number Diff line number Diff line change
@@ -4,18 +4,18 @@ resource "vultr_dns_domain" "example" {
}

module "typhoon" {
source = "git::https://github.com/squat/typhoon-vultr?ref=v1.13.5"
source = "git::https://github.com/squat/typhoon-vultr?ref=v1.15.1"

cluster_name = "example"

# Vultr
region = "${data.vultr_region.frankfurt.id}"
dns_zone = "${vultr_dns_domain.example.domain}"
controller_type = "${data.vultr_plan.2gb.id}"
worker_type = "${data.vultr_plan.2gb.id}"
region = data.vultr_region.frankfurt.id
dns_zone = vultr_dns_domain.example.domain
controller_type = data.vultr_plan.twogb.id
worker_type = data.vultr_plan.twogb.id

# configuration
ssh_authorized_key = "${file("/path/to/ssh/public/key")}"
ssh_authorized_key = file("/path/to/ssh/public/key")
asset_dir = "assets"

# optional
@@ -29,9 +29,14 @@ data "vultr_region" "frankfurt" {
}
}

data "vultr_plan" "2gb" {
data "vultr_plan" "twogb" {
filter {
name = "ram"
values = ["2048"]
}

filter {
name = "plan_type"
values = ["SSD"]
}
}
3 changes: 3 additions & 0 deletions examples/kubernetes/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
terraform {
required_version = ">= 0.12"
}
16 changes: 8 additions & 8 deletions examples/network/example.tf
Original file line number Diff line number Diff line change
@@ -36,22 +36,22 @@ data "vultr_os" "ubuntu" {
// Create a pair of Vultr private networks.
resource "vultr_network" "network" {
count = 2
cidr_block = "${cidrsubnet("192.168.0.0/23", 1, count.index)}"
cidr_block = cidrsubnet("192.168.0.0/23", 1, count.index)
description = "test_${count.index}"
region_id = "${data.vultr_region.frankfurt.id}"
region_id = data.vultr_region.frankfurt.id
}

// Create a Vultr virtual machine.
resource "vultr_instance" "ubuntu" {
name = "ubuntu"
network_ids = ["${vultr_network.network.*.id}"]
region_id = "${data.vultr_region.frankfurt.id}"
plan_id = "${data.vultr_plan.starter.id}"
os_id = "${data.vultr_os.ubuntu.id}"
network_ids = vultr_network.network.*.id
region_id = data.vultr_region.frankfurt.id
plan_id = data.vultr_plan.starter.id
os_id = data.vultr_os.ubuntu.id
ipv6 = true
}

// Output all of the virtual machine's IPv6 addresses to STDOUT when the infrastructure is ready.
output ip_addresses {
value = "${vultr_instance.ubuntu.ipv6_addresses}"
output "ip_addresses" {
value = vultr_instance.ubuntu.ipv6_addresses
}
3 changes: 3 additions & 0 deletions examples/network/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
terraform {
required_version = ">= 0.12"
}
14 changes: 7 additions & 7 deletions examples/reserved_ip/example.tf
Original file line number Diff line number Diff line change
@@ -36,21 +36,21 @@ data "vultr_plan" "starter" {
// 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 = ["${vultr_ssh_key.squat.id}"]
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 = [vultr_ssh_key.squat.id]
}

// Create a new SSH key.
resource "vultr_ssh_key" "squat" {
name = "squat"
public_key = "${file("~/lserven.ssh")}"
public_key = file("~/lserven.ssh")
}

// Create a reserved IP.
resource "vultr_reserved_ip" "example" {
name = "example"
attached_id = "${vultr_instance.example.id}"
region_id = "${data.vultr_region.silicon_valley.id}"
attached_id = vultr_instance.example.id
region_id = data.vultr_region.silicon_valley.id
}
3 changes: 3 additions & 0 deletions examples/reserved_ip/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
terraform {
required_version = ">= 0.12"
}
6 changes: 3 additions & 3 deletions examples/snapshot/example.tf
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ data "vultr_plan" "starter" {
// Create a Vultr virtual machine.
resource "vultr_instance" "snapshot" {
name = "snapshot"
region_id = "${data.vultr_region.silicon_valley.id}"
plan_id = "${data.vultr_plan.starter.id}"
snapshot_id = "${data.vultr_snapshot.master.id}"
region_id = data.vultr_region.silicon_valley.id
plan_id = data.vultr_plan.starter.id
snapshot_id = data.vultr_snapshot.master.id
}
3 changes: 3 additions & 0 deletions examples/snapshot/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
terraform {
required_version = ">= 0.12"
}

0 comments on commit f356bbd

Please sign in to comment.