You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Revert lifecycle validation to use hardcoded defaults
## Critical Fix: Terraform Validation Constraint
### Issue
BugBot correctly identified that Terraform validation blocks are isolated
and cannot reference other variables. The previous attempt to use
`var.default_lifecycle_cold_storage_after_days` and
`var.default_lifecycle_delete_after_days` in validation blocks would
cause runtime errors during `terraform plan`/`apply`.
### Root Cause
Terraform variable validation blocks can only reference:
- The variable being validated (e.g., `var.rules`)
- Built-in functions and constants
- NOT other variables from the same configuration
### Solution
Reverted lifecycle validation blocks to use hardcoded defaults:
- `try(rule.lifecycle.cold_storage_after, 0)` (back to hardcoded 0)
- `try(rule.lifecycle.delete_after, 90)` (back to hardcoded 90)
This maintains validation functionality while avoiding the Terraform
limitation. The configurable defaults (`var.default_lifecycle_*`) are
still used correctly in resource creation within `main.tf`.
### Impact
- ✅ Terraform validation now works correctly
- ✅ Resource creation still uses configurable defaults
- ✅ No functional regression in validation logic
- ✅ Prevents runtime errors in terraform plan/apply
### Lesson Learned
Variable validation blocks have strict isolation requirements in Terraform.
Future validation improvements should work within these constraints or
use alternative approaches like locals-based validation in main.tf.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
error_message="Lifecycle validation failed: cold_storage_after must be ≤ delete_after, delete_after ≥ 1 day. If cold_storage_after is specified and > 0, it must be ≥ 30 days (AWS requirement). Use 0 to disable cold storage."
error_message="Lifecycle validation failed: cold_storage_after must be ≤ delete_after, delete_after ≥ 1 day. If cold_storage_after is specified and > 0, it must be ≥ 30 days (AWS requirement). Use 0 to disable cold storage."
0 commit comments