-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Max db connections #13
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
Conversation
WalkthroughA new variable, Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Terraform
participant RootModule
participant DatabaseModule
participant GoogleSQL
User->>Terraform: Apply configuration
Terraform->>RootModule: Process variables (including max_database_connections)
RootModule->>DatabaseModule: Pass max_database_connections
DatabaseModule->>GoogleSQL: Create/Update instance (conditionally set max_connections flag)
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
main.tf (1)
32-35
: Document and alphabetize new module input.
Themax_database_connections
input was added to thedatabase
module, but it isn’t mentioned in our docs/README. Please:
- Update your Terraform documentation to include this variable.
- (Optional) Reorder module inputs alphabetically for readability.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
main.tf
(1 hunks)modules/database/main.tf
(1 hunks)modules/database/variables.tf
(1 hunks)variables.tf
(1 hunks)
🔇 Additional comments (1)
modules/database/main.tf (1)
32-39
: Dynamic block fordatabase_flags
is correctly scoped.
The conditional addition of themax_connections
flag based onvar.max_database_connections
is implemented correctly inside thesettings
block. This ensures the flag is only set when provided.
variable "max_database_connections" { | ||
description = "The maximum number of connections to the database" | ||
type = string | ||
default = "" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider using a numeric type or adding validation for max_database_connections
.
Right now this variable is a string
with an empty default. Since it ultimately represents a numeric value for the max_connections
flag, we should:
- Change the type to
number
with a default ofnull
and update the dynamic block to check for!= null
. - Or add a
validation
block to enforce a digits-only string (e.g.^[0-9]+$
).
This ensures users can’t pass invalid inputs and improves type safety.
variable "max_database_connections" {
description = "The maximum number of connections to the database"
- type = string
- default = ""
+ type = number
+ default = null
+ validation {
+ condition = var.max_database_connections == null || var.max_database_connections >= 0
+ error_message = "max_database_connections must be a non-negative number or null"
+ }
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
variable "max_database_connections" { | |
description = "The maximum number of connections to the database" | |
type = string | |
default = "" | |
} | |
variable "max_database_connections" { | |
description = "The maximum number of connections to the database" | |
type = number | |
default = null | |
validation { | |
condition = var.max_database_connections == null || var.max_database_connections >= 0 | |
error_message = "max_database_connections must be a non-negative number or null" | |
} | |
} |
|
||
variable "max_database_connections" { | ||
description = "The maximum number of connections to the database" | ||
type = string | ||
default = "" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Align module variable type with root or add validation.
Just like in the root, the database module’s max_database_connections
should either:
- Be converted to a
number
withdefault = null
and validation, or - Retain
string
type but include avalidation
clause to enforce numeric content.
Consistency prevents runtime errors when passing values across modules.
variable "max_database_connections" {
description = "The maximum number of connections to the database"
- type = string
- default = ""
+ type = number
+ default = null
+ validation {
+ condition = var.max_database_connections == null || var.max_database_connections >= 0
+ error_message = "max_database_connections must be a non-negative number or null"
+ }
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
variable "max_database_connections" { | |
description = "The maximum number of connections to the database" | |
type = string | |
default = "" | |
} | |
variable "max_database_connections" { | |
description = "The maximum number of connections to the database" | |
type = number | |
default = null | |
validation { | |
condition = var.max_database_connections == null || var.max_database_connections >= 0 | |
error_message = "max_database_connections must be a non-negative number or null" | |
} | |
} |
a260cb2
to
687a1ee
Compare
## [1.10.0](v1.9.0...v1.10.0) (2025-05-07) ### Features * Max db connections ([#13](#13)) ([7905d05](7905d05))
This PR is included in version 1.10.0 🎉 |
Summary by CodeRabbit