diff --git a/concepts/src/app.ts b/concepts/src/app.ts index 78e8fcc030..3df62b6209 100644 --- a/concepts/src/app.ts +++ b/concepts/src/app.ts @@ -5,6 +5,7 @@ import { conceptController, conceptsController, errorHandler, + healthcheckController, } from "./controllers"; import { Config } from "../config"; import { Clients } from "./types"; @@ -16,6 +17,7 @@ const createApp = (clients: Clients, config: Config) => { app.get("/concepts", conceptsController(clients, config)); app.get("/concepts/:id", conceptController(clients, config)); + app.get("/management/healthcheck", healthcheckController(config)); app.use(errorHandler); diff --git a/concepts/src/controllers/healthcheck.ts b/concepts/src/controllers/healthcheck.ts new file mode 100644 index 0000000000..b1c5c6e415 --- /dev/null +++ b/concepts/src/controllers/healthcheck.ts @@ -0,0 +1,16 @@ +import { RequestHandler } from "express"; +import asyncHandler from "express-async-handler"; +import { Config } from "../../config"; + +type PathParams = { id: string }; + +const healthcheckController = (config: Config): RequestHandler => { + return asyncHandler(async (req, res) => { + res.status(200).json({ + status: "ok", + config, + }); + }); +}; + +export default healthcheckController; diff --git a/concepts/src/controllers/index.ts b/concepts/src/controllers/index.ts index a187840e9c..2f9bf279c8 100644 --- a/concepts/src/controllers/index.ts +++ b/concepts/src/controllers/index.ts @@ -1,5 +1,6 @@ import conceptController from "./concept"; import conceptsController from "./concepts"; +import healthcheckController from "./healthcheck"; export { errorHandler } from "./error"; -export { conceptController, conceptsController }; +export { conceptController, conceptsController, healthcheckController }; diff --git a/terraform/modules/service/target_group.tf b/terraform/modules/service/target_group.tf index 9a7e611663..88e85ed346 100644 --- a/terraform/modules/service/target_group.tf +++ b/terraform/modules/service/target_group.tf @@ -15,22 +15,10 @@ resource "aws_lb_target_group" "tcp" { # updated service. Reducing this parameter to 90s makes deployments faster. deregistration_delay = 90 - dynamic "health_check" { - for_each = var.tcp_healthcheck == false ? toset([]) : toset([1]) - - content { - protocol = "TCP" - } - } - - dynamic "health_check" { - for_each = var.tcp_healthcheck == true ? toset([]) : toset([1]) - - content { - protocol = "HTTP" - path = var.healthcheck_path - matcher = "200" - } + health_check { + protocol = "HTTP" + path = var.healthcheck_path + matcher = "200" } } diff --git a/terraform/modules/service/variables.tf b/terraform/modules/service/variables.tf index 54ffe9fdf9..8c6b8e9aad 100644 --- a/terraform/modules/service/variables.tf +++ b/terraform/modules/service/variables.tf @@ -73,14 +73,7 @@ variable "app_memory" { type = number } -variable "tcp_healthcheck" { - # TODO: Remove this when all services use HTTP healthcheck - type = bool - default = true -} - variable "healthcheck_path" { - # Note: this is only used when tcp_healthcheck is set to false type = string default = "/management/healthcheck" }