Skip to content
Open
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
5 changes: 2 additions & 3 deletions packages/@aws-cdk/aws-elasticache-alpha/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,6 @@ You can also create a no password required user by using `NoPasswordUser` constr

```ts
const user = new elasticache.NoPasswordUser(this, 'User', {
// set user engine
engine: elasticache.UserEngine.REDIS,

// set user id
userId: 'my-user-id',

Expand All @@ -305,6 +302,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
7 changes: 7 additions & 0 deletions packages/@aws-cdk/aws-elasticache-alpha/lib/iam-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ export interface IamUserProps extends UserBaseProps {
* @default - Same as userId.
*/
readonly userName?: string;
/**
* The engine type for the user.
* Enum options: UserEngine.VALKEY, UserEngine.REDIS.
*
* @default UserEngine.VALKEY.
*/
readonly engine?: UserEngine;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Construct } from 'constructs';
import { UserEngine } from './common';
import { CfnUser } from 'aws-cdk-lib/aws-elasticache';
import { UserBase, UserBaseProps } from './user-base';
import { ValidationError } from 'aws-cdk-lib/core';
import { addConstructMetadata } from 'aws-cdk-lib/core/lib/metadata-resource';
import { propertyInjectable } from 'aws-cdk-lib/core/lib/prop-injectable';

Expand Down Expand Up @@ -81,15 +80,11 @@ export class NoPasswordUser extends UserBase {
// Enhanced CDK Analytics Telemetry
addConstructMetadata(this, props);

this.engine = props.engine ?? UserEngine.REDIS;
this.engine = UserEngine.REDIS;
this.userId = props.userId;
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);
}

this.resource = new CfnUser(this, 'Resource', {
engine: this.engine,
userId: props.userId,
Expand Down
7 changes: 7 additions & 0 deletions packages/@aws-cdk/aws-elasticache-alpha/lib/password-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ export interface PasswordUserProps extends UserBaseProps {
* @default - Same as userId.
*/
readonly userName?: string;
/**
* The engine type for the user.
* Enum options: UserEngine.VALKEY, UserEngine.REDIS.
*
* @default UserEngine.VALKEY.
*/
readonly engine?: UserEngine;
/**
* The passwords for the user.
* Password authentication requires using 1-2 passwords.
Expand Down
7 changes: 0 additions & 7 deletions packages/@aws-cdk/aws-elasticache-alpha/lib/user-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ class AccessControlString extends AccessControl {
* Properties for defining an ElastiCache base user.
*/
export interface UserBaseProps {
/**
* The engine type for the user.
* Enum options: UserEngine.VALKEY, UserEngine.REDIS.
*
* @default UserEngine.VALKEY.
*/
readonly engine?: UserEngine;
/**
* The ID of the user.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,6 @@ import { Stack } from 'aws-cdk-lib';
import { NoPasswordUser, AccessControl, UserEngine } from '../lib';

describe('NoPasswordUser', () => {
describe('validation errors', () => {
let stack: Stack;
beforeEach(() => {
stack = new Stack();
});

test('when using Valkey engine throws validation error', () => {
expect(() => new NoPasswordUser(stack, 'TestUser', {
userId: 'test-user',
engine: UserEngine.VALKEY,
accessControl: AccessControl.fromAccessString('on ~* +@all'),
})).toThrow('Valkey engine does not support no-password authentication.');
});
});

describe('constructor', () => {
let stack: Stack;
beforeEach(() => {
Expand All @@ -27,7 +12,6 @@ describe('NoPasswordUser', () => {
test('creates user with minimal required properties', () => {
new NoPasswordUser(stack, 'TestUser', {
userId: 'test-user',
engine: UserEngine.REDIS,
accessControl: AccessControl.fromAccessString('on ~* +@all'),
});

Expand All @@ -49,7 +33,6 @@ describe('NoPasswordUser', () => {
new NoPasswordUser(stack, 'TestUser', {
userId: 'test-user',
accessControl: AccessControl.fromAccessString('on ~app:* +@read +@write'),
engine: UserEngine.REDIS,
userName: 'test-user-name',
});

Expand All @@ -71,7 +54,6 @@ describe('NoPasswordUser', () => {
new NoPasswordUser(stack, 'TestUser', {
userId: 'test-user',
accessControl: AccessControl.fromAccessString('on ~* +@all'),
engine: UserEngine.REDIS,
});

const template = Template.fromStack(stack);
Expand All @@ -89,7 +71,6 @@ describe('NoPasswordUser', () => {
const user = new NoPasswordUser(stack, 'TestUser', {
userId: 'test-user-id',
userName: 'test-user-name',
engine: UserEngine.REDIS,
accessControl: AccessControl.fromAccessString('on ~app:* +@read'),
});

Expand All @@ -104,7 +85,6 @@ describe('NoPasswordUser', () => {
test('userName defaults to userId when not provided', () => {
const user = new NoPasswordUser(stack, 'TestUser', {
userId: 'my-user-id',
engine: UserEngine.REDIS,
accessControl: AccessControl.fromAccessString('on ~* +@all'),
});

Expand All @@ -118,7 +98,6 @@ describe('NoPasswordUser', () => {
const stack = new Stack();
const user = new NoPasswordUser(stack, 'TestUser', {
userId: 'test-user',
engine: UserEngine.REDIS,
accessControl: AccessControl.fromAccessString('on ~* +@all'),
});

Expand Down
10 changes: 0 additions & 10 deletions packages/@aws-cdk/aws-elasticache-alpha/test/user-group.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,11 @@ describe('UserGroup', () => {
new NoPasswordUser(stack, 'TestUser1', {
userId: 'user1',
userName: 'duplicate-name',
engine: UserEngine.REDIS,
accessControl: AccessControl.fromAccessString('on ~* +@all'),
}),
new NoPasswordUser(stack, 'TestUser2', {
userId: 'user2',
userName: 'duplicate-name',
engine: UserEngine.REDIS,
accessControl: AccessControl.fromAccessString('on ~* +@all'),
}),
];
Expand Down Expand Up @@ -179,7 +177,6 @@ describe('UserGroup', () => {
test('creates Redis user group with minimal required properties', () => {
const user = new NoPasswordUser(stack, 'TestUser', {
userId: 'default',
engine: UserEngine.REDIS,
accessControl: AccessControl.fromAccessString('on ~app:* +@read +@write'),
});

Expand Down Expand Up @@ -220,7 +217,6 @@ describe('UserGroup', () => {
test('creates Valkey user group with both Redis and Valkey users', () => {
const redisUser = new NoPasswordUser(stack, 'RedisUser', {
userId: 'redis-user',
engine: UserEngine.REDIS,
accessControl: AccessControl.fromAccessString('on ~* +@all'),
});

Expand Down Expand Up @@ -325,7 +321,6 @@ describe('UserGroup', () => {
});
const user = new NoPasswordUser(stack, 'TestUser', {
userId: 'test-user',
engine: UserEngine.REDIS,
accessControl: AccessControl.fromAccessString('on ~* +@all'),
});

Expand All @@ -338,7 +333,6 @@ describe('UserGroup', () => {
test('adds second user to group that already has one user', () => {
const existingUser = new NoPasswordUser(stack, 'ExistingUser', {
userId: 'existing-user',
engine: UserEngine.REDIS,
accessControl: AccessControl.fromAccessString('on ~* +@all'),
});

Expand All @@ -349,7 +343,6 @@ describe('UserGroup', () => {

const newUser = new NoPasswordUser(stack, 'NewUser', {
userId: 'new-user',
engine: UserEngine.REDIS,
accessControl: AccessControl.fromAccessString('on ~* +@all'),
});

Expand Down Expand Up @@ -425,7 +418,6 @@ describe('UserGroup', () => {
test('fromUserGroupAttributes preserves users when provided', () => {
const user = new NoPasswordUser(stack, 'TestUser', {
userId: 'test-user',
engine: UserEngine.REDIS,
accessControl: AccessControl.fromAccessString('on ~* +@all'),
});

Expand All @@ -441,7 +433,6 @@ describe('UserGroup', () => {
test('fromUserGroupAttributes works with both engine and users', () => {
const user = new NoPasswordUser(stack, 'TestUser', {
userId: 'test-user',
engine: UserEngine.REDIS,
accessControl: AccessControl.fromAccessString('on ~* +@all'),
});

Expand All @@ -462,7 +453,6 @@ describe('UserGroup', () => {
const arn = 'arn:aws:elasticache:us-east-1:123456789012:usergroup:my-group';
const user = new NoPasswordUser(stack, 'TestUser', {
userId: 'test-user',
engine: UserEngine.REDIS,
accessControl: AccessControl.fromAccessString('on ~* +@all'),
});

Expand Down
Loading