-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdata.tf
76 lines (69 loc) · 2.06 KB
/
data.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
71
72
73
74
75
76
data "aws_ami" "default_ami" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-20220420"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
owners = ["099720109477"]
}
data "template_file" "init-master" {
template = file("${path.module}/files/k3s.tpl.sh")
count = var.master_node_count
vars = {
instance_role = "master"
instance_index = count.index
k3s_server_token = random_password.k3s_server_token.result
k3s_version = var.k3s_version
cluster_name = var.cluster_name
cluster_domain = local.cluster_domain
s3_bucket = var.s3_bucket
node_labels = local.master_node_labels
node_taints = local.master_node_taints
extra_args = "${local.custom_args} ${local.extra_api_args}"
kubeconfig_name = local.s3_kubeconfig_filename
}
}
data "template_cloudinit_config" "init-master" {
gzip = true
base64_encode = true
count = var.master_node_count
part {
content = data.template_file.init-master[count.index].rendered
content_type = "text/x-shellscript"
}
}
data "template_cloudinit_config" "init-worker" {
for_each = local.worker_groups_map
gzip = true
base64_encode = true
part {
content = data.template_file.init-worker[each.key].rendered
content_type = "text/x-shellscript"
}
}
data "template_file" "init-worker" {
for_each = local.worker_groups_map
template = file("${path.module}/files/k3s.tpl.sh")
vars = {
instance_role = "worker"
instance_index = "null"
k3s_server_token = random_password.k3s_server_token.result
k3s_version = var.k3s_version
cluster_domain = local.cluster_domain
node_labels = each.value.node_labels
node_taints = each.value.node_taints
}
}
resource "random_password" "k3s_server_token" {
length = 30
special = false
}
data "aws_route53_zone" "main_zone" {
count = var.domain == "" ? 0 : 1
name = var.domain
private_zone = false
}