-
Notifications
You must be signed in to change notification settings - Fork 3
/
control_plane.tf
77 lines (61 loc) · 1.82 KB
/
control_plane.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
77
// hack to get around terraform not allowing variable interpolation
// in aws tags block
locals {
common_tags = {
Name = "control-plane"
"kubernetes.io/cluster/${var.stage}" = "${var.stage}"
}
}
resource "aws_instance" "control_plane" {
ami = "${data.aws_ami.ubuntu.id}"
instance_type = "t2.large"
subnet_id = "${aws_subnet.public.0.id}"
vpc_security_group_ids = ["${aws_security_group.ssh.id}",
"${aws_security_group.icmp.id}",
"${aws_security_group.egress.id}",
"${aws_security_group.kube.id}",
"${aws_security_group.allow_https.id}",
]
source_dest_check = false
iam_instance_profile = "${aws_iam_instance_profile.control_plane.name}"
key_name = "${aws_key_pair.kube.key_name}"
lifecycle {
create_before_destroy = true
}
root_block_device {
volume_type = "gp2"
volume_size = 20
delete_on_termination = true
}
# tags {
# Name = "control-plane"
# "kubernetes.io/cluster/test" = "test"
# }
tags = "${merge(
local.common_tags
)}"
associate_public_ip_address = true
user_data = "${data.template_cloudinit_config.control_plane.rendered}"
connection {
user = "ubuntu"
private_key = "${file("/Users/jamesweber/.ssh/id_rsa")}"
}
}
data "template_file" "control_plane" {
template = "${file("${path.root}/control_plane.tpl")}"
vars {
k8s_token = "${var.k8s_token}"
elb_dnsname = "${var.route53_elb_cname}"
}
}
data "template_cloudinit_config" "control_plane" {
gzip = false
base64_encode = false
part {
content_type = "text/cloud-config"
content = "${data.template_file.control_plane.rendered}"
}
}
output "control_plane.public_ip" {
value = "${aws_instance.control_plane.public_ip}"
}