Open shettypriy opened 7 months ago
Voting for Prioritization
Volunteering to Work on This Issue
Relates #33867
Hey @shettypriy 👋 Thank you for taking the time to raise this! Are you able to supply debug logs (redacted as needed) in case whoever looks into this needs that information?
hi @justinretzolk I am also facing exact same issue , Kindly let me know how to gather the debug log and share with you
I'm hitting this as well, here's my lockfile https://gist.github.com/darkhelmet/7689bd5928d5832b75b4970a2aef6ee9
I've already updated the Redis instance to 7.1 via the console, and this is now just running plan after I've updated my TF
I encountered the same issue while updating my Terraform AWS provider. My Redis cache instances were originally created using AWS provider version 3, and the engine version I used was specified as "7.x". When I attempted to update the provider to the latest version (5.54.1), I encountered the error related to parsing the engine_version.
To resolve this issue, I initially fixed it by manually modifying the tfstate file. However, this approach is not scalable for my projects because I have a large number of Redis cache instances, making it impractical to edit each tfstate file individually.
We were able to reproduce this issue and believe it's caused by this regex check when matches on [6-9]\.x
when it should only match on 6\.x
.
Create an aws_elasticache_replication_group
resource to use engine_version = "6.x"
resource "aws_elasticache_replication_group" "redis" {
replication_group_id = "redis"
description = "redis-cluster"
subnet_group_name = aws_elasticache_subnet_group.redis.name
security_group_ids = [aws_security_group.redis-instance-sg.id]
node_type = "cache.t2.small"
transit_encryption_enabled = true
apply_immediately = true
engine_version = "6.x"
}
7.1
engine_version = "7.1"
Error: parsing old engine_version: Malformed version: 7.x
setEngineVersionRedis
is responsible for setting the engine_version
attribute. This function gets called by resourceGlobalReplicationGroup()
which performs an AWS API query via resourceGlobalReplicationGroupRead()
.
By looking up the Global Replication Group, the EngineVersion
that gets passed to setEngineVersionRedis
is 7.1
However, configVersion
in this function is actually 6.x
because d.Get(names.AttrEngineVersion).(string)
retrieved from the state file is 6.x
. Because this regex evaluation is true, we update the engine_version
attribute using the value passed into setEngineVersionRedis
, which is 7.1.
As a result, we get a version of 7.x
We believe this was introduced as part of provider v5.3.0 release. Prior to 5.3.0, the plan would have been successful and proposed ~ engine_version = "7.x" -> "7.1" # forces replacement
Update the regex evaluation from
if t, _ := regexp.MatchString(
[6-9].x, configVersion); t {
to
if t, _ := regexp.MatchString(
6.x, configVersion); t {
.
We tested this locally and this seemed to have prevented the malformed error and the plan succeeded.
Terraform Core Version
1.6.4
AWS Provider Version
5.42.0
Affected Resource(s)
aws_elasticache_replication_group
Expected Behavior
should be able to upgrade the version to 7
Actual Behavior
Failing with following error
Relevant Error/Panic Output Snippet
No response
Terraform Configuration Files
It planned and then gave below error
replication group resource:
Steps to Reproduce
Upgraded elasticcache engine versionfrom 6.2.6 to 7.0 from the AWS console, Now trying to update the engine version in the terraform and getting below error
Debug Output
No response
Panic Output
No response
Important Factoids
No response
References
No response
Would you like to implement a fix?
None