-
Notifications
You must be signed in to change notification settings - Fork 199
/
Copy pathmain.tf
44 lines (37 loc) · 1.12 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
resource "aws_launch_template" "web_server_as" {
name = "myproject"
image_id = "ami-0454e52560c7f5c55"
vpc_security_group_ids = [aws_security_group.web_server.id]
instance_type = "t2.micro"
key_name = "lastone"
tags = {
Name = "DevOps"
}
}
resource "aws_elb" "web_server_lb"{
name = "web-server-lb"
security_groups = [aws_security_group.web_server.id]
subnets = ["subnet-024286466e258f339", "subnet-09558309acf4661a8"]
listener {
instance_port = 8000
instance_protocol = "http"
lb_port = 80
lb_protocol = "http"
}
tags = {
Name = "terraform-elb"
}
}
resource "aws_autoscaling_group" "web_server_asg" {
name = "web-server-asg"
min_size = 1
max_size = 3
desired_capacity = 2
health_check_type = "EC2"
load_balancers = [aws_elb.web_server_lb.name]
availability_zones = ["us-east-1a", "us-east-1b"]
launch_template {
id = aws_launch_template.web_server_as.id
version = "$Latest"
}
}