fix(elasticache): store the user Engine instead of hardcoding redis (#2331)

CreateUser dropped the Engine parameter and userXml emitted a literal
redis, so a user created with Engine=valkey read back as redis on
CreateUser, DescribeUsers, ModifyUser and DeleteUser - the issue's
aws_elasticache_user resource plans a diff on every run and never
converges.

Store the engine on ElastiCacheUser, defaulting a missing value to
redis to keep the previous behavior for callers that omit it. Accept
Engine on ModifyUser too, which AWS models as an optional parameter,
validating it before the first setter so a rejected request leaves
the user untouched - the storage backends hand back the live stored
object, so a mutation applied before validation would survive the
400. Honor the documented Engine filter on DescribeUsers, which means
something now that users can differ by engine. Values are validated
redis/valkey case-insensitively, matching the handler's existing
memcached check. MinimumEngineVersion stays at 6.0, the only value
AWS documents for the element. Users persisted before the engine
field existed deserialize with the redis default.

Closes #2290
This commit is contained in:
soreavis authored and GitHub committed 2026-08-15 18:16:57 -04:00
1 parent 20470b7f4a
commit 7a4fc45fdf
7 files changed
+423 -13

No files matched your search

@@ -155,6 +155,7 @@ class ElastiCacheTest {
assertThat(response.userId()).isEqualTo(userId);
assertThat(response.userName()).isEqualTo(userName);
assertThat(response.engine()).isEqualTo("redis");
assertThat(response.authentication().typeAsString()).isEqualTo("password");
assertThat(response.authentication().passwordCount()).isEqualTo(1);
userCreated = true;
@@ -168,7 +169,8 @@ class ElastiCacheTest {
var response = elasticache.describeUsers(DescribeUsersRequest.builder().build());
assertThat(response.users())
.anyMatch(user -> user.userId().equals(userId) && user.userName().equals(userName));
.anyMatch(user -> user.userId().equals(userId) && user.userName().equals(userName)
&& "redis".equals(user.engine()));
}
@Test
@@ -271,6 +273,27 @@ class ElastiCacheTest {
@Test
@Order(11)
void valkeyUserRoundTripEchoesEngine() {
String valkeyUserId = TestFixtures.uniqueName("ec-valkey-user");
var created = elasticache.createUser(CreateUserRequest.builder()
.userId(valkeyUserId)
.userName(TestFixtures.uniqueName("ec-valkey-name"))
.engine("valkey")
.accessString("on ~* +@all")
.authenticationMode(AuthenticationMode.builder()
.type(InputAuthenticationType.NO_PASSWORD_REQUIRED)
.build())
.build());
assertThat(created.engine()).isEqualTo("valkey");
var deleted = elasticache.deleteUser(DeleteUserRequest.builder()
.userId(valkeyUserId)
.build());
assertThat(deleted.engine()).isEqualTo("valkey");
}
@Test
@Order(12)
void deleteReplicationGroupReleasesPortForReuse() {
requireGroup();