forked from sezginmutlu/terraform-project1-3-tier-app
-
Notifications
You must be signed in to change notification settings - Fork 1
/
asg.tf
75 lines (60 loc) · 1.92 KB
/
asg.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
72
73
74
75
# Creates ASG with launch configuration
#Gets ubuntu AMI information
data "aws_ami" "ubuntu" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
owners = ["099720109477"] # Canonical
}
resource "aws_launch_configuration" "as_conf" {
name = "web_config"
image_id = "${data.aws_ami.ubuntu.id}"
instance_type = "t2.micro"
}
module "dev" {
name = "wordpress"
source = "terraform-aws-modules/autoscaling/aws"
version = "2.12.0"
# Launch configuration
lc_name = "wordpress-lc"
image_id = "${data.aws_ami.ubuntu.id}"
key_name = "${aws_key_pair.team4.key_name}"
instance_type = "t2.micro"
associate_public_ip_address = true
security_groups =[
"${data.terraform_remote_state.dev.sec_group_1}",
"${data.terraform_remote_state.dev.sec_group_2}"
]
# Auto scaling group
asg_name = "wordpress-asg"
vpc_zone_identifier = [
"${data.terraform_remote_state.dev.Subnet1}", ### ???
"${data.terraform_remote_state.dev.Subnet2}",
"${data.terraform_remote_state.dev.Subnet3}",
]
health_check_type = "EC2"
min_size = 3
max_size = 48
desired_capacity = 3
wait_for_capacity_timeout = 0
user_data = "${file("./wordpress.sh")}"
# "${file("wordpress.sh")}"
tags = [
{
key = "Environment"
value = "dev"
propagate_at_launch = true
},
{
key = "Project"
value = "megasecret"
propagate_at_launch = true
},
]
}