-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.tf
66 lines (59 loc) · 1.67 KB
/
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
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
resource "scaleway_instance_ip" "public_ip" {
count = 3
}
resource "scaleway_instance_security_group" "sg" {
inbound_default_policy = "accept"
outbound_default_policy = "accept"
}
resource "scaleway_vpc_private_network" "network" {
name = "${var.name}-private_network"
}
resource "scaleway_instance_server" "master" {
name = "${var.name}-master"
type = "DEV1-S"
image = "ubuntu_focal"
ip_id = scaleway_instance_ip.public_ip[2].id
tags = ["CKA", "LABS", "PIERRE"]
user_data = {
docker = "installed"
cloud-init = file("setup-master.sh")
}
private_network {
pn_id = scaleway_vpc_private_network.network.id
}
security_group_id = scaleway_instance_security_group.sg.id
}
resource "scaleway_instance_server" "worker" {
count = 2
name = "${var.name}-worker-${count.index}"
type = "DEV1-S"
image = "ubuntu_focal"
ip_id = scaleway_instance_ip.public_ip[count.index].id
tags = ["CKA", "LABS", "PIERRE"]
user_data = {
docker = "installed"
cloud-init = file("setup-worker.sh")
}
private_network {
pn_id = scaleway_vpc_private_network.network.id
}
security_group_id = scaleway_instance_security_group.sg.id
}
output "public_ip_master" {
value = scaleway_instance_server.master.public_ip
}
output "public_ip_worker1" {
value = scaleway_instance_server.worker[0].public_ip
}
output "public_ip_worker2" {
value = scaleway_instance_server.worker[1].public_ip
}
output "private_ip_master" {
value = scaleway_instance_server.master.private_ip
}
output "private_ip_worker1" {
value = scaleway_instance_server.worker[0].private_ip
}
output "private_ip_worker2" {
value = scaleway_instance_server.worker[1].private_ip
}