forked from ViktorUJ/cks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathec2_master_ondemand.tf
50 lines (45 loc) · 1.87 KB
/
ec2_master_ondemand.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
resource "aws_instance" "master" {
for_each = toset(var.node_type == "ondemand" ? ["enable"] : [])
iam_instance_profile = aws_iam_instance_profile.server.id
associate_public_ip_address = "true"
ami = local.master_ami
instance_type = var.k8s_master.instance_type
subnet_id = local.subnets[var.k8s_master.subnet_number]
key_name = var.k8s_master.key_name != "" ? var.k8s_master.key_name : null
security_groups = [aws_security_group.servers.id]
lifecycle {
ignore_changes = [
instance_type,
user_data,
root_block_device,
key_name,
security_groups
]
}
user_data = base64encode(templatefile("template/boot_zip.sh", {
boot_zip = base64gzip(templatefile(var.k8s_master.user_data_template, {
worker_join = local.worker_join
k8s_config = local.k8s_config
external_ip = local.external_ip
k8_version = var.k8s_master.k8_version
runtime = var.k8s_master.runtime
utils_enable = var.k8s_master.utils_enable
pod_network_cidr = var.k8s_master.pod_network_cidr
runtime_script = file(var.k8s_master.runtime_script)
task_script_url = var.k8s_master.task_script_url
calico_url = var.k8s_master.calico_url
ssh_private_key = var.k8s_master.ssh.private_key
ssh_pub_key = var.k8s_master.ssh.pub_key
ssh_password = random_string.ssh.result
ssh_password_enable = var.ssh_password_enable
}))
}))
tags = local.tags_all
root_block_device {
volume_size = var.k8s_master.root_volume.size
volume_type = var.k8s_master.root_volume.type
delete_on_termination = true
tags = local.tags_all
encrypted = true
}
}