-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaws_instance.tf
36 lines (31 loc) · 1.04 KB
/
aws_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
resource "aws_instance" "master" {
ami = data.aws_ami.linux.id
instance_type = var.master_instance_type
key_name = var.key_name
vpc_security_group_ids = [aws_security_group.tf-k8s-sec-gr.id]
iam_instance_profile = aws_iam_instance_profile.ec2sshprofile.name
user_data = file("master-init-script.sh")
tags = {
Name = "k8s-master"
}
}
resource "aws_instance" "worker" {
count = var.worker_count
ami = data.aws_ami.linux.id
instance_type = var.worker_instance_type
key_name = var.key_name
vpc_security_group_ids = [aws_security_group.tf-k8s-sec-gr.id]
iam_instance_profile = aws_iam_instance_profile.ec2sshprofile.name
user_data = templatefile(
"worker-init-script.tftpl",
{
region = var.aws_region
master-id = aws_instance.master.id
master-private = aws_instance.master.private_ip
}
)
tags = {
Name = "k8s-worker-${count.index + 1}"
}
depends_on = [aws_instance.master]
}