feat: update .#6
Conversation
Closes #2
Module Review — Grade: 🟡 C
📋 Variable Classification
🏗️ Module Structure
🔒 Security Defaults
✅ Validation Results
🤖 Auto-Fixable Issues (11)A follow-up automated fix PR can address these:
👤 Needs Human Review (5)These require organizational decisions and cannot be auto-fixed:
Automated review by terraform-module-pr-review workflow · grade: C · 16 violations (11 auto-fixable, 5 need human review) |
asarkar157
left a comment
There was a problem hiding this comment.
Automated module review complete. Grade: 🟡 C. See detailed review comment above for variable classification, structure checks, security defaults, and auto-fixable vs human-review items.
Module Review — Grade: 🟡 C
📋 Variable Classification
0 of 13 variables have validation blocks. 🏗️ Module Structure
🔒 Security Defaults
🌐 Org-Distribution Readiness
✅ Functional Validation
🔧 Suggested Fixes (Priority Order)🔴 CRITICAL (auto-fixable)
🟠 HIGH (auto-fixable) 🟡 MEDIUM (needs human review) 📊 Summary
Labeled |
asarkar157
left a comment
There was a problem hiding this comment.
Module Review — Grade: 🟡 C
Grade C — Moderate issues requiring polish before org-wide distribution. The module is fundamentally sound with correct resource patterns, proper
thisnaming, good output coverage, and sensitive handling of credentials. However, it has zero test coverage, zero validation blocks across all 13 variables, noterraform { required_providers }block, workspace-specific defaults, and several security hardening gaps. The LTR feature addition itself is well-implemented with sensible defaults.
📋 Variable Classification
| Variable | Type | Classification | Issue | Status |
|---|---|---|---|---|
server_name |
string |
REQUIRED | Missing validation (1-63 chars, lowercase+hyphens) | |
database_name |
string |
OPTIONAL | Default "workshopdb" is workshop-specific |
|
resource_group_name |
string |
OPTIONAL | Default "se-rg" is workspace-specific — should be REQUIRED |
❌ |
location |
string |
OPTIONAL | Default "westus2" — opinionated regional assumption |
|
admin_login |
string |
REQUIRED | Missing validation (Azure disallows "admin", "sa", etc.) | |
admin_password |
string |
REQUIRED | sensitive = true ✅ — missing complexity validation |
|
sku_name |
string |
OPTIONAL | Missing validation for allowed SKU values | |
max_size_gb |
number |
OPTIONAL | Missing bounds validation | |
tags |
map(string) |
OPTIONAL | Fine | ✅ |
ltr_weekly_retention |
string |
OPTIONAL | Missing ISO 8601 duration validation | ❌ |
ltr_monthly_retention |
string |
OPTIONAL | Good default "P13M" — missing ISO 8601 validation |
❌ |
ltr_yearly_retention |
string |
OPTIONAL | Missing ISO 8601 duration validation | ❌ |
ltr_week_of_year |
number |
OPTIONAL | Missing validation (must be 1–52) | ❌ |
0 of 13 variables have validation blocks.
🏗️ Module Structure
| Check | Result |
|---|---|
| Tightly-coupled resources | ✅ PASS — server + database + firewall rule |
Resource naming (this) |
✅ PASS |
| Tags locals merge pattern | ❌ FAIL — raw var.tags passthrough, no locals merge |
| No provider blocks | ✅ PASS |
| No backend blocks | ✅ PASS |
terraform { required_providers } |
❌ FAIL — missing entirely; consumers cannot pin azurerm version |
| Outputs complete + described | ✅ PASS — 5 outputs, all described |
| README with usage example | ✅ PASS |
| Tests exist | ❌ FAIL — zero test files in repo |
🔒 Security Defaults
| Check | Result |
|---|---|
| Encryption at rest (TDE) | |
| Encryption in transit (TLS 1.2) | ✅ PASS — minimum_tls_version = "1.2" hardcoded |
| Public network access | ❌ FAIL — defaults to true (provider default); should be false |
| Firewall rule 0.0.0.0 | |
| Admin password handling | ✅ PASS — sensitive = true on variable and output |
| Auditing policy | ❌ FAIL — no azurerm_mssql_server_extended_auditing_policy |
| Threat detection | ❌ FAIL — no azurerm_mssql_server_security_alert_policy |
connection_string output |
|
| Azure AD authentication | azuread_administrator block |
| Deletion protection | lifecycle { prevent_destroy } on stateful resources |
🌐 Org-Distribution Readiness
| Check | Result |
|---|---|
| Self-contained (no relative sources) | ✅ PASS |
| All variables have descriptions | ✅ PASS |
| All outputs have descriptions | ✅ PASS |
| No workspace-specific assumptions | ❌ FAIL — se-rg, workshopdb defaults |
Version constraints on required_providers |
❌ FAIL — no terraform block at all |
✅ Functional Validation
| Check | Result |
|---|---|
terraform fmt |
✅ PASS |
terraform init |
✅ PASS (azurerm v4.76.0) |
terraform validate |
✅ PASS — Success! The configuration is valid. |
terraform test |
⏭️ SKIPPED — no tests/ directory |
🔧 Suggested Fixes (Priority Order)
🔴 CRITICAL (auto-fixable)
- Add
terraform { required_version = ">= 1.3"; required_providers { azurerm = { source = "hashicorp/azurerm", version = "~> 4.0" } } }— LTR features need azurerm ≥ 3.x. - Add
validationblocks to all 4 LTR variables (ISO 8601 regex for durations,1 <= week <= 52). - Add at least one
tests/basic.tftest.hclsmoke test exercising the LTR block.
🟠 HIGH (auto-fixable)
4. Remove workspace-specific defaults — make resource_group_name REQUIRED (no default); reconsider database_name = "workshopdb" and location = "westus2".
5. Add public_network_access_enabled variable defaulting to false.
6. Make the firewall rule conditional via var.allow_azure_services (default false) using count.
7. Introduce locals { merged_tags = merge(var.tags, { "managed-by" = "terraform", "module" = "azure_tf_sql_database" }) } and use everywhere.
8. Add validation blocks to server_name, admin_login, admin_password, sku_name, max_size_gb.
🟡 MEDIUM (needs human review)
9. Add azurerm_mssql_server_extended_auditing_policy (or make optional via variable).
10. Add azurerm_mssql_server_security_alert_policy for threat detection.
11. Support Azure AD authentication via optional azuread_administrator block.
12. Consider splitting connection_string output into credential-free + credential-bearing variants, or document the Azure AD alternative.
13. Add lifecycle { prevent_destroy = true } (or variable-gated) on server/database.
📊 Summary
- Violations: 16 total → 11 auto-fixable, 5 need human review
- Functional validation: all checks passed (fmt, init, validate)
- Grade ceiling: capped at B by zero test coverage; current C reflects validation/structure/security gaps
- Positive notes: LTR implementation is clean, credentials properly marked sensitive, TLS 1.2 enforced, no IAM wildcards, no hardcoded secrets
Labeled platform-review-suggested. Address the CRITICAL and HIGH items before merging for org-wide distribution.
Summary
azure_tf_sql_database
Motivation
Closes #2
What's included
.Terraform resources
azurerm_mssql_databaseazurerm_mssql_firewall_ruleazurerm_mssql_serverValidation
terraform fmtterraform validateterraform testReviewer notes
terraform-module-updateworkflow (StackGen terraform-bot).