-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.tf
130 lines (118 loc) · 4.21 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
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
119
120
121
122
123
124
125
126
127
128
129
130
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "4.16.0"
}
}
# Required version of Terraform
required_version = "~> 1.1.5"
}
# AWS provider with region and profile set to the
# region and aws_profile variables
provider "aws" {
region = var.region
profile = var.aws_profile
endpoints {
sts = "https://sts.${var.region}.amazonaws.com"
}
}
# The VPC module
# Points to main.tf in modules/vpc and passes in
# all the necessary variables
module "vpc" {
source = "./modules/vpc"
prefix = var.prefix
region = var.region
vpc_cidr_block = var.vpc_cidr_block
public_subnets = var.public_subnets
private_subnets = var.private_subnets
public_subnet_blocks = var.public_subnet_blocks
private_subnet_blocks = var.private_subnet_blocks
vpc_endpoints_sg = module.security_groups.vpc_endpoints
}
# The Securiy Group module
# Points to main.tf in modules/security_groups
# and passes in all the necessary variables
module "security_groups" {
source = "./modules/security_groups"
prefix = var.prefix
vpc_id = module.vpc.vpc_id
jenkins_controller_port = var.jenkins_controller_port
jenkins_agent_port = var.jenkins_agent_port
}
# The ECR module
# Points to main.tf in modules/ecr
# and passes in all the necessary variables
module "ecr" {
source = "./modules/ecr"
jenkins_agent_port = var.jenkins_agent_port
jenkins_controller_port = var.jenkins_controller_port
jenkins_agent_cluster = module.ecs.jenkins_agents_cluster
jenkins_agent_sg = module.security_groups.jenkins_agents
jenkins_dns = module.cloud_map.jenkins_controller_dns_endpoint
jenkins_log_group = module.cloudwatch.jenkins_log_group
jenkins_agent_log_stream = module.cloudwatch.jenkins_agent_log_stream
jenkins_execution_role = module.iam.jenkinsExecutionRole
private_subnets = module.vpc.private_subnets
}
# The EFS module
# Points to main.tf in modules/efs
# and passes in all the necessary variables
module "efs" {
source = "./modules/efs"
prefix = var.prefix
efs_sg = module.security_groups.jenkins_efs
private_subnets = module.vpc.private_subnets
}
# The ELB module
# Points to main.tf in modules/elb
# and passes in all the necessary variables
module "elb" {
source = "./modules/elb"
prefix = var.prefix
jenkins_alb_sg = module.security_groups.jenkins_alb
vpc_id = module.vpc.vpc_id
public_subnets = module.vpc.public_subnets
}
# The ECS module
# Points to main.tf in modules/ecs
# and passes in all the necessary variables
module "ecs" {
source = "./modules/ecs"
prefix = var.prefix
jenkins_controller_cpu = var.jenkins_controller_cpu
jenkins_controller_mem = var.jenkins_controller_mem
jenkins_controller_port = var.jenkins_controller_port
jenkins_agent_port = var.jenkins_agent_port
jenkins_repo = module.ecr.jenkins_repo_url
jenkins_efs = module.efs.efs
jenkins_efs_ap = module.efs.efs_ap
jenkins_alb_tg = module.elb.alb_tg_arn
jenkins_controller_sg = module.security_groups.jenkins_controller
jenkins_log_group = module.cloudwatch.jenkins_log_group
jenkins_log_stream = module.cloudwatch.jenkins_controller_log_stream
jenkins_controller_dns_arn = module.cloud_map.jenkins_controller_dns_arn
private_subnets = module.vpc.private_subnets
execution_role_arn = module.iam.jenkinsExecutionRole
}
# The CloudWatch module
# Points to main.tf in modules/cloudwatch
# and passes in all the necessary variables
module "cloudwatch" {
source = "./modules/cloudwatch"
prefix = var.prefix
}
# The IAM module
# Points to main.tf in modules/iam
module "iam" {
source = "./modules/iam"
}
# The Cloud Map module
# Points to main.tf in modules/cloud_map
# and passes in all the necessary variables
module "cloud_map" {
source = "./modules/cloud_map"
vpc_id = module.vpc.vpc_id
prefix = var.prefix
}