-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoscaling.tf
71 lines (61 loc) · 1.61 KB
/
autoscaling.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
provider "aws" {
region = "${var.region}"
}
resource "aws_launch_configuration" "example" {
image_id = "${lookup(var.amis,var.region)}"
instance_type = "t2.micro"
security_groups = ["${aws_security_group.instance.id}"]
key_name = "webservers"
user_data = "${file("userdata.sh")}"
lifecycle {
create_before_destroy = true
}
}
resource "aws_autoscaling_group" "example" {
launch_configuration = "${aws_launch_configuration.example.id}"
availability_zones = data.aws_availability_zones.all.names
min_size = 1
max_size = 1
load_balancers = ["${aws_elb.example.name}"]
health_check_type = "ELB"
tags = [
{
key = "Name"
value = "PlayQ-2019"
propagate_at_launch = true
},
{
key = "Type"
value = "webserver"
propagate_at_launch = true
},
]
}
resource "aws_security_group" "instance" {
name = "terraform-example-instance"
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["${cidrhost("${var.myaddr}/${var.bits}", 0)}/${var.bits}"]
}
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["${cidrhost("${var.PlayQaddr}/${var.bits}", 0)}/${var.bits}"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
data "aws_availability_zones" "all" {}