From c2dabad5c7a180ba6d1ad0763a53d80558563c79 Mon Sep 17 00:00:00 2001 From: Tigran Muradyan Date: Thu, 15 Aug 2024 15:30:21 +0400 Subject: [PATCH 1/3] fix(DMVP-5026): fix rds module to set passed custom parameters correctly --- main.tf | 6 +++++- tests/parameters-mysql/main.tf | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 tests/parameters-mysql/main.tf diff --git a/main.tf b/main.tf index 1dcaf0f..382c8d1 100644 --- a/main.tf +++ b/main.tf @@ -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 }] diff --git a/tests/parameters-mysql/main.tf b/tests/parameters-mysql/main.tf new file mode 100644 index 0000000..ecf03f6 --- /dev/null +++ b/tests/parameters-mysql/main.tf @@ -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 = "" + } +} From ce7b11c8f105fb914e263f1eca21d313c47bcf16 Mon Sep 17 00:00:00 2001 From: Tigran Muradyan Date: Thu, 15 Aug 2024 15:41:32 +0400 Subject: [PATCH 2/3] fix(DMVP-5026): fix/upgrade pre-commit-hooks --- .pre-commit-config.yaml | 52 ++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3452644..30ed4f9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,27 +1,27 @@ 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-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.92.1 + hooks: + - id: terraform_fmt + - id: terraform_docs + args: + - "--args=--lockfile=false" From bee9c676beca57a00dc08179c41e88e9780db198 Mon Sep 17 00:00:00 2001 From: Tigran Muradyan Date: Thu, 15 Aug 2024 16:02:10 +0400 Subject: [PATCH 3/3] fix(DMVP-5026): fix/upgrade pre-commit-hooks --- .pre-commit-config.yaml | 9 +++++++- README.md | 4 ++++ git-conventional-commits.json | 41 +++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 git-conventional-commits.json diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 30ed4f9..57087f5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,6 @@ repos: 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 @@ -25,3 +24,11 @@ repos: - 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 diff --git a/README.md b/README.md index b807b56..4a21007 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/git-conventional-commits.json b/git-conventional-commits.json new file mode 100644 index 0000000..009fca5 --- /dev/null +++ b/git-conventional-commits.json @@ -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%" + } +}