Skip to content

Commit 321ed6f

Browse files
ronaldo-macapobreRonaldo Macapobre
andauthored
Apply infra dev changes to test and prod (#640)
Co-authored-by: Ronaldo Macapobre <rmacapob@gov.bc.ca>
1 parent 39724a7 commit 321ed6f

File tree

6 files changed

+88
-22
lines changed

6 files changed

+88
-22
lines changed

infrastructure/cloud/environments/prod/main.tf

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,33 @@ module "alb" {
135135
tg_api_arn = module.tg_api.tg_arn
136136
}
137137

138+
# Setup EFS Files storage
139+
module "efs_files" {
140+
source = "../../modules/EFS"
141+
environment = var.environment
142+
app_name = var.app_name
143+
name = var.efs_config.files_dir
144+
purpose = "Temporary file storage when accessing court files."
145+
subnet_ids = module.subnets.app_subnets_ids
146+
security_group_ids = [data.aws_security_group.app_sg.id]
147+
kms_key_arn = module.initial.kms_key_arn
148+
}
149+
138150
# Create Lambda Functions
139151
module "lambda" {
140-
source = "../../modules/Lambda"
141-
environment = var.environment
142-
app_name = var.app_name
143-
lambda_role_arn = module.iam.lambda_role_arn
144-
apigw_execution_arn = module.apigw.apigw_execution_arn
145-
lambda_ecr_repo_url = module.initial.lambda_ecr.ecr_repo_url
146-
lambda_memory_size = var.lambda_memory_size
147-
subnet_ids = module.subnets.all_subnet_ids
148-
sg_ids = [data.aws_security_group.web_sg.id, data.aws_security_group.data_sg.id, data.aws_security_group.app_sg.id]
149-
lambda_secrets = module.secrets_manager.lambda_secrets
150-
ecs_cluster_name = module.ecs_cluster.ecs_cluster.name
152+
source = "../../modules/Lambda"
153+
environment = var.environment
154+
app_name = var.app_name
155+
lambda_role_arn = module.iam.lambda_role_arn
156+
apigw_execution_arn = module.apigw.apigw_execution_arn
157+
lambda_ecr_repo_url = module.initial.lambda_ecr.ecr_repo_url
158+
lambda_memory_size = var.lambda_memory_size
159+
subnet_ids = module.subnets.all_subnet_ids
160+
sg_ids = [data.aws_security_group.web_sg.id, data.aws_security_group.data_sg.id, data.aws_security_group.app_sg.id]
161+
lambda_secrets = module.secrets_manager.lambda_secrets
162+
ecs_cluster_name = module.ecs_cluster.ecs_cluster.name
163+
efs_access_point_arn = module.efs_files.access_point_arn
164+
efs_mount_path = var.efs_config.mount_path
151165
}
152166

153167
# Create Cloudwatch LogGroups
@@ -266,6 +280,13 @@ module "ecs_api_td" {
266280
log_group_name = module.ecs_api_td_log_group.log_group.name
267281
cpu = var.api_ecs_config.cpu
268282
memory_size = var.api_ecs_config.memory_size
283+
efs_volume_config = {
284+
name = "efs-files-storage"
285+
file_system_id = module.efs_files.efs_id
286+
access_point_id = module.efs_files.access_point_id
287+
root_directory = var.efs_config.files_dir
288+
container_path = var.efs_config.mount_path
289+
}
269290
}
270291

271292
# Create Web ECS Service

infrastructure/cloud/environments/prod/prod.tfvars

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ alarm_config = {
3434
task_evaluation_periods = 1
3535
task_period = 30
3636
}
37+
efs_config = {
38+
mount_path = "/mnt/efs"
39+
files_dir = "files"
40+
}

infrastructure/cloud/environments/prod/variables.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,11 @@ variable "api_ecs_config" {
135135
memory_size = number
136136
})
137137
}
138+
139+
variable "efs_config" {
140+
description = "EFS configuration"
141+
type = object({
142+
mount_path = string
143+
files_dir = string
144+
})
145+
}

infrastructure/cloud/environments/test/main.tf

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,33 @@ module "alb" {
135135
tg_api_arn = module.tg_api.tg_arn
136136
}
137137

138+
# Setup EFS Files storage
139+
module "efs_files" {
140+
source = "../../modules/EFS"
141+
environment = var.environment
142+
app_name = var.app_name
143+
name = var.efs_config.files_dir
144+
purpose = "Temporary file storage when accessing court files."
145+
subnet_ids = module.subnets.app_subnets_ids
146+
security_group_ids = [data.aws_security_group.app_sg.id]
147+
kms_key_arn = module.initial.kms_key_arn
148+
}
149+
138150
# Create Lambda Functions
139151
module "lambda" {
140-
source = "../../modules/Lambda"
141-
environment = var.environment
142-
app_name = var.app_name
143-
lambda_role_arn = module.iam.lambda_role_arn
144-
apigw_execution_arn = module.apigw.apigw_execution_arn
145-
lambda_ecr_repo_url = module.initial.lambda_ecr.ecr_repo_url
146-
lambda_memory_size = var.lambda_memory_size
147-
subnet_ids = module.subnets.all_subnet_ids
148-
sg_ids = [data.aws_security_group.web_sg.id, data.aws_security_group.data_sg.id, data.aws_security_group.app_sg.id]
149-
lambda_secrets = module.secrets_manager.lambda_secrets
150-
ecs_cluster_name = module.ecs_cluster.ecs_cluster.name
152+
source = "../../modules/Lambda"
153+
environment = var.environment
154+
app_name = var.app_name
155+
lambda_role_arn = module.iam.lambda_role_arn
156+
apigw_execution_arn = module.apigw.apigw_execution_arn
157+
lambda_ecr_repo_url = module.initial.lambda_ecr.ecr_repo_url
158+
lambda_memory_size = var.lambda_memory_size
159+
subnet_ids = module.subnets.all_subnet_ids
160+
sg_ids = [data.aws_security_group.web_sg.id, data.aws_security_group.data_sg.id, data.aws_security_group.app_sg.id]
161+
lambda_secrets = module.secrets_manager.lambda_secrets
162+
ecs_cluster_name = module.ecs_cluster.ecs_cluster.name
163+
efs_access_point_arn = module.efs_files.access_point_arn
164+
efs_mount_path = var.efs_config.mount_path
151165
}
152166

153167
# Create Cloudwatch LogGroups
@@ -266,6 +280,13 @@ module "ecs_api_td" {
266280
log_group_name = module.ecs_api_td_log_group.log_group.name
267281
cpu = var.api_ecs_config.cpu
268282
memory_size = var.api_ecs_config.memory_size
283+
efs_volume_config = {
284+
name = "efs-files-storage"
285+
file_system_id = module.efs_files.efs_id
286+
access_point_id = module.efs_files.access_point_id
287+
root_directory = var.efs_config.files_dir
288+
container_path = var.efs_config.mount_path
289+
}
269290
}
270291

271292
# Create Web ECS Service

infrastructure/cloud/environments/test/test.tfvars

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ alarm_config = {
3434
task_evaluation_periods = 1
3535
task_period = 30
3636
}
37+
efs_config = {
38+
mount_path = "/mnt/efs"
39+
files_dir = "files"
40+
}

infrastructure/cloud/environments/test/variables.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,11 @@ variable "api_ecs_config" {
135135
memory_size = number
136136
})
137137
}
138+
139+
variable "efs_config" {
140+
description = "EFS configuration"
141+
type = object({
142+
mount_path = string
143+
files_dir = string
144+
})
145+
}

0 commit comments

Comments
 (0)