Skip to content

Commit

Permalink
Merge pull request #3 from ankur6405/parameter-group
Browse files Browse the repository at this point in the history
Added parameters slow-query-log and long-query-time
  • Loading branch information
RohitSquareops authored Aug 8, 2023
2 parents c32bda2 + 1949681 commit 06e9dff
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Features
autoscaling_enabled = true
autoscaling_max = 4
autoscaling_min = 1
long_query_time = 10
deletion_protection = false
predefined_metric_type = "RDSReaderAverageDatabaseConnections"
autoscaling_target_connections = 40
Expand Down Expand Up @@ -125,6 +126,7 @@ Security scanning is graciously provided by Prowler. Proowler is the leading ful
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | Instance type | `string` | `"db.m5.large"` | no |
| <a name="input_instances_config"></a> [instances\_config](#input\_instances\_config) | Map of cluster instances and any specific/overriding attributes to be created | `map(any)` | <pre>{<br> "one": {}<br>}</pre> | no |
| <a name="input_kms_key_arn"></a> [kms\_key\_arn](#input\_kms\_key\_arn) | The ARN for the KMS encryption key. If creating an encrypted replica, set this to the destination KMS ARN. If storage\_encrypted is set to true and kms\_key\_id is not specified the default KMS key created in your account will be used | `string` | `null` | no |
| <a name="input_long_query_time"></a> [long\_query\_time](#input\_long\_query\_time) | To prevent fast-running queries from being logged in the slow query log, specify a value for the shortest query runtime to be logged, in seconds | `number` | `10` | no |
| <a name="input_master_username"></a> [master\_username](#input\_master\_username) | The username for the primary cluster | `string` | `"root"` | no |
| <a name="input_monitoring_interval"></a> [monitoring\_interval](#input\_monitoring\_interval) | The interval, in seconds, between points when Enhanced Monitoring metrics are collected for instances. Set to 0 to disble. Default is 0 | `number` | `0` | no |
| <a name="input_performance_insights_enabled"></a> [performance\_insights\_enabled](#input\_performance\_insights\_enabled) | Specifies whether Performance Insights is enabled or not | `bool` | `null` | no |
Expand Down
1 change: 1 addition & 0 deletions examples/aurora/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ module "aurora" {
autoscaling_enabled = true
autoscaling_max = 4
autoscaling_min = 1
long_query_time = 10
deletion_protection = false
predefined_metric_type = "RDSReaderAverageDatabaseConnections"
autoscaling_target_connections = 40
Expand Down
17 changes: 16 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ resource "aws_db_parameter_group" "rds_parameter_group" {
{ "Name" = format("%s-%s-parameter-group", var.environment, var.rds_instance_name) },
local.tags,
)
parameter {
name = (var.engine == "aurora-mysql" ? "slow_query_log" : "")
value = (var.engine == "aurora-mysql" ? 1 : "")
}
parameter {
name = (var.engine == "aurora-mysql" ? "long_query_time" : "")
value = (var.engine == "aurora-mysql" ? var.long_query_time : "")
}
}
resource "aws_rds_cluster_parameter_group" "rds_cluster_parameter_group" {
name = format("%s-%s-cluster-parameter-group", var.environment, var.rds_instance_name)
Expand All @@ -93,5 +101,12 @@ resource "aws_rds_cluster_parameter_group" "rds_cluster_parameter_group" {
name = (var.engine == "aurora-mysql" ? "require_secure_transport" : "rds.force_ssl")
value = (var.engine == "aurora-mysql" ? (var.enable_ssl_connection ? "ON" : "OFF") : (var.engine == "aurora-postgres" && var.enable_ssl_connection ? 1 : 0))
}

parameter {
name = (var.engine == "aurora-mysql" ? "slow_query_log" : "")
value = (var.engine == "aurora-mysql" ? 1 : "")
}
parameter {
name = (var.engine == "aurora-mysql" ? "long_query_time" : "")
value = (var.engine == "aurora-mysql" ? var.long_query_time : "")
}
}
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,9 @@ variable "predefined_metric_type" {
type = string
default = "RDSReaderAverageDatabaseConnections"
}

variable "long_query_time" {
description = "To prevent fast-running queries from being logged in the slow query log, specify a value for the shortest query runtime to be logged, in seconds"
type = number
default = 10
}

0 comments on commit 06e9dff

Please sign in to comment.