-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.tf
38 lines (36 loc) · 919 Bytes
/
main.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
# Create a server
variable "DO_TOKEN" {}
provider "digitalocean" {
token = var.DO_TOKEN
}
#NYC region
resource "digitalocean_droplet" "nyc1" {
name = "${format("compute-%03d", count.index)}-nyc1"
region = "nyc1"
count = 2
image = "ubuntu-20-04-x64"
size = "s-2vcpu-4gb"
user_data = file("cloudinit.yml")
}
#TOR1 region
resource "digitalocean_droplet" "tor1" {
name = "${format("compute-%03d", count.index)}-tor1"
region = "tor1"
count = 2
image = "ubuntu-20-04-x64"
size = "s-2vcpu-4gb"
user_data = file("cloudinit.yml")
}
#Print the IP addresses of the newly create Vms
output "Toronto_droplet_ip_addresses" {
value = {
for droplet in digitalocean_droplet.tor1:
droplet.name => droplet.ipv4_address
}
}
output "NewYork_droplet_ip_addresses" {
value = {
for droplet in digitalocean_droplet.nyc1:
droplet.name => droplet.ipv4_address
}
}