From 0a85e0b04fadd1e0e1becac52358a855ef586f5c Mon Sep 17 00:00:00 2001 From: iamtrazy Date: Wed, 19 Mar 2025 11:48:29 +0530 Subject: [PATCH 1/6] Random-Password module --- .../random/Random-Password/outputs.tf | 25 +++++++ .../random/Random-Password/random_password.tf | 30 +++++++++ .../random/Random-Password/variables.tf | 67 +++++++++++++++++++ .../random/Random-Password/versions.tf | 30 +++++++++ 4 files changed, 152 insertions(+) create mode 100644 modules/hashicorp/random/Random-Password/outputs.tf create mode 100644 modules/hashicorp/random/Random-Password/random_password.tf create mode 100644 modules/hashicorp/random/Random-Password/variables.tf create mode 100644 modules/hashicorp/random/Random-Password/versions.tf diff --git a/modules/hashicorp/random/Random-Password/outputs.tf b/modules/hashicorp/random/Random-Password/outputs.tf new file mode 100644 index 0000000..949cb6d --- /dev/null +++ b/modules/hashicorp/random/Random-Password/outputs.tf @@ -0,0 +1,25 @@ +# ------------------------------------------------------------------------------------- +# +# Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. +# +# WSO2 LLC. licenses this file to you under the Apache License, +# Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# -------------------------------------------------------------------------------------- + +output "random_password" { + depends_on = [random_password.random_password] + value = random_password.random_password.result + sensitive = true +} diff --git a/modules/hashicorp/random/Random-Password/random_password.tf b/modules/hashicorp/random/Random-Password/random_password.tf new file mode 100644 index 0000000..69cb6e2 --- /dev/null +++ b/modules/hashicorp/random/Random-Password/random_password.tf @@ -0,0 +1,30 @@ +# ------------------------------------------------------------------------------------- +# +# Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. +# +# WSO2 LLC. licenses this file to you under the Apache License, +# Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# -------------------------------------------------------------------------------------- + +resource "random_password" "random_password" { + length = var.length + special = var.special + override_special = var.override_special + min_numeric = var.min_numeric + min_upper = var.min_upper + min_lower = var.min_lower + min_special = var.min_special + keepers = var.keepers +} diff --git a/modules/hashicorp/random/Random-Password/variables.tf b/modules/hashicorp/random/Random-Password/variables.tf new file mode 100644 index 0000000..ffb27f5 --- /dev/null +++ b/modules/hashicorp/random/Random-Password/variables.tf @@ -0,0 +1,67 @@ +# ------------------------------------------------------------------------------------- +# +# Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. +# +# WSO2 LLC. licenses this file to you under the Apache License, +# Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# -------------------------------------------------------------------------------------- + +variable "length" { + default = 20 + description = "The length of the generated password" + type = number +} + +variable "special" { + default = true + description = "Whether to include special characters in the generated password" + type = bool +} + +variable "override_special" { + default = "_+.~^#*?" + description = "Override the default special characters with a custom set" + type = string +} + +variable "min_numeric" { + default = 1 + description = "The minimum number of numeric characters in the generated password" + type = number +} + +variable "min_upper" { + default = 1 + description = "The minimum number of uppercase characters in the generated password" + type = number +} + +variable "min_lower" { + default = 1 + description = "The minimum number of lowercase characters in the generated password" + type = number +} + +variable "min_special" { + default = 1 + description = "The minimum number of special characters in the generated password" + type = number +} + +variable "keepers" { + default = {} + description = "A map of values that should be kept secret" + type = map(string) +} diff --git a/modules/hashicorp/random/Random-Password/versions.tf b/modules/hashicorp/random/Random-Password/versions.tf new file mode 100644 index 0000000..54effc2 --- /dev/null +++ b/modules/hashicorp/random/Random-Password/versions.tf @@ -0,0 +1,30 @@ +# ------------------------------------------------------------------------------------- +# +# Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. +# +# WSO2 LLC. licenses this file to you under the Apache License, +# Version 2.0 (the "License"); you may not use this file except +# in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# -------------------------------------------------------------------------------------- + +terraform { + required_version = ">= 0.13" + required_providers { + azuredevops = { + source = "hashicorp/random" + version = ">=2.2.0" + } + } +} + From e09de44d754f7a5301d5562682f145b85830172d Mon Sep 17 00:00:00 2001 From: iamtrazy Date: Wed, 19 Mar 2025 11:59:51 +0530 Subject: [PATCH 2/6] Update Licens Header --- modules/hashicorp/random/Random-Password/versions.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/hashicorp/random/Random-Password/versions.tf b/modules/hashicorp/random/Random-Password/versions.tf index 54effc2..7438c26 100644 --- a/modules/hashicorp/random/Random-Password/versions.tf +++ b/modules/hashicorp/random/Random-Password/versions.tf @@ -1,6 +1,6 @@ # ------------------------------------------------------------------------------------- # -# Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. +# Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com) All Rights Reserved. # # WSO2 LLC. licenses this file to you under the Apache License, # Version 2.0 (the "License"); you may not use this file except From 7c4f4883b07a096b77a4dfcb56322af17b5fdeaf Mon Sep 17 00:00:00 2001 From: iamtrazy Date: Wed, 19 Mar 2025 12:13:40 +0530 Subject: [PATCH 3/6] Fix: Folder structure + Code formatting --- .../random/Random-Password/outputs.tf | 0 .../random/Random-Password/random_password.tf | 4 ++-- .../random/Random-Password/variables.tf | 20 +++++++++---------- .../random/Random-Password/versions.tf | 3 +-- 4 files changed, 13 insertions(+), 14 deletions(-) rename modules/{hashicorp => }/random/Random-Password/outputs.tf (100%) rename modules/{hashicorp => }/random/Random-Password/random_password.tf (91%) rename modules/{hashicorp => }/random/Random-Password/variables.tf (95%) rename modules/{hashicorp => }/random/Random-Password/versions.tf (97%) diff --git a/modules/hashicorp/random/Random-Password/outputs.tf b/modules/random/Random-Password/outputs.tf similarity index 100% rename from modules/hashicorp/random/Random-Password/outputs.tf rename to modules/random/Random-Password/outputs.tf diff --git a/modules/hashicorp/random/Random-Password/random_password.tf b/modules/random/Random-Password/random_password.tf similarity index 91% rename from modules/hashicorp/random/Random-Password/random_password.tf rename to modules/random/Random-Password/random_password.tf index 69cb6e2..82034c7 100644 --- a/modules/hashicorp/random/Random-Password/random_password.tf +++ b/modules/random/Random-Password/random_password.tf @@ -20,8 +20,8 @@ resource "random_password" "random_password" { length = var.length - special = var.special - override_special = var.override_special + special = var.include_special_characters + override_special = var.override_special_characters min_numeric = var.min_numeric min_upper = var.min_upper min_lower = var.min_lower diff --git a/modules/hashicorp/random/Random-Password/variables.tf b/modules/random/Random-Password/variables.tf similarity index 95% rename from modules/hashicorp/random/Random-Password/variables.tf rename to modules/random/Random-Password/variables.tf index ffb27f5..0629aa1 100644 --- a/modules/hashicorp/random/Random-Password/variables.tf +++ b/modules/random/Random-Password/variables.tf @@ -19,49 +19,49 @@ # -------------------------------------------------------------------------------------- variable "length" { - default = 20 description = "The length of the generated password" type = number + default = 20 } -variable "special" { - default = true +variable "include_special_characters" { description = "Whether to include special characters in the generated password" type = bool + default = 20 } -variable "override_special" { - default = "_+.~^#*?" +variable "override_special_characters" { description = "Override the default special characters with a custom set" type = string + default = "_+.~^#*?" } variable "min_numeric" { - default = 1 description = "The minimum number of numeric characters in the generated password" type = number + default = 1 } variable "min_upper" { - default = 1 description = "The minimum number of uppercase characters in the generated password" type = number + default = 1 } variable "min_lower" { - default = 1 description = "The minimum number of lowercase characters in the generated password" type = number + default = 1 } variable "min_special" { - default = 1 description = "The minimum number of special characters in the generated password" type = number + default = 1 } variable "keepers" { - default = {} description = "A map of values that should be kept secret" type = map(string) + default = {} } diff --git a/modules/hashicorp/random/Random-Password/versions.tf b/modules/random/Random-Password/versions.tf similarity index 97% rename from modules/hashicorp/random/Random-Password/versions.tf rename to modules/random/Random-Password/versions.tf index 7438c26..ab1cff1 100644 --- a/modules/hashicorp/random/Random-Password/versions.tf +++ b/modules/random/Random-Password/versions.tf @@ -23,8 +23,7 @@ terraform { required_providers { azuredevops = { source = "hashicorp/random" - version = ">=2.2.0" + version = ">= 2.2.0" } } } - From 56adc4c0a5bf6c345327624abb3ac7f6dc2a9bde Mon Sep 17 00:00:00 2001 From: iamtrazy Date: Wed, 19 Mar 2025 12:16:16 +0530 Subject: [PATCH 4/6] Fix: Variable Description for Keepers --- modules/random/Random-Password/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/random/Random-Password/variables.tf b/modules/random/Random-Password/variables.tf index 0629aa1..a790af2 100644 --- a/modules/random/Random-Password/variables.tf +++ b/modules/random/Random-Password/variables.tf @@ -61,7 +61,7 @@ variable "min_special" { } variable "keepers" { - description = "A map of values that should be kept secret" + description = "Arbitrary map of values that, when changed, will trigger recreation of resource" type = map(string) default = {} } From 45cdd2e95c10b8919b4fe6e4d405d572fca24a58 Mon Sep 17 00:00:00 2001 From: iamtrazy Date: Wed, 19 Mar 2025 12:18:53 +0530 Subject: [PATCH 5/6] Fix: Special chracter bolean default --- modules/random/Random-Password/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/random/Random-Password/variables.tf b/modules/random/Random-Password/variables.tf index a790af2..c603a4c 100644 --- a/modules/random/Random-Password/variables.tf +++ b/modules/random/Random-Password/variables.tf @@ -27,7 +27,7 @@ variable "length" { variable "include_special_characters" { description = "Whether to include special characters in the generated password" type = bool - default = 20 + default = true } variable "override_special_characters" { From 0dd21513ebb36b44275f4c62752999c6005e0405 Mon Sep 17 00:00:00 2001 From: iamtrazy Date: Wed, 19 Mar 2025 12:20:09 +0530 Subject: [PATCH 6/6] fix: provider name --- modules/random/Random-Password/versions.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/random/Random-Password/versions.tf b/modules/random/Random-Password/versions.tf index ab1cff1..6971e3b 100644 --- a/modules/random/Random-Password/versions.tf +++ b/modules/random/Random-Password/versions.tf @@ -21,7 +21,7 @@ terraform { required_version = ">= 0.13" required_providers { - azuredevops = { + random = { source = "hashicorp/random" version = ">= 2.2.0" }