mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(elasticache): use the AWS wire codes UserNotFound and UserAlreadyExists (#5452)
* fix(elasticache): use the AWS wire codes UserNotFound and UserAlreadyExists * fix(elasticache): tolerate UserNotFound on CFN user delete and fix SDK test assertions The CloudFormation user delete still tolerated the old UserNotFoundFault code, so deleting a stack whose user was already gone would report DELETE_FAILED. The SDK compatibility test also asserted UserAlreadyExistsException on the duplicate replication group test instead of the duplicate user test.
This commit is contained in:
1 parent
f50437efba
commit
b318794fa2
5 files changed
+24
-12
No files matched your search
+1
-1
@@ -455,7 +455,7 @@ public class ElastiCacheCfnProvisioner implements CfnResourceProvisioner {
|
||||
case USER_GROUP -> CfnDeletes.safeDelete("ElastiCache user group", physicalId,
|
||||
() -> elastiCacheService.deleteUserGroup(physicalId), "UserGroupNotFound");
|
||||
case USER -> CfnDeletes.safeDelete("ElastiCache user", physicalId,
|
||||
() -> elastiCacheService.deleteUser(physicalId), "UserNotFoundFault");
|
||||
() -> elastiCacheService.deleteUser(physicalId), "UserNotFound");
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -1806,7 +1806,7 @@ public class ElastiCacheService implements ResourceProvider {
|
||||
public ElastiCacheUser createUser(String userId, String userName, AuthMode authMode,
|
||||
List<String> passwords, String accessString, String engine) {
|
||||
if (users.get(userId).isPresent()) {
|
||||
throw new AwsException("UserAlreadyExistsFault",
|
||||
throw new AwsException("UserAlreadyExists",
|
||||
"User " + userId + " already exists.", 400);
|
||||
}
|
||||
|
||||
@@ -1827,7 +1827,7 @@ public class ElastiCacheService implements ResourceProvider {
|
||||
|
||||
public ElastiCacheUser getUser(String userId) {
|
||||
return users.get(userId).orElseThrow(() ->
|
||||
new AwsException("UserNotFoundFault", "User " + userId + " not found.", 404));
|
||||
new AwsException("UserNotFound", "User " + userId + " not found.", 404));
|
||||
}
|
||||
|
||||
public Collection<ElastiCacheUser> listUsers(String filterUserId, String filterEngine) {
|
||||
@@ -1835,7 +1835,7 @@ public class ElastiCacheService implements ResourceProvider {
|
||||
if (filterUserId != null && !filterUserId.isBlank()) {
|
||||
return users.get(filterUserId)
|
||||
.map(List::of)
|
||||
.orElseThrow(() -> new AwsException("UserNotFoundFault",
|
||||
.orElseThrow(() -> new AwsException("UserNotFound",
|
||||
"User " + filterUserId + " not found.", 404));
|
||||
}
|
||||
if (filterEngine != null && !filterEngine.isBlank()) {
|
||||
@@ -1890,7 +1890,7 @@ public class ElastiCacheService implements ResourceProvider {
|
||||
|
||||
public void deleteUser(String userId) {
|
||||
if (users.get(userId).isEmpty()) {
|
||||
throw new AwsException("UserNotFoundFault", "User " + userId + " not found.", 404);
|
||||
throw new AwsException("UserNotFound", "User " + userId + " not found.", 404);
|
||||
}
|
||||
synchronized (userGroupLock) {
|
||||
users.delete(userId);
|
||||
|
||||
Reference in new issue
Block a user