This repository has been archived by the owner on Jul 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathexample.tf
70 lines (54 loc) · 1.75 KB
/
example.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#provider "vultr" {
# api_key = "TODO_SET_TO_YOUR_API_KEY__OR__THE_VULTR_API_KEY_ENV_VARIABLE"
#}
output "ipv4_address" {
value = "${vultr_server.example.ipv4_address}"
}
output "default_password" {
sensitive = true
value = "${vultr_server.example.default_password}"
}
resource "vultr_ssh_key" "example" {
name = "example created from terraform"
# get the public key from a local file.
#
# create the example_rsa.pub file with:
#
# ssh-keygen -t rsa -b 4096 -C 'terraform example' -f example_rsa -N ''
public_key = "${file("example_rsa.pub")}"
}
resource "vultr_dns_domain" "example" {
# NB vultr does not allow sub-domains (e.g. vultr.example.com).
name = "vultr-example.com"
ipv4_address = "${vultr_server.example.ipv4_address}"
}
resource "vultr_dns_record" "test" {
domain = "${vultr_dns_domain.example.name}"
type = "A"
name = "test"
data = "${vultr_server.example.ipv4_address}"
}
resource "vultr_server" "example" {
name = "example created from terraform"
tag = "example tag"
hostname = "test.vultr-example.com"
# set the region. 1 is New Jersey.
# get the list of regions with the command: vultr regions
region_id = 1
# set the plan. 200 is 512 MB RAM,20 GB SSD,0.50 TB BW.
# get the list of plans with the command: vultr plans --region 1
plan_id = 200
# set the OS image. 244 is Debian 9 x64 (stretch).
# get the list of OSs with the command: vultr os
os_id = 244
# enable IPv6.
ipv6 = true
# enable private networking.
private_networking = true
# enable one or more ssh keys on the root account.
ssh_key_ids = ["${vultr_ssh_key.example.id}"]
# execute a command on the local machine.
provisioner "local-exec" {
command = "echo local-exec ${vultr_server.example.ipv4_address}"
}
}