Closed madpipeline closed 1 year ago
Voting for Prioritization
Volunteering to Work on This Issue
I'm seeing this issue when upgrading from 6 => 7 as well.
It does a drop and replace.
I was able to replicate the bug:
package main
import (
"fmt"
gversion "github.com/hashicorp/go-version"
"math"
"regexp"
)
const (
redisVersionPreV6RegexpRaw = `[1-5](\.[[:digit:]]+){2}`
redisVersionPostV6RegexpRaw = `(([6-9])\.x)|([6-9]\.[[:digit:]]+)`
redisVersionRegexpRaw = redisVersionPreV6RegexpRaw + "|" + redisVersionPostV6RegexpRaw
)
const (
redisVersionRegexpPattern = "^" + redisVersionRegexpRaw + "$"
redisVersionPostV6RegexpPattern = "^" + redisVersionPostV6RegexpRaw + "$"
)
var (
redisVersionRegexp = regexp.MustCompile(redisVersionRegexpPattern)
redisVersionPostV6Regexp = regexp.MustCompile(redisVersionPostV6RegexpPattern)
)
func normalizeEngineVersion(version string) (*gversion.Version, error) {
if matches := redisVersionPostV6Regexp.FindStringSubmatch(version); matches != nil {
if matches[1] != "" {
version = fmt.Sprintf("%s.%d", matches[2], math.MaxInt)
} else if matches[3] != "" {
version = matches[3]
}
}
return gversion.NewVersion(version)
}
func main() {
oVersion, _ := normalizeEngineVersion("6.x")
nVersion, _ := normalizeEngineVersion("6.0")
print(nVersion.LessThan(oVersion))
}
This return true
as x
is 'higher' than any digit.
When comparing two versions:
func main() {
oVersion, _ := normalizeEngineVersion("6.0")
nVersion, _ := normalizeEngineVersion("6.2")
print(nVersion.LessThan(oVersion))
}
Works as expected returning false
Looks like changing this:
const (
redisVersionRegexpPattern = "^" + redisVersionRegexpRaw + "$"
redisVersionPostV6RegexpPattern = "^" + redisVersionPostV6RegexpRaw + "$"
)
to:
const (
redisVersionRegexpPattern = "^(?:" + redisVersionRegexpRaw + ")$"
redisVersionPostV6RegexpPattern = "^(?:" + redisVersionPostV6RegexpRaw + ")$"
)
works fine, as with the previous implementation 2.8.12
will be detected as 8.12
as minor
is higher or equal than 6
This functionality has been released in v5.22.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.
For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Terraform Core Version
v1.3.5
AWS Provider Version
v4.40.0
Affected Resource(s)
Expected Behavior
When upgrading the
aws_elasticache_replication_group
engine_version
from any version to any version to upgrade the resource in-place, just like in the AWS Console.Actual Behavior
When upgrading from version
2.8.24
to any other higher version, the plan wants to destroy and recreate the resource.Upgrading from any other higher version to a higher version works as expected.
Relevant Error/Panic Output Snippet
No response
Terraform Configuration Files
Steps to Reproduce
2.8.24
terraform plan
The plan will attempt to destroy-recreate the resource instead of upgrading in place.
Debug Output
No response
Panic Output
No response
Important Factoids
According to the CloudFormation documentation on the Engine version, the upgrade should happen in place, with no down time.
References
Would you like to implement a fix?
Yes