From f356bbdef530167a4e8baff47dec54bf778d7370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Serv=C3=A9n=20Mar=C3=ADn?= Date: Thu, 1 Aug 2019 15:47:26 +0200 Subject: [PATCH] examples: update for terraform 0.12.0 --- examples/application/example.tf | 8 ++++---- examples/application/versions.tf | 3 +++ examples/bare_metal/example.tf | 6 +++--- examples/bare_metal/versions.tf | 3 +++ examples/basic/example.tf | 27 +++++++++++++++------------ examples/basic/versions.tf | 3 +++ examples/block_storage/example.tf | 2 +- examples/block_storage/versions.tf | 3 +++ examples/dns/example.tf | 4 ++-- examples/dns/versions.tf | 3 +++ examples/kubernetes/example.tf | 19 ++++++++++++------- examples/kubernetes/versions.tf | 3 +++ examples/network/example.tf | 16 ++++++++-------- examples/network/versions.tf | 3 +++ examples/reserved_ip/example.tf | 14 +++++++------- examples/reserved_ip/versions.tf | 3 +++ examples/snapshot/example.tf | 6 +++--- examples/snapshot/versions.tf | 3 +++ 18 files changed, 82 insertions(+), 47 deletions(-) create mode 100644 examples/application/versions.tf create mode 100644 examples/bare_metal/versions.tf create mode 100644 examples/basic/versions.tf create mode 100644 examples/block_storage/versions.tf create mode 100644 examples/dns/versions.tf create mode 100644 examples/kubernetes/versions.tf create mode 100644 examples/network/versions.tf create mode 100644 examples/reserved_ip/versions.tf create mode 100644 examples/snapshot/versions.tf diff --git a/examples/application/example.tf b/examples/application/example.tf index 76eca38c..f7b67c10 100644 --- a/examples/application/example.tf +++ b/examples/application/example.tf @@ -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 } diff --git a/examples/application/versions.tf b/examples/application/versions.tf new file mode 100644 index 00000000..d9b6f790 --- /dev/null +++ b/examples/application/versions.tf @@ -0,0 +1,3 @@ +terraform { + required_version = ">= 0.12" +} diff --git a/examples/bare_metal/example.tf b/examples/bare_metal/example.tf index 9f4bb67e..aa28ff3d 100644 --- a/examples/bare_metal/example.tf +++ b/examples/bare_metal/example.tf @@ -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 } diff --git a/examples/bare_metal/versions.tf b/examples/bare_metal/versions.tf new file mode 100644 index 00000000..d9b6f790 --- /dev/null +++ b/examples/bare_metal/versions.tf @@ -0,0 +1,3 @@ +terraform { + required_version = ">= 0.12" +} diff --git a/examples/basic/example.tf b/examples/basic/example.tf index 9fba04a4..91b92858 100644 --- a/examples/basic/example.tf +++ b/examples/basic/example.tf @@ -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], + ) } diff --git a/examples/basic/versions.tf b/examples/basic/versions.tf new file mode 100644 index 00000000..d9b6f790 --- /dev/null +++ b/examples/basic/versions.tf @@ -0,0 +1,3 @@ +terraform { + required_version = ">= 0.12" +} diff --git a/examples/block_storage/example.tf b/examples/block_storage/example.tf index 0be5a31f..43b38551 100644 --- a/examples/block_storage/example.tf +++ b/examples/block_storage/example.tf @@ -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 } diff --git a/examples/block_storage/versions.tf b/examples/block_storage/versions.tf new file mode 100644 index 00000000..d9b6f790 --- /dev/null +++ b/examples/block_storage/versions.tf @@ -0,0 +1,3 @@ +terraform { + required_version = ">= 0.12" +} diff --git a/examples/dns/example.tf b/examples/dns/example.tf index aa857480..505f6271 100644 --- a/examples/dns/example.tf +++ b/examples/dns/example.tf @@ -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 } diff --git a/examples/dns/versions.tf b/examples/dns/versions.tf new file mode 100644 index 00000000..d9b6f790 --- /dev/null +++ b/examples/dns/versions.tf @@ -0,0 +1,3 @@ +terraform { + required_version = ">= 0.12" +} diff --git a/examples/kubernetes/example.tf b/examples/kubernetes/example.tf index fc09e16c..e2ed8d1b 100644 --- a/examples/kubernetes/example.tf +++ b/examples/kubernetes/example.tf @@ -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"] + } } diff --git a/examples/kubernetes/versions.tf b/examples/kubernetes/versions.tf new file mode 100644 index 00000000..d9b6f790 --- /dev/null +++ b/examples/kubernetes/versions.tf @@ -0,0 +1,3 @@ +terraform { + required_version = ">= 0.12" +} diff --git a/examples/network/example.tf b/examples/network/example.tf index 14916e6b..f4309be5 100644 --- a/examples/network/example.tf +++ b/examples/network/example.tf @@ -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 } diff --git a/examples/network/versions.tf b/examples/network/versions.tf new file mode 100644 index 00000000..d9b6f790 --- /dev/null +++ b/examples/network/versions.tf @@ -0,0 +1,3 @@ +terraform { + required_version = ">= 0.12" +} diff --git a/examples/reserved_ip/example.tf b/examples/reserved_ip/example.tf index 6eb46c57..f3da99da 100644 --- a/examples/reserved_ip/example.tf +++ b/examples/reserved_ip/example.tf @@ -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 } diff --git a/examples/reserved_ip/versions.tf b/examples/reserved_ip/versions.tf new file mode 100644 index 00000000..d9b6f790 --- /dev/null +++ b/examples/reserved_ip/versions.tf @@ -0,0 +1,3 @@ +terraform { + required_version = ">= 0.12" +} diff --git a/examples/snapshot/example.tf b/examples/snapshot/example.tf index 7d05ecfe..b94cd5ea 100644 --- a/examples/snapshot/example.tf +++ b/examples/snapshot/example.tf @@ -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 } diff --git a/examples/snapshot/versions.tf b/examples/snapshot/versions.tf new file mode 100644 index 00000000..d9b6f790 --- /dev/null +++ b/examples/snapshot/versions.tf @@ -0,0 +1,3 @@ +terraform { + required_version = ">= 0.12" +}