diff --git a/modules/random/Random-Password/outputs.tf b/modules/random/Random-Password/outputs.tf new file mode 100644 index 0000000..949cb6d --- /dev/null +++ b/modules/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/random/Random-Password/random_password.tf b/modules/random/Random-Password/random_password.tf new file mode 100644 index 0000000..82034c7 --- /dev/null +++ b/modules/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.include_special_characters + override_special = var.override_special_characters + 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/random/Random-Password/variables.tf b/modules/random/Random-Password/variables.tf new file mode 100644 index 0000000..c603a4c --- /dev/null +++ b/modules/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" { + description = "The length of the generated password" + type = number + default = 20 +} + +variable "include_special_characters" { + description = "Whether to include special characters in the generated password" + type = bool + default = true +} + +variable "override_special_characters" { + description = "Override the default special characters with a custom set" + type = string + default = "_+.~^#*?" +} + +variable "min_numeric" { + description = "The minimum number of numeric characters in the generated password" + type = number + default = 1 +} + +variable "min_upper" { + description = "The minimum number of uppercase characters in the generated password" + type = number + default = 1 +} + +variable "min_lower" { + description = "The minimum number of lowercase characters in the generated password" + type = number + default = 1 +} + +variable "min_special" { + description = "The minimum number of special characters in the generated password" + type = number + default = 1 +} + +variable "keepers" { + description = "Arbitrary map of values that, when changed, will trigger recreation of resource" + type = map(string) + default = {} +} diff --git a/modules/random/Random-Password/versions.tf b/modules/random/Random-Password/versions.tf new file mode 100644 index 0000000..6971e3b --- /dev/null +++ b/modules/random/Random-Password/versions.tf @@ -0,0 +1,29 @@ +# ------------------------------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------------------------------- + +terraform { + required_version = ">= 0.13" + required_providers { + random = { + source = "hashicorp/random" + version = ">= 2.2.0" + } + } +}