Skip to content

Commit 52b0205

Browse files
authored
Merge pull request #72 from companieshouse/ASM-575/move-ocr-api-to-new-ecs-cluster
ASM-575 Amending the ECS service to match recent standards.
2 parents 9399e1a + 16f4d4f commit 52b0205

File tree

7 files changed

+22
-62
lines changed

7 files changed

+22
-62
lines changed

terraform/groups/ecs-service/data.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ data "aws_iam_role" "ecs_cluster_iam_role" {
3434
}
3535

3636
data "aws_lb" "service_lb" {
37-
name = "${var.environment}-chs-internalapi"
37+
name = "alb-${var.environment}-ocr-api"
3838
}
3939

4040
data "aws_lb_listener" "service_lb_listener" {

terraform/groups/ecs-service/locals.tf

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ locals {
55
global_prefix = "global-${var.environment}"
66
service_name = "ocr-api"
77
container_port = 8080
8-
eric_port = "10000"
98
docker_repo = "ocr-api"
109
kms_alias = "alias/${var.aws_profile}/environment-services-kms"
1110
lb_listener_rule_priority = 24
@@ -61,12 +60,8 @@ locals {
6160
# secrets to go in list
6261
task_secrets = concat(local.global_secret_list,local.service_secret_list)
6362

64-
task_environment = concat(local.ssm_global_version_map,local.ssm_service_version_map)
63+
task_environment = concat(local.ssm_global_version_map,local.ssm_service_version_map,[
64+
{ "name" : "PORT", "value" : local.container_port }
65+
])
6566

66-
# get eric secrets from global secrets map
67-
eric_secrets = [
68-
{ "name": "API_KEY", "valueFrom": local.global_secrets_arn_map.eric_api_key },
69-
{ "name": "AES256_KEY", "valueFrom": local.global_secrets_arn_map.eric_aes256_key }
70-
]
71-
eric_environment_filename = "eric.env"
7267
}

terraform/groups/ecs-service/main.tf

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@ terraform {
1919
}
2020

2121
module "secrets" {
22-
source = "[email protected]:companieshouse/terraform-modules//aws/ecs/secrets?ref=1.0.294"
22+
source = "[email protected]:companieshouse/terraform-modules//aws/parameter-store?ref=1.0.361"
2323

2424
name_prefix = "${local.service_name}-${var.environment}"
25-
environment = var.environment
2625
kms_key_id = data.aws_kms_key.kms_key.id
2726
secrets = nonsensitive(local.service_secrets)
2827
}
2928

3029
module "ecs-service" {
31-
source = "[email protected]:companieshouse/terraform-modules//aws/ecs/ecs-service?ref=1.0.294"
30+
source = "[email protected]:companieshouse/terraform-modules//aws/ecs/ecs-service?ref=1.0.361"
3231

3332
# Environmental configuration
3433
environment = var.environment
@@ -42,7 +41,7 @@ module "ecs-service" {
4241
lb_listener_arn = data.aws_lb_listener.service_lb_listener.arn
4342
lb_listener_rule_priority = local.lb_listener_rule_priority
4443
lb_listener_paths = local.lb_listener_paths
45-
health_check_grace_period_seconds = 240
44+
health_check_grace_period_seconds = 300
4645
healthcheck_healthy_threshold = "2"
4746

4847
# ECS Task container health check
@@ -59,6 +58,8 @@ module "ecs-service" {
5958
# Service configuration
6059
service_name = local.service_name
6160
name_prefix = local.name_prefix
61+
62+
# Service performance and scaling configs
6263
desired_task_count = var.desired_task_count
6364
max_task_count = var.max_task_count
6465
min_task_count = var.min_task_count
@@ -82,11 +83,6 @@ module "ecs-service" {
8283
use_set_environment_files = local.use_set_environment_files
8384

8485
# eric options for eric running API module
85-
use_eric_reverse_proxy = true
86-
eric_version = var.eric_version
87-
eric_cpus = var.eric_cpus
88-
eric_memory = var.eric_memory
89-
eric_port = local.eric_port
90-
eric_environment_filename = local.eric_environment_filename
91-
eric_secrets = local.eric_secrets
86+
use_eric_reverse_proxy = false
87+
9288
}

terraform/groups/ecs-service/profiles/development-eu-west-2/cidev/vars

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
environment = "cidev"
22
aws_profile = "development-eu-west-2"
33

4-
# service configs
5-
log_level = "debug"
4+
required_cpus = 2048
5+
required_memory = 4096
66

77
# scaling configs
88
service_scaledown_schedule = "55 19 * * ? *"
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
environment = "live"
22
aws_profile = "live-eu-west-2"
33

4-
# service configs
5-
log_level = "info"
6-
7-
required_cpus = 7936
8-
required_memory = 31744
9-
10-
desired_task_count = 2
11-
max_task_count = 3
12-
min_task_count = 2
4+
required_cpus = 4096
5+
required_memory = 8192
136

147
# scaling configs
158
desired_task_count = 2 # use multi instance in Live
9+
min_task_count = 2
10+
max_task_count = 3

terraform/groups/ecs-service/profiles/staging-eu-west-2/staging/vars

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
environment = "staging"
22
aws_profile = "staging-eu-west-2"
33

4-
# service configs
5-
log_level = "debug"
6-
7-
required_cpus = 7936
8-
required_memory = 31744
4+
required_cpus = 4096
5+
required_memory = 8192
96

107
# scaling configs
118
service_scaledown_schedule = "55 19 * * ? *"

terraform/groups/ecs-service/variables.tf

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,31 +50,19 @@ variable "min_task_count" {
5050
variable "required_cpus" {
5151
type = number
5252
description = "The required cpu resource for this service. 1024 here is 1 vCPU"
53-
default = 1792 # current cpu used by legacy ocr api service pipeline
53+
default = 2048 # current cpu used by legacy ocr api service pipeline
5454
}
5555

5656
variable "required_memory" {
5757
type = number
5858
description = "The required memory for this service"
59-
default = 7168 # current memory used by legacy ocr api service pipeline
60-
}
61-
62-
variable "eric_cpus" {
63-
type = number
64-
description = "The required cpu resource for eric. 1024 here is 1 vCPU"
65-
default = 256
66-
}
67-
68-
variable "eric_memory" {
69-
type = number
70-
description = "The required memory for eric"
71-
default = 512
59+
default = 7680 # current memory used by legacy ocr api service pipeline
7260
}
7361

7462
variable "use_fargate" {
7563
type = bool
7664
description = "If true, sets the required capabilities for all containers in the task definition to use FARGATE, false uses EC2"
77-
default = false
65+
default = true
7866
}
7967

8068
variable "use_capacity_provider" {
@@ -135,14 +123,3 @@ variable "ocr_api_version" {
135123
type = string
136124
description = "The version of the ocr-api container to run."
137125
}
138-
139-
variable "log_level" {
140-
default = "info"
141-
type = string
142-
description = "The log level for services to use: trace, debug, info or error"
143-
}
144-
145-
variable "eric_version" {
146-
type = string
147-
description = "The version of the eric container to run."
148-
}

0 commit comments

Comments
 (0)