-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
58 lines (48 loc) · 1.84 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
resource "aws_default_vpc" "main" {}
resource "aws_default_subnet" "main" {
for_each = toset(var.subnets_to_use)
availability_zone = "${var.region}${each.value}"
}
module "alb" {
source = "./modules/alb"
env = var.env
subnets_to_use = [for s in aws_default_subnet.main : s.id]
vpc_id = aws_default_vpc.main.id
}
module "asg" {
source = "./modules/asg"
efs_dns_name = module.efs.dns_name
efs_mount_point = "/var/www/html"
env = var.env
min_size = var.asg_min_size
max_size = var.asg_max_size
desired_capacity = var.asg_desired_capacity
instance_type = var.asg_instance_type
subnets_to_use = [for s in aws_default_subnet.main : s.id]
elb_security_group_id = module.alb.security_group_id
target_group_arns = module.alb.target_group_arns
db_name = var.db_name
db_username = var.db_username
db_ip = module.rds.db_ip
ssm_db_password = module.rds.ssm_db_password
ssm_region = var.region
cpu_metric_down_threshold = var.asg_cpu_metric_down_threshold
cpu_metric_period = var.asg_cpu_metric_period
cpu_metric_up_threshold = var.asg_cpu_metric_up_threshold
}
module "efs" {
source = "./modules/efs"
available_subnets = [for s in aws_default_subnet.main : s.id]
env = var.env
trusted_sgs = [module.asg.asg_security_group_id]
}
module "rds" {
source = "./modules/rds"
available_subnets = [for s in aws_default_subnet.main : s.id]
db_name = var.db_name
db_username = var.db_username
engine_version = var.db_engine_version
env = var.env
instance_class = var.db_instance_class
trusted_sgs = [module.asg.asg_security_group_id]
}