Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid terraform drifting to redis in global replication groups #39950

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion internal/service/elasticache/replication_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func resourceReplicationGroup() *schema.Resource {
names.AttrEngine: {
Type: schema.TypeString,
Optional: true,
Default: engineRedis,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{engineRedis, engineValkey}, true),
},
names.AttrEngineVersion: {
Expand Down Expand Up @@ -417,6 +417,22 @@ func resourceReplicationGroup() *schema.Resource {
// be configured during creation of the cluster.
return semver.LessThan(d.Get("engine_version_actual").(string), "7.0.5")
}),
customdiff.ForceNewIf(names.AttrEngine, func(_ context.Context, d *schema.ResourceDiff, meta interface{}) bool {
// If this is part of a global replication group, engine should match global group
if _, ok := d.GetOk("global_replication_group_id"); ok {
// Engine is determined by global replication group
return false
}
// For standalone replication groups, only allow Redis -> Valkey without replacement
if !d.HasChange(names.AttrEngine) {
return false
}
// If engine is changing, check if it is changing from Redis to Valkey
if old, new := d.GetChange(names.AttrEngine); old.(string) == engineRedis && new.(string) == engineValkey {
return false
}
return true
}),
replicationGroupValidateAutomaticFailoverNumCacheClusters,
verify.SetTagsDiff,
),
Expand Down
Loading