Skip to content

Commit d6a6d1f

Browse files
committed
refactor: improve retention_days_cross_valid clarity and add version compatibility docs
This commit builds on the fix from PR #283 with two improvements: 1. Clarify validation logic in main.tf:20 - Change from: (var.min_retention_days == null || var.max_retention_days == null) ? true : ... - Change to: (var.min_retention_days != null && var.max_retention_days != null) ? (...) : true - This explicit ternary pattern makes intent clearer: "compare only when both non-null" - Improves code readability and maintainability for future developers - Logically equivalent to original fix, with improved clarity 2. Document version compatibility in versions.tf - Add comments explaining tested Terraform versions (1.3.0 - 1.11.4+) - Add comments explaining tested OpenTofu versions (1.6.0 - 1.9.3+) - Document the null handling issue fixed in main.tf - Help users understand version support boundaries These improvements maintain all existing functionality while enhancing code clarity and providing better documentation for future maintainers.
1 parent 8b201d6 commit d6a6d1f

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ locals {
1717
airgapped_vault_requirements_met = var.vault_type != "logically_air_gapped" || (var.min_retention_days != null && var.max_retention_days != null)
1818

1919
# Cross-validation for retention days (unified validation approach)
20-
retention_days_cross_valid = (var.min_retention_days == null || var.max_retention_days == null) ? true : var.min_retention_days <= var.max_retention_days
20+
retention_days_cross_valid = (var.min_retention_days != null && var.max_retention_days != null) ? (var.min_retention_days <= var.max_retention_days) : true
2121

2222
# Vault reference helpers (dynamic based on vault type)
2323
vault_name = local.should_create_standard_vault ? try(aws_backup_vault.ab_vault[0].name, null) : (

versions.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
# Version compatibility requirements
2+
# Terraform: >= 1.3.0 (tested on 1.3.0 - 1.11.4+)
3+
# OpenTofu: >= 1.6.0 (tested on 1.6.0 - 1.9.3+)
4+
#
5+
# Note: Terraform 1.0-1.2 and OpenTofu < 1.6 may experience "argument must not be null" errors
6+
# when using vault lock features due to null value handling in boolean expressions.
7+
# This module includes fixes in main.tf (retention_days_cross_valid) to ensure compatibility
8+
# with newer versions while maintaining correct validation logic.
9+
110
terraform {
211
required_version = ">= 1.3.0"
312

0 commit comments

Comments
 (0)