-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathinstance.tf
103 lines (63 loc) · 2.48 KB
/
instance.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
resource "aws_instance" "kubernetes_controllers" {
count=3
ami = "${lookup(var.AMIS, var.AWS_REGION)}"
instance_type = "t2.micro"
key_name = "${aws_key_pair.kubernetes_ec2_key.key_name}"
associate_public_ip_address = "true"
iam_instance_profile="${aws_iam_instance_profile.kubernetes-instance-profile.name}"
vpc_security_group_ids=["${aws_security_group.kubernetes-securitygroup.id}"]
private_ip="${cidrhost(aws_vpc.kubernetes.cidr_block, 10 + count.index)}"
subnet_id="${aws_subnet.kubernetes-public-1.id}"
source_dest_check="false"
tags {
Name = "controller-${count.index}"
Role = "controller"
AnsibleFilter = "${var.ANSIBLE_FILTER}"
AnsibleNodeName = "controller${count.index}"
}
}
resource "aws_instance" "kubernetes_workers" {
count=3
ami = "${lookup(var.AMIS, var.AWS_REGION)}"
instance_type = "t2.micro"
key_name = "${aws_key_pair.kubernetes_ec2_key.key_name}"
associate_public_ip_address = "true"
iam_instance_profile="${aws_iam_instance_profile.kubernetes-instance-profile.name}"
vpc_security_group_ids=["${aws_security_group.kubernetes-securitygroup.id}"]
private_ip="${cidrhost(aws_vpc.kubernetes.cidr_block, 20 + count.index)}"
subnet_id="${aws_subnet.kubernetes-public-1.id}"
source_dest_check="false"
tags {
Name = "worker-${count.index}"
Role = "worker"
AnsibleFilter = "${var.ANSIBLE_FILTER}"
AnsibleNodeName = "worker${count.index}"
}
}
resource "aws_instance" "etcd_cluster_members" {
count=3
ami = "${lookup(var.AMIS, var.AWS_REGION)}"
instance_type = "t2.micro"
key_name = "${aws_key_pair.kubernetes_ec2_key.key_name}"
associate_public_ip_address = "true"
iam_instance_profile="${aws_iam_instance_profile.kubernetes-instance-profile.name}"
vpc_security_group_ids=["${aws_security_group.kubernetes-securitygroup.id}"]
private_ip="${cidrhost(aws_vpc.kubernetes.cidr_block, 30 + count.index)}"
subnet_id="${aws_subnet.kubernetes-public-1.id}"
source_dest_check="false"
tags {
Name = "etcd-${count.index}"
Role = "etcd"
AnsibleFilter = "${var.ANSIBLE_FILTER}"
AnsibleNodeName = "etcd${count.index}"
}
}
output "controller_addresses" {
value = ["Controller IPs: ${aws_instance.kubernetes_controllers.*.private_ip}"]
}
output "worker_addresses" {
value = ["Worker IPs: ${aws_instance.kubernetes_workers.*.private_ip}"]
}
output "etcd_cluster_addresses" {
value = ["Worker IPs: ${aws_instance.etcd_cluster_members.*.private_ip}"]
}