-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservers.tf
More file actions
48 lines (41 loc) · 1.65 KB
/
Copy pathservers.tf
File metadata and controls
48 lines (41 loc) · 1.65 KB
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
resource "aws_instance" "public_instances" {
count = var.environment == "production" ? 3 : 2
ami = lookup(var.amis, var.aws_region)
availability_zone = element(var.az_name, count.index)
instance_type = "t2.micro"
key_name = "Linux_secfile"
subnet_id = element(aws_subnet.public_subnets[*].id, count.index)
vpc_security_group_ids = ["${aws_security_group.allow_all.id}"]
associate_public_ip_address = true
tags = {
Name = "${var.vpc_name}_Public_Server_${count.index + 1}"
Owner = local.Owner
TeamDL = local.TeamDL
costcenter = local.costcenter
}
}
resource "aws_instance" "private_instances" {
count = var.environment == "production" ? 3 : 2
ami = lookup(var.amis, var.aws_region)
availability_zone = element(var.az_name, count.index)
instance_type = "t2.micro"
key_name = "Linux_secfile"
subnet_id = element(aws_subnet.private_subnets[*].id, count.index)
vpc_security_group_ids = ["${aws_security_group.allow_all.id}"]
tags = {
Name = "${var.vpc_name}_private_Server_${count.index + 1}"
Owner = local.Owner
TeamDL = local.TeamDL
costcenter = local.costcenter
}
user_data = <<-EOF
#!/bin/bash
set -e
sudo apt-get update -y
sudo apt-get install -y nginx
rm -f /var/www/html/index.nginx-debian.html
echo "<h1>It works from user_data on Private_servers!</h1>" > /var/www/html/index.html
sudo systemctl restart nginx
sudo systemctl enable nginx
EOF
}