feat: Add variable validation rules to engine_version
to prevent invalid formats
#42
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.
Description
This PR adds comprehensive input validation for the
engine_version
variable to prevent users from accidentally using invalid version formats that cause OpenSearch domain destruction and recreation failures.Key Changes:
engine_version
variable invariables.tf
.pre-commit-config.yaml
with custom engine version validation hookProblem Solved:
Users were mistakenly using software service versions (e.g.,
OpenSearch_2_19_R20250630-P5
) instead of engine versions (e.g.,OpenSearch_2.19
), causing:terraform apply
Motivation and Context
This change is required to prevent a critical issue where users confuse software service versions with engine versions.
Real-world incident:
OpenSearch_2_19_R20250630-P5
Member must satisfy regular expression pattern: ^Elasticsearch_[0-9]{1}\.[0-9]{1,2}$|^OpenSearch_[0-9]{1,2}\.[0-9]{1,2}$
Root Cause:
engine_version
variableBreaking Changes
No breaking changes. This is purely additive validation that:
terraform plan
vsterraform apply
)Existing valid configurations like
engine_version = "OpenSearch_2.11"
continue to work unchanged.How Has This Been Tested?
Validation Testing
Regex Pattern Testing: Validated regex patterns against known valid and invalid formats:
OpenSearch_1.3
,OpenSearch_2.11
,OpenSearch_2.15
,Elasticsearch_7.10
OpenSearch_2_19_R20250630-P5
,OpenSearch_2.19.1
,2.19
Length Validation Testing: Confirmed 18-character limit catches software service versions:
OpenSearch_2.11
(14 chars)OpenSearch_2_19_R20250630-P5
(29 chars)Error Message Testing: Verified clear, actionable error messages are displayed
Pre-commit Testing
Compatibility Testing
engine_version = null
(default) continues to workManual Testing Scenarios
Testing Commands:
Testing Checklist
examples/*
to demonstrate and validate my change(s)examples/*
projectsexamples/complete
- no impact on valid configurationspre-commit run -a
on my pull requestAdditional Testing: