feat(module): add random_password/default/1.0#541
Conversation
Adds a new random_password module using the hashicorp/random provider. The module generates a configurable random password and exports it as a sensitive `result` attribute via the @facets/random_password output type. Spec fields: - length (number, 8-128, default 16) - special (boolean, default true) - upper (boolean, default true) - numeric (boolean, default true)
WalkthroughA new Terraform module for random password generation is introduced, comprising configuration files, input variables, resource definitions, and output specifications. The module accepts configurable parameters for password length and character types. Changes
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Trivy (0.69.3)Trivy execution failed: Unknown error Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
modules/random_password/default/1.0/main.tf (1)
16-22: Consider addinglowerparameter for completeness.The module exposes
upper,numeric, andspecialbut notlower(lowercase letters). Therandom_passwordresource defaultslower = true, which is fine for most cases, but exposing it would give users full control over character sets.This is optional since lowercase letters are almost always desired in passwords.
♻️ Optional: Add lower parameter
In
localsblock:numeric = lookup(local.spec, "numeric", true) + lower = lookup(local.spec, "lower", true)In resource block:
numeric = local.numeric + lower = local.lower🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@modules/random_password/default/1.0/main.tf` around lines 16 - 22, Add a new "lower" parameter to the module so callers can control lowercase characters: update the locals block to include lower = lookup(local.spec, "lower", true) (matching existing pattern for length/special/upper/numeric) and wire that local into the random_password resource's lower attribute (alongside upper/numeric/special) so the resource uses the exposed value; also add corresponding docs/variable handling where you populate var.instance.spec to document the new option.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@modules/random_password/default/1.0/facets.yaml`:
- Around line 19-21: The module's facet metadata is inconsistent: the YAML
"clouds" key currently lists only "gcp" while "x-project-type" is set to
"aws-eks"; update the "clouds" array to be cloud-agnostic (e.g.,
["aws","gcp","azure","kubernetes"]) to match other cloud-agnostic modules and
either remove or clear the "x-project-type" field if AWS EKS is not applicable.
Locate the "clouds" key and "x-project-type" field in the facets.yaml for the
random provider and replace the single-entry "gcp" list with the multi-cloud
list (or delete "x-project-type") so the metadata accurately reflects the
provider's cloud-agnostic scope.
---
Nitpick comments:
In `@modules/random_password/default/1.0/main.tf`:
- Around line 16-22: Add a new "lower" parameter to the module so callers can
control lowercase characters: update the locals block to include lower =
lookup(local.spec, "lower", true) (matching existing pattern for
length/special/upper/numeric) and wire that local into the random_password
resource's lower attribute (alongside upper/numeric/special) so the resource
uses the exposed value; also add corresponding docs/variable handling where you
populate var.instance.spec to document the new option.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3d8187fb-5e67-4a50-bbac-2cbcb9cc58a9
📒 Files selected for processing (5)
modules/random_password/default/1.0/.terraform.lock.hclmodules/random_password/default/1.0/facets.yamlmodules/random_password/default/1.0/main.tfmodules/random_password/default/1.0/outputs.tfmodules/random_password/default/1.0/variables.tf
| clouds: | ||
| - gcp | ||
| x-project-type: aws-eks |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check how other cloud-agnostic modules handle clouds/x-project-type
rg -l "hashicorp/random" --type hcl | head -5 | xargs -I{} dirname {} | xargs -I{} cat {}/facets.yaml 2>/dev/null | grep -A2 "clouds:"Repository: Facets-cloud/facets-modules
Length of output: 98
🏁 Script executed:
# First, let's find and examine the specific file
find . -path "*modules/random_password/default/1.0/facets.yaml" -type fRepository: Facets-cloud/facets-modules
Length of output: 120
🏁 Script executed:
# Also check the overall repository structure to understand the module format
ls -la modules/ | head -20Repository: Facets-cloud/facets-modules
Length of output: 1283
🏁 Script executed:
# Search for other modules that use hashicorp/random provider
find modules -name "facets.yaml" -type f | xargs grep -l "hashicorp/random" | head -10Repository: Facets-cloud/facets-modules
Length of output: 53
🏁 Script executed:
cat -n ./modules/random_password/default/1.0/facets.yamlRepository: Facets-cloud/facets-modules
Length of output: 2602
🏁 Script executed:
# Search for all modules with 'clouds:' to see the pattern
find modules -name "facets.yaml" -type f | xargs grep -B2 -A2 "clouds:" | head -50Repository: Facets-cloud/facets-modules
Length of output: 3036
🏁 Script executed:
# Check how many modules use aws-eks as x-project-type
find modules -name "facets.yaml" -type f | xargs grep -l "aws-eks" | wc -lRepository: Facets-cloud/facets-modules
Length of output: 72
🏁 Script executed:
# Find modules with multiple cloud support (more likely cloud-agnostic)
find modules -name "facets.yaml" -type f | xargs grep -l "clouds:" | while read f; do
clouds=$(grep -A5 "^clouds:" "$f" | grep "^\s*-" | wc -l)
[ "$clouds" -gt 1 ] && echo "$f ($clouds clouds)"
done | head -20Repository: Facets-cloud/facets-modules
Length of output: 1190
🏁 Script executed:
# Check for modules with no x-project-type specified (to understand the pattern)
find modules -name "facets.yaml" -type f | while read f; do
if ! grep -q "x-project-type:" "$f"; then
echo "$f"
fi
done | head -10Repository: Facets-cloud/facets-modules
Length of output: 531
🏁 Script executed:
# Look for documentation or schema definition
find . -name "*.md" -o -name "*.txt" -o -name "schema*" | xargs grep -l "x-project-type\|clouds" 2>/dev/null | head -5Repository: Facets-cloud/facets-modules
Length of output: 314
🏁 Script executed:
# Check what x-project-type values exist across all modules
find modules -name "facets.yaml" -type f | xargs grep "x-project-type:" | cut -d':' -f2 | sort | uniq -cRepository: Facets-cloud/facets-modules
Length of output: 93
🏁 Script executed:
# Look at a cloud-agnostic module like alert_group to see its pattern
cat modules/alert_group/default/0.1/facets.yaml | grep -A10 "^clouds:"Repository: Facets-cloud/facets-modules
Length of output: 201
🏁 Script executed:
# Check if random_password has any provider info that could explain its configuration
cat modules/random_password/default/1.0/facets.yaml | grep -i "provider\|resource"Repository: Facets-cloud/facets-modules
Length of output: 53
Fix cloud and project-type configuration for cloud-agnostic provider.
The module declares clouds: [gcp] but x-project-type: aws-eks, which is inconsistent. The random provider is cloud-agnostic and should support all major clouds. This configuration incorrectly restricts the module to GCP while also claiming AWS EKS support. Update to clouds: [aws, gcp, azure, kubernetes] to match other cloud-agnostic modules in the repository, or remove the x-project-type field if it's not applicable.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@modules/random_password/default/1.0/facets.yaml` around lines 19 - 21, The
module's facet metadata is inconsistent: the YAML "clouds" key currently lists
only "gcp" while "x-project-type" is set to "aws-eks"; update the "clouds" array
to be cloud-agnostic (e.g., ["aws","gcp","azure","kubernetes"]) to match other
cloud-agnostic modules and either remove or clear the "x-project-type" field if
AWS EKS is not applicable. Locate the "clouds" key and "x-project-type" field in
the facets.yaml for the random provider and replace the single-entry "gcp" list
with the multi-cloud list (or delete "x-project-type") so the metadata
accurately reflects the provider's cloud-agnostic scope.
Summary
random_password/default/1.0module using thehashicorp/randomprovider@facets/random_passwordwith a sensitiveresultattributeSpec Fields
lengthspecialuppernumericOutput
resultValidation
raptor module validate— all checks passraptor create iac-module --dry-run— all validations passSummary by CodeRabbit