Skip to content

Commit a260cb2

Browse files
feat: max db connections flag
1 parent 9d11848 commit a260cb2

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ module "database" {
3131

3232
deletion_protection = var.deletion_protection
3333

34+
max_database_connections = var.max_database_connections
35+
3436
depends_on = [module.networking]
3537
}
3638

modules/database/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ resource "google_sql_database_instance" "this" {
2929
insights_config {
3030
query_insights_enabled = true
3131
}
32+
33+
dynamic "database_flags" {
34+
for_each = var.max_database_connections != "" ? [1] : []
35+
content {
36+
name = "max_connections"
37+
value = var.max_database_connections
38+
}
39+
}
3240
}
3341
}
3442

modules/database/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@ variable "deletion_protection" {
2323
description = "Whether to enable deletion protection for the database instance."
2424
type = bool
2525
}
26+
27+
variable "max_database_connections" {
28+
description = "The maximum number of connections to the database"
29+
type = string
30+
default = ""
31+
}

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ variable "postgres_version" {
2020
default = "POSTGRES_17"
2121
}
2222

23+
variable "max_database_connections" {
24+
description = "The maximum number of connections to the database"
25+
type = string
26+
default = ""
27+
}
28+
2329
variable "redis_tier" {
2430
description = "The tier for the Redis instance"
2531
type = string

0 commit comments

Comments
 (0)