Skip to content

Conversation

@go-to-k
Copy link
Contributor

@go-to-k go-to-k commented Aug 18, 2025

Issue # (if applicable)

Closes #76 .

Reason for this change

Correct major engine version cannot be set on serverless cache for memcached.

Currently the same MajorVersion property is used for all the engine.

export enum MajorVersion {
  /**
   * Version 7
   */
  VER_7 = '7',

  /**
   * Version 8
   */
  VER_8 = '8',
}

new aws_elasticache.ServerlessCache(this, 'ServerlessCache', {
  engine: aws_elasitcache.Engine.VALKEY,
  majorEngineVersion: aws_elasticache.MajorVersion.Ver_8
  vpc,
});

https://github.com/open-constructs/aws-cdk-library/blob/v0.1.0/src/aws-elasticache/serverless-cache.ts#L69-L79

But the major version 1.6 can only be specified for memcached.

And 7 and 8 for valkey and 7 for redis only can be specified.

Supported versions: https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/engine-versions.html

FYI: https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/VersionManagement.html

ElastiCache serverless caches support ElastiCache version 7.2 for Valkey and above, ElastiCache version 1.6 for Memcached and above, and ElastiCache 7.0 for Redis OSS and above.

Description of changes

Two approaches can be applied for the issue:

1. Adding a new version (1.6 / VER_1_6) for memcached in the existing enum property

This approach is adding the new version VER_1_6 to the existing enum.

But additional validation process for correct combinations is required and the usability is not good because users can choose any of the options even though different engines have different possible versions.

export enum MajorVersion {
  /**
-   * Version 7
+   * Version 7 for Valkey and Redis only
   */
  VER_7 = '7',

  /**
-   * Version 8
+   * Version 8 for Valkey only
   */
  VER_8 = '8',
+
+  /**
+   * Version 1.6 for Memcached only
+   */
+  VER_1_6 = '1.6',
}

2. Adding a new property for each engine, including version

I decided to use this approach in this PR.

This approach removes the existing engine and majorEngineVersion properties and adds a new serverlessCacheEngine property using Enum-like classes.

    new ocf.aws_elasticache.ServerlessCache(this, 'Valkey8', {
      serverlessCacheEngine: ocf.aws_elasticache.ServerlessCacheEngine.valkey({
        engineVersion: ocf.aws_elasticache.ValkeyEngineVersion.VER_8,
      }),
      vpc,
    });

    new ocf.aws_elasticache.ServerlessCache(this, 'Memcached1_6', {
      serverlessCacheEngine: ocf.aws_elasticache.ServerlessCacheEngine.memcached({
        engineVersion: ocf.aws_elasticache.MemcachedEngineVersion.VER_1_6,
      }),
      vpc,
    });

This would be a breaking change since it would remove existing properties, but we are still on version 0 so it is doable. I think it is too early to adopt Approach 1 for backward compatibility concerns. Approach 1 is not a good approach and is inconvenient for users.

Also, those old properties are required properties now, so we CANNOT use the feature flag alternative.

Description of how you validated changes

Both unit tests and integ tests.

Checklist

  • My code adheres to the CONTRIBUTING GUIDE
  • My pull request adheres to the Pull Request Rule
    • Do not omit the aws- part in the scope of the PR title if the PR relates to a specific AWS service module.
    • e.g.) feat(aws-s3): description of the change

Breaking Change

BREAKING CHANGE: The existing properties engine and majorEngineVersion for ServerlessCache will be removed, users will have to use the new property serverlessCacheEngine.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@go-to-k go-to-k changed the title fix(aws-elasticache)\!: memcached engine version cannot be set on serverless cache fix(aws-elasticache)!: memcached engine version cannot be set on serverless cache Aug 18, 2025
@go-to-k go-to-k changed the title fix(aws-elasticache)!: memcached engine version cannot be set on serverless cache fix(aws-elasticache)!: correct engine version cannot be set on serverless cache for memcached Aug 18, 2025
@go-to-k go-to-k changed the title fix(aws-elasticache)!: correct engine version cannot be set on serverless cache for memcached fix(aws-elasticache)!: correct major engine version cannot be set on serverless cache for memcached Aug 20, 2025
@go-to-k go-to-k changed the title fix(aws-elasticache)!: correct major engine version cannot be set on serverless cache for memcached fix(aws-elasticache)!: correct major engine versions cannot be set on serverless cache for memcached Aug 20, 2025
@go-to-k go-to-k changed the title fix(aws-elasticache)!: correct major engine versions cannot be set on serverless cache for memcached fix(aws-elasticache)!: correct major engine version cannot be set on serverless cache for memcached Aug 20, 2025
Comment on lines +3 to +8
interface EngineVersionBaseProps {
/**
* The major version of the engine.
*/
readonly majorVersion: string;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created the props instead of directly using majorVersion as arguments for the EngineVersion in case properties such as fullVersion are added in the future.

Comment on lines +21 to +24
/**
* Properties for the Valkey engine version.
*/
export interface ValkeyEngineVersionProps extends EngineVersionBaseProps {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering the possibility that properties such as fullVersion may be added only for partial engines in the future, I have prepared props for each engine: ValkeyEngineVersionProps, RedisEngineVersionProps and MemcachedEngineVersionProps.

Comment on lines +54 to +62
/**
* Properties of the Valkey engine for serverless cache.
*/
export interface ValkeyEngineProps {
/**
* The engine version of the Valkey engine.
*/
readonly engineVersion: ValkeyEngineVersion;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The EngineVersion class (property) is wrapped in the EngineProps for factory methods of the ServerlessCacheEngine to allow for the possibility of additional elements other than the version in the future.

@go-to-k go-to-k marked this pull request as ready for review August 20, 2025 09:45
@go-to-k go-to-k marked this pull request as draft August 20, 2025 16:02
@go-to-k go-to-k marked this pull request as ready for review August 20, 2025 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ServerlessCache for memecache fail because of memcache not support Platform Version 8

1 participant