Skip to content

Commit db0899b

Browse files
committed
API still up for now
Signed-off-by: Irving Popovetsky <[email protected]>
1 parent 6719605 commit db0899b

File tree

4 files changed

+51
-38
lines changed

4 files changed

+51
-38
lines changed

terraform/apps.tf

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,31 @@ resource "aws_iam_role_policy_attachment" "ecs_task_execution_role_attach" {
1919
################################################################################
2020

2121
# Backend Prod
22-
# module "python_backend_prod" {
23-
# source = "./python_backend"
22+
module "python_backend_prod" {
23+
source = "./python_backend"
2424

25-
# env = "prod"
26-
# vpc_id = data.aws_vpc.use2.id
27-
# logs_group = aws_cloudwatch_log_group.ecslogs.name
28-
# ecs_cluster_id = module.ecs.cluster_id
29-
# task_execution_role = data.aws_iam_role.ecs_task_execution_role.arn
30-
# image_tag = "latest"
31-
# }
25+
env = "prod"
26+
vpc_id = data.aws_vpc.use2.id
27+
logs_group = aws_cloudwatch_log_group.ecslogs.name
28+
ecs_cluster_id = module.ecs.cluster_id
29+
task_execution_role = data.aws_iam_role.ecs_task_execution_role.arn
30+
image_tag = "latest"
31+
}
3232

33-
# resource "aws_lb_listener_rule" "python_backend_prod" {
34-
# listener_arn = aws_lb_listener.default_https.arn
33+
resource "aws_lb_listener_rule" "python_backend_prod" {
34+
listener_arn = aws_lb_listener.default_https.arn
3535

36-
# action {
37-
# type = "forward"
38-
# target_group_arn = module.python_backend_prod.lb_tg_arn
39-
# }
36+
action {
37+
type = "forward"
38+
target_group_arn = module.python_backend_prod.lb_tg_arn
39+
}
4040

41-
# condition {
42-
# host_header {
43-
# values = ["backend.operationcode.org", "api.operationcode.org"]
44-
# }
45-
# }
46-
# }
41+
condition {
42+
host_header {
43+
values = ["backend.operationcode.org", "api.operationcode.org"]
44+
}
45+
}
46+
}
4747

4848
# Backend Staging
4949
# module "python_backend_staging" {
@@ -92,8 +92,6 @@ resource "aws_lb_listener_rule" "shutdown_sites_redirector" {
9292
values = [
9393
"resources.operationcode.org",
9494
"resources-staging.operationcode.org",
95-
"api.operationcode.org",
96-
"backend.operationcode.org",
9795
"api.staging.operationcode.org",
9896
]
9997
}

terraform/asg.tf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,21 @@ module "autoscaling" {
107107
# reduce cloudwatch costs
108108
enable_monitoring = false
109109

110+
# Enable essential autoscaling metrics
111+
enabled_metrics = [
112+
"GroupDesiredCapacity",
113+
"GroupInServiceCapacity",
114+
"GroupInServiceInstances",
115+
"GroupMaxSize",
116+
"GroupMinSize",
117+
"GroupPendingCapacity",
118+
"GroupPendingInstances",
119+
"GroupTerminatingCapacity",
120+
"GroupTerminatingInstances",
121+
"GroupTotalCapacity",
122+
"GroupTotalInstances"
123+
]
124+
110125
tags = local.tags
111126
}
112127

terraform/pybot/main.tf

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ locals {
1111

1212
# CHANGEME once infra scales up
1313
cpu = var.env == "prod" ? 256 : 256
14-
memory = var.env == "prod" ? 512 : 256
14+
memory = var.env == "prod" ? 256 : 128
1515
count = var.env == "prod" ? 1 : 1
1616

1717

@@ -52,13 +52,13 @@ resource "aws_ecs_task_definition" "pybot" {
5252
}
5353
}
5454

55-
# healthCheck = {
56-
# command = ["CMD-SHELL", "wget -q http://localhost:5000/health || exit 1"]
57-
# interval = 30
58-
# timeout = 5
59-
# retries = 3
60-
# startPeriod = 60
61-
# }
55+
healthCheck = {
56+
command = ["CMD-SHELL", "wget -q -O /dev/null http://localhost:5000/health"]
57+
interval = 30
58+
timeout = 5
59+
retries = 3
60+
startPeriod = 60
61+
}
6262

6363
secrets = local.secrets_env
6464

terraform/python_backend/main.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ resource "aws_ecs_task_definition" "python_backend" {
5353
}
5454
}
5555

56-
# healthCheck = {
57-
# command = ["CMD-SHELL", "wget -q http://localhost:8000/healthz || exit 1"]
58-
# interval = 30
59-
# timeout = 5
60-
# retries = 3
61-
# startPeriod = 60
62-
# }
56+
healthCheck = {
57+
command = ["CMD-SHELL", "wget -q -O /dev/null http://localhost:8000/healthz"]
58+
interval = 30
59+
timeout = 5
60+
retries = 3
61+
startPeriod = 60
62+
}
6363

6464
environment = [
6565
{

0 commit comments

Comments
 (0)