Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-elasticache-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ const user = new elasticache.NoPasswordUser(this, 'User', {
});
```

> NOTE: `NoPasswordUser` is only available for Redis Cache.

### Default user

ElastiCache automatically creates a default user with both a user ID and username set to `default`. This default user cannot be modified or deleted. The user is created as a no password authentication user.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import { UserBase, UserBaseProps } from './user-base';

const ELASTICACHE_NOPASSWORDUSER_SYMBOL = Symbol.for('@aws-cdk/aws-elasticache.NoPasswordUser');

/**
* List of engines that support no-password authentication.
*/
const SUPPORTED_NO_PASSWORD_ENGINES = [UserEngine.REDIS];

/**
* Properties for defining an ElastiCache user with no password authentication.
*/
Expand Down Expand Up @@ -86,8 +91,8 @@ export class NoPasswordUser extends UserBase {
this.userName = props.userName ?? props.userId;
this.accessString = props.accessControl.accessString;

if (this.engine === UserEngine.VALKEY) {
throw new ValidationError('Valkey engine does not support no-password authentication.', this);
if (!SUPPORTED_NO_PASSWORD_ENGINES.includes(this.engine)) {
throw new ValidationError(`Engine '${this.engine}' does not support no-password authentication. Supported engines: ${SUPPORTED_NO_PASSWORD_ENGINES.join(', ')}.`, this);
}

this.resource = new CfnUser(this, 'Resource', {
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-elasticache-alpha/lib/user-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export interface UserBaseProps {
* The engine type for the user.
* Enum options: UserEngine.VALKEY, UserEngine.REDIS.
*
* @default UserEngine.VALKEY.
* @default - UserEngine.REDIS for NoPasswordUser, UserEngine.VALKEY for all other user types.
*/
readonly engine?: UserEngine;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('NoPasswordUser', () => {
userId: 'test-user',
engine: UserEngine.VALKEY,
accessControl: AccessControl.fromAccessString('on ~* +@all'),
})).toThrow('Valkey engine does not support no-password authentication.');
})).toThrow("Engine 'valkey' does not support no-password authentication. Supported engines: redis.");
});
});

Expand Down
Loading