Skip to content

Commit

Permalink
Merge pull request #18 from dasmeta/DMVP-5026-fix-rds-parameters-setting
Browse files Browse the repository at this point in the history
Dmvp-5026 fix rds parameters setting
  • Loading branch information
mrdntgrn authored Aug 15, 2024
2 parents 0793604 + bee9c67 commit 8797616
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 27 deletions.
59 changes: 33 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: check-added-large-files
- id: check-merge-conflict
- id: check-vcs-permalinks
- id: end-of-file-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
exclude: CHANGELOG.md
- id: check-yaml
- id: check-merge-conflict
- id: check-executables-have-shebangs
- id: check-case-conflict
- id: mixed-line-ending
args: [--fix=lf]
- id: detect-aws-credentials
args: ['--allow-missing-credentials']
- id: detect-private-key
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.62.3
hooks:
- id: terraform_fmt
- id: terraform_docs
args:
- '--args=--lockfile=false'
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-merge-conflict
- id: check-vcs-permalinks
- id: end-of-file-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
exclude: CHANGELOG.md
- id: check-yaml
- id: check-executables-have-shebangs
- id: check-case-conflict
- id: mixed-line-ending
args: [--fix=lf]
- id: detect-aws-credentials
args: ["--allow-missing-credentials"]
- id: detect-private-key
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.92.1
hooks:
- id: terraform_fmt
- id: terraform_docs
args:
- "--args=--lockfile=false"
- repo: https://github.com/qoomon/git-conventional-commits
rev: v2.6.7
hooks:
- id: conventional-commits
- repo: https://github.com/zricethezav/gitleaks
rev: v8.18.4
hooks:
- id: gitleaks
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# please enable git hooks by running the following command
```sh
git config --global core.hooksPath ./githooks # enables git hooks globally
```
# How to use

Case 1. Create Security group and create RDS
Expand Down
41 changes: 41 additions & 0 deletions git-conventional-commits.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"convention" : {
"commitTypes": [
"feat",
"fix",
"perf",
"refactor",
"style",
"test",
"build",
"ops",
"docs",
"merge",
"chore"
],
"commitScopes": [],
"releaseTagGlobPattern": "v[0-9]*.[0-9]*.[0-9]*",
"issueRegexPattern": "(^|\\s)#\\d+(\\s|$)"
},
"changelog" : {
"commitTypes": [
"feat",
"fix",
"perf",
"merge"
],
"includeInvalidCommits": true,
"commitScopes": [],
"commitIgnoreRegexPattern": "^WIP ",
"headlines": {
"feat": "Features",
"fix": "Bug Fixes",
"perf": "Performance Improvements",
"merge": "Merged Branches",
"breakingChange": "BREAKING CHANGES"
},
"commitUrl": "https://github.com/ACCOUNT/REPOSITORY/commit/%commit%",
"commitRangeUrl": "https://github.com/ACCOUNT/REPOSITORY/compare/%from%...%to%?diff=split",
"issueUrl": "https://github.com/ACCOUNT/REPOSITORY/issues/%issue%"
}
}
6 changes: 5 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ locals {
user_params_map = { for p in var.parameters : p.name => p.value }

# Merge the two maps, with user parameters overriding defaults
merged_params_map = ((var.engine == "mysql" || var.engine == "mariadb") && var.slow_queries.enabled) ? merge(local.params_mysql, local.user_params_map) : (var.engine == "postgres" && var.slow_queries.enabled) ? merge(local.params_postgres, local.user_params_map) : {}
merged_params_map = merge(
((var.engine == "mysql" || var.engine == "mariadb") && var.slow_queries.enabled) ? local.params_mysql : {},
(var.engine == "postgres" && var.slow_queries.enabled) ? local.params_postgres : {},
local.user_params_map
)

# Convert the merged map back to a list of maps
combined_parameters = [for name, value in local.merged_params_map : { name = name, value = value }]
Expand Down
24 changes: 24 additions & 0 deletions tests/parameters-mysql/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module "rds" {
source = "../.."

engine = "mysql"
engine_version = "8.0"
identifier = "parameters-rds"
db_name = "test-with-parameters"
db_username = "userTerraform"
db_password = "password"

vpc_id = "vpc-046effd7e14742653"
subnet_ids = ["subnet-08b19374efcede225", "subnet-01fd8508db302e82c", "subnet-0af7c75104c35cbde"]

create_security_group = false
create_db_parameter_group = true
parameters = [{ "name" : "sql_mode", "value" : "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION" }, { "name" : "character_set_server", "value" : "utf8mb4" }, { "name" : "collation_server", "value" : "utf8mb4_general_ci" }]

slow_queries = { "enabled" : false, "query_duration" : 1 }

alarms = {
enabled = false
sns_topic = ""
}
}

0 comments on commit 8797616

Please sign in to comment.