-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
118 lines (98 loc) · 3.18 KB
/
Copy pathmain.tf
File metadata and controls
118 lines (98 loc) · 3.18 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
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
locals {
name_prefix = "${var.project_name}-${var.environment}"
common_tags = {
Project = var.project_name
Environment = var.environment
ManagedBy = "Terraform"
}
}
module "vpc" {
source = "./modules/vpc"
name_prefix = local.name_prefix
vpc_cidr = var.vpc_cidr
azs = var.azs
public_subnet_cidrs = var.public_subnet_cidrs
private_subnet_cidrs = var.private_subnet_cidrs
enable_nat_gateway = var.enable_nat_gateway
tags = local.common_tags
}
module "security" {
source = "./modules/security"
name_prefix = local.name_prefix
vpc_id = module.vpc.vpc_id
tags = local.common_tags
}
module "s3" {
source = "./modules/s3"
name_prefix = local.name_prefix
project_name = var.project_name
environment = var.environment
bucket_base_name = var.s3_bucket_name
tags = local.common_tags
}
module "iam" {
source = "./modules/iam"
name_prefix = local.name_prefix
app_bucket_name = module.s3.bucket_name
backend_bucket_name = var.backend_bucket_name
environment = var.environment
tags = local.common_tags
}
module "sns" {
source = "./modules/sns"
name_prefix = local.name_prefix
subscription_email = var.notification_email
tags = local.common_tags
}
module "alb" {
source = "./modules/alb"
name_prefix = local.name_prefix
vpc_id = module.vpc.vpc_id
subnet_ids = module.vpc.public_subnet_ids
sg_id = module.security.alb_sg
tags = local.common_tags
}
module "ec2" {
source = "./modules/ec2"
name_prefix = local.name_prefix
project_name = var.project_name
environment = var.environment
aws_region = var.aws_region
subnet_ids = module.vpc.private_subnet_ids
instance_type = var.instance_type
sg_id = module.security.ec2_sg
target_group_arn = module.alb.target_group_arn
desired_capacity = var.desired_capacity
max_size = var.max_size
min_size = var.min_size
instance_profile = module.iam.instance_profile
sns_topic_arn = module.sns.topic_arn
app_bucket_name = module.s3.bucket_name
backend_bucket_name = var.backend_bucket_name
tags = local.common_tags
}
module "lambda" {
source = "./modules/lambda"
name_prefix = local.name_prefix
project_name = var.project_name
environment = var.environment
app_bucket_name = module.s3.bucket_name
app_bucket_arn = module.s3.bucket_arn
autoscaling_group_name = module.ec2.asg_name
log_retention_days = var.lambda_log_retention_days
tags = local.common_tags
}
module "cloudwatch" {
source = "./modules/cloudwatch"
name_prefix = local.name_prefix
autoscaling_group_name = module.ec2.asg_name
alb_arn_suffix = module.alb.alb_arn_suffix
target_group_arn_suffix = module.alb.target_group_arn_suffix
sns_topic_arn = module.sns.topic_arn
cpu_threshold = var.cpu_alarm_threshold
tags = local.common_tags
depends_on = [
module.ec2,
module.alb
]
}