-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
70 lines (52 loc) · 1.95 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
59
60
61
62
63
64
65
66
67
68
69
70
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.16"
}
}
required_version = ">= 1.3.5"
}
module "vpc" {
source = "./modules/vpc"
}
module "rds" {
source = "./modules/rds"
subnet_ids = ["${module.vpc.private_subnet_id_a}","${module.vpc.private_subnet_id_b}"]
rds_sub_groups_id = module.rds.rds_sub_groups_id
aws_security_group_ec2 = module.vpc.security_group_ec2_id
aws_security_group_rds = module.vpc.aws_security_group_rds_id
depends_on = [module.vpc]
}
module "elasticache" {
source = "./modules/elasticache"
private_subnet_id_a = module.vpc.private_subnet_id_a
private_subnet_id_b = module.vpc.private_subnet_id_b
depends_on = [module.vpc, module.rds]
}
module "efs" {
source = "./modules/efs"
private_subnet_id_a = module.vpc.private_subnet_id_a
private_subnet_id_b = module.vpc.private_subnet_id_b
vpc_id = module.vpc.vpc_id
aws_security_group_efs = module.vpc.aws_security_group_efs_id
depends_on = [module.vpc]
}
/**
* https://developer.hashicorp.com/terraform/language/functions/element
*/
module "ec2_instance" {
source = "./modules/ec2"
vpc_id = module.vpc.vpc_id
public_subnet_id_a = module.vpc.public_subnet_id_a
public_subnet_id_b = module.vpc.public_subnet_id_b
private_subnet_id_a = module.vpc.private_subnet_id_a
private_subnet_id_b = module.vpc.private_subnet_id_b
subnet_id = "${element(module.vpc.public_subnet_ids,module.ec2_instance.count_instances)}"
aws_security_group_ec2 = module.vpc.security_group_ec2_id
dns_efs = module.efs.dns_name
depends_on = [module.vpc,module.rds, module.elasticache, module.efs]
}
module "s3" {
source = "./modules/s3"
}