Skip to content

Commit bd37b64

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 38072de commit bd37b64

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,21 @@ In case you get an error message similar to this one:
290290
error creating Backup Vault (): AccessDeniedException: status code: 403, request id: 8e7e577e-5b74-4d4d-95d0-bf63e0b2cc2e,
291291
```
292292

293+
Add the [required IAM permissions mentioned in the CreateBackupVault row](https://docs.aws.amazon.com/aws-backup/latest/devguide/access-control.html#backup-api-permissions-ref) to the role or user creating the Vault (the one running Terraform CLI). In particular make sure `kms` and `backup-storage` permissions are added.
294+
<!-- END_TF_DOCS -->
295+
296+
## Known Issues
297+
298+
During the development of the module, the following issues were found:
299+
300+
### Error creating Backup Vault
301+
302+
In case you get an error message similar to this one:
303+
304+
```
305+
error creating Backup Vault (): AccessDeniedException: status code: 403, request id: 8e7e577e-5b74-4d4d-95d0-bf63e0b2cc2e,
306+
```
307+
293308
Add the [required IAM permissions mentioned in the CreateBackupVault row](https://docs.aws.amazon.com/aws-backup/latest/devguide/access-control.html#backup-api-permissions-ref) to the role or user creating the Vault (the one running Terraform CLI). In particular make sure `kms` and `backup-storage` permissions are added.
294309

295310
## Testing

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)