Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ecs): add restrictions on database connections to prevent max co… #111

Merged
merged 1 commit into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,14 @@ module "kong_ecs" {
image_url = var.image_url
execution_role_arn = var.execution_role_arn

skip_final_snapshot = var.skip_final_snapshot
skip_rds_creation = var.skip_rds_creation
kong_database_config = var.kong_database_config
postgres_config = var.postgres_config
postgres_host = var.postgres_host
db_password_arn = var.db_password_arn
skip_final_snapshot = var.skip_final_snapshot
skip_rds_creation = var.skip_rds_creation
kong_database_config = var.kong_database_config
postgres_config = var.postgres_config
postgres_host = var.postgres_host
db_password_arn = var.db_password_arn
pg_max_concurrent_queries = var.pg_max_concurrent_queries
pg_keepalive_timeout = var.pg_keepalive_timeout

kong_vitals_enabled = var.kong_vitals_enabled
kong_portal_enabled = var.kong_portal_enabled
Expand Down
2 changes: 2 additions & 0 deletions modules/ecs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ resource "aws_ecs_task_definition" "kong" {
db_host = local.db_info.endpoint
db_name = local.db_info.database_name
db_password_arn = var.db_password_arn
pg_max_concurrent_queries = var.pg_max_concurrent_queries
pg_keepalive_timeout = var.pg_keepalive_timeout
kong_admin_gui_session_conf = var.kong_admin_gui_session_conf
log_group = var.log_group
admin_api_port = var.kong_ports.admin_api
Expand Down
10 changes: 10 additions & 0 deletions modules/ecs/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,16 @@ variable "db_password_arn" {
type = string
}

variable "pg_max_concurrent_queries" {
description = "The maximum number of concurrent queries that can be executing at any given time. The total number of concurrent queries for this node will be will be: pg_max_concurrent_queries * nginx_worker_processes. The default value of 0 removes this concurrency limitation."
type = number
}

variable "pg_keepalive_timeout" {
description = "Specify the maximal idle timeout (in ms) for the postgres connections in the pool. If this value is set to 0 then the timeout interval is unlimited."
type = number
}

variable "log_group" {
description = "The Log Group for ECS to report out to"
type = string
Expand Down
12 changes: 12 additions & 0 deletions templates/ecs/kong_control_plane.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@
"name": "KONG_PG_DATABASE",
"value": "${db_name}"
},
%{ if pg_max_concurrent_queries != null }
{
"name": "KONG_PG_MAX_CONCURRENT_QUERIES",
"value": "${pg_max_concurrent_queries}"
},
%{ endif }
%{ if pg_keepalive_timeout != null }
{
"name": "KONG_PG_KEEPALIVE_TIMEOUT",
"value": "${pg_keepalive_timeout}"
},
%{ endif }
{
"name": "KONG_NGINX_HTTP_INCLUDE",
"value": "/usr/local/kong/custom-nginx.conf"
Expand Down
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,18 @@ variable "db_password_arn" {
default = null
}

variable "pg_max_concurrent_queries" {
description = "The maximum number of concurrent queries that can be executing at any given time. The total number of concurrent queries for this node will be will be: pg_max_concurrent_queries * nginx_worker_processes. The default value of 0 removes this concurrency limitation."
type = number
default = null
}

variable "pg_keepalive_timeout" {
description = "Specify the maximal idle timeout (in ms) for the postgres connections in the pool. If this value is set to 0 then the timeout interval is unlimited."
type = number
default = null
}

variable "log_group" {
description = "(Optional) The Log Group for ECS to report out to"
type = string
Expand Down
Loading