Add cross-variable preconditions for autoscale sizing constraints#43
Open
dmchaledev wants to merge 1 commit into
Open
Add cross-variable preconditions for autoscale sizing constraints#43dmchaledev wants to merge 1 commit into
dmchaledev wants to merge 1 commit into
Conversation
Variable-level validation blocks can only reference the single variable being declared, so the documented invariants — asg_desired_capacity must be between asg_min_size and asg_max_size, and db_max_allocated_storage_gb must be at least db_allocated_storage_gb — were enforced only by comments. A misconfigured caller would get a cryptic provider error at apply time rather than a clear plan-time failure. Uses terraform_data lifecycle.precondition (Terraform >=1.4, within our >=1.5 requirement) to add two cross-variable checks to unlimited-scale/aws and one to unlimited-scale/azure: - asg_min_size <= asg_desired_capacity <= asg_max_size (AWS) - db_max_allocated_storage_gb >= db_allocated_storage_gb (AWS) - vmss_min_count <= vmss_default_count <= vmss_max_count (Azure) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011wmAZG2UwZJYvunsUoDHKB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The autoscale tier variables document sizing invariants in their descriptions ("Must be between asg_min_size and asg_max_size") but didn't enforce them. A caller who sets
asg_desired_capacity = 25withasg_max_size = 20gets a cryptic AWS provider error at apply time rather than a clear plan-time failure.Terraform
variablevalidation blocks can only reference the one variable being declared, so cross-variable constraints require a different mechanism. This PR usesterraform_datalifecyclepreconditionblocks (idiomatic Terraform ≥ 1.4, within our ≥ 1.5 floor) to add hard plan-time errors for three cross-variable invariants:modules/unlimited-scale/aws/main.tfasg_min_size ≤ asg_desired_capacity ≤ asg_max_size— AWS rejects an ASG where desired is outside [min, max]db_max_allocated_storage_gb ≥ db_allocated_storage_gb— RDS autoscaling cap must be at least the initial allocationmodules/unlimited-scale/azure/main.tfvmss_min_count ≤ vmss_default_count ≤ vmss_max_count— Azure VMSS rejects a default count outside [min, max]Error messages include the actual values so the caller can fix them without digging into provider logs:
Changes
modules/unlimited-scale/aws/main.tf— addsterraform_data.validate_asg_sizingwith two preconditionsmodules/unlimited-scale/azure/main.tf— addsterraform_data.validate_vmss_sizingwith one preconditionNo variables, outputs, or resources added. No behaviour change for valid inputs. The
terraform validateandtflintCI gates will exercise the new HCL.Test plan
terraform validatepasses inmodules/unlimited-scale/awsandmodules/unlimited-scale/azuretflintpasses with no new findingsasg_desired_capacityoutside[asg_min_size, asg_max_size]surfaces the precondition error at plan timedb_max_allocated_storage_gb < db_allocated_storage_gbsurfaces the precondition error at plan timemin=3, desired=3, max=20) pass all preconditions cleanlyGenerated by Claude Code