core: add default validation rules for ElastiCache ReplicationGroup
Describe the feature
Ship CDK-authored default Rego rules for AWS::ElastiCache::ReplicationGroup, following the mechanism added in #38448.
Four property combinations are schema-valid, so template validation passes and the deploy proceeds, but CreateReplicationGroup rejects every one of them:
| Rule | Combination | API error |
|---|---|---|
| CDK-ElastiCache-001 | NumNodeGroups > 1 against a parameter group that leaves cluster-enabled at no |
Use a parameter group with cluster-enabled parameter to create more than one node group. |
| CDK-ElastiCache-002 | UserGroupIds without TransitEncryptionEnabled |
User group based access control requires encryption-in-transit to be enabled on the replication group. |
| CDK-ElastiCache-003 | AuthToken without TransitEncryptionEnabled |
The AUTH token is only supported when encryption-in-transit is enabled |
| CDK-ElastiCache-004 | DataTieringEnabled on a node type outside the r6gd family |
Data tiering is not supported for the node type <type>. |
Use Case
AWS::ElastiCache::ReplicationGroup has no L2 construct — not in aws-cdk-lib, and not in aws-elasticache-alpha, which covers serverless caches and users only. Every replication group in a CDK app is therefore written as an L1, so there is no construct-level validation these checks could live in.
Without them the mistake surfaces as a CloudFormation rollback partway through a deploy instead of a warning at synth.
Rule 001 additionally cannot be expressed in any single construct: cluster mode is a property of the parameter group, not of the replication group, so the check has to join the two resources through the template's Ref graph.
Proposed Solution
Add packages/aws-cdk-lib/core/lib/validation/rules/elasticache-replication-group.rego, picked up automatically by the default CloudFormationValidatePlugin instance.
Because the rules run on the synthesized template, they also cover resources defined through escape hatches and CfnInclude, and token-valued properties are already resolved.
Other Information
Each error above was reproduced directly against the ElastiCache API; the probe commands and verbatim responses are in the PR.
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
AWS CDK Library version (aws-cdk-lib)
2.270.0AWS CDK CLI version
2.1131.0Environment details (OS name and version, etc.)
macOS 14.6.0 (darwin 23.6.0), Node.js v20.19.2Source: aws/aws-cdk