-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
33 lines (28 loc) · 868 Bytes
/
main.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
locals {
vm_name = var.vm_name
}
resource "aws_instance" "vm" {
depends_on = [aws_efs_file_system.efs]
count = 2
ami = data.aws_ami.ubuntu.id
instance_type = var.instance_type
key_name = var.key_name
subnet_id = var.subnet_id1d
security_groups = [aws_security_group.vmsg.id]
#security_groups = [var.sg_id]
#user_data = data.template_file.user_data.rendered
user_data = <<EOF
mkdir /efs
mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport "${aws_efs_file_system.efs.dns_name}":/ /efs
echo "${aws_efs_file_system.efs.dns_name}:/ /efs nfs4 defaults,_netdev 0 0" >> /etc/fstab
EOF
associate_public_ip_address = false
root_block_device {
volume_type = "standard"
volume_size = 100
delete_on_termination = "false"
}
tags = {
Name = "${local.vm_name}${count.index + 1}"
}
}