Generated banner for Amazon Elasticache
Generated logo for Amazon Elasticache

Amazon Elasticache

AWSOfficialPublished by AWS

  • Skill
  • Tool integration
  • Cloud and DevOps
  • Apache-2.0
  • Medium risk
  • Has scripts

From the author

Activate when developers have latent caching needs: slow API responses, database read bottlenecks, DynamoDB throttling or cost, RDS/Aurora scaling pressure, Bedrock latency or cost, or adding a cache; activate when working with Redis, Valkey, Memcached, or any in-memory data store, cache-aside patterns, session stores, rate limiting, leaderboards, counters, streams, queues, pub/sub, distributed locks, feature flags, shopping carts, or other caching strategies. Activate for GenAI and ML retrieval: vector similarity search for low-latency retrieval, semantic caching, RAG, LLM response caching, embedding stores, AI agent memory, recommendation, personalization. Activate for ElastiCache lifecycle: provisioning (serverless or node-based), engine selection, CloudFormation/CDK/Terraform IaC, VPC connectivity, TLS, RBAC, IAM auth, Global Datastore, monitoring, troubleshooting, cost optimization, and migration from self-managed Redis. Do not trigger for browser caches, CDN/CloudFront, HTTP Cache-Control, CPU caches.
— the description by AWS

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

The Amazon ElastiCache skill provides a structured, modular approach to managing in-memory data stores on AWS. It guides developers through the entire lifecycle of ElastiCache and Valkey, from initial requirements gathering and provisioning to complex data modeling, AI-driven vector search, and operational monitoring. The skill enforces best practices for connection safety, security, and infrastructure-as-code, ensuring reliable performance for caching, session management, and GenAI workloads.

What it does

  • Assesses workload requirements to recommend optimal ElastiCache configurations.
  • Automates provisioning and connectivity setup for serverless and node-based clusters.
  • Provides implementation patterns for common use cases like cache-aside, session stores, and rate limiting.
  • Supports advanced AI workloads including semantic caching, RAG, and vector similarity search.
  • Delivers operational diagnostics for performance tuning, cost optimization, and troubleshooting.
  • Manages migration paths from self-managed Redis or between different deployment models.

When to use it

  • When you need to reduce database load or improve API response times with an in-memory cache.
  • When implementing AI agent memory, RAG retrieval, or semantic caching for LLM applications.
  • When migrating existing Redis workloads to a managed AWS environment.
  • When troubleshooting performance issues like high latency, replication lag, or memory pressure.
  • When setting up secure, production-ready caching infrastructure using IaC.

Advantages

  • Standardizes deployment and operational patterns across development teams.
  • Ensures compliance with security best practices like TLS and IAM authentication.
  • Reduces configuration errors through automated input validation and tagging.
  • Provides clear guidance on engine selection and version-specific feature availability.
  • Simplifies complex tasks like cross-region migration and vector search setup.

Usage examples

“I need to speed up my RDS database. Should I use ElastiCache?”
The agent will initiate the requirements sub-skill to analyze your workload, stack, and latency needs, then provide a recommendation on whether ElastiCache is the right fit.
“How do I set up a Valkey cluster for vector search?”
The agent will route to the genai sub-skill, verify you are using a node-based Valkey 8.2+ cluster, and provide the necessary configuration and code to enable vector similarity search.
“My cache hit rate is low and latency is spiking. Can you help me troubleshoot?”
The agent will activate the monitoring sub-skill to analyze your metrics, identify potential hot keys or memory imbalance, and suggest specific remediation steps.
“Help me migrate my self-managed Redis to ElastiCache.”
The agent will guide you through the migration sub-skill, performing preflight checks and validating your source configuration for a zero-downtime cutover.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/aws/amazon-elasticache/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip amazon-elasticache.zip -d .agents/skills

Documentation by AWS

ElastiCache

A modular ElastiCache toolkit organized as a registry of sub-skills. Each sub-skill handles one domain of ElastiCache work. The router below matches user intent to the right sub-skill, then loads only the references needed for that sub-skill.

How this skill works

  1. Match the user's request against the semantic categories in the registry below. Match on meaning, not exact wording ("help me figure out which data structures to use" matches data-modeling even without the word "pattern").

  2. Disambiguation: If the user's intent matches multiple sub-skills, apply these rules in order:

    • If .elasticache/requirements.json exists with infrastructure.endpoint set, prefer monitoring or data-modeling (the user has an existing cache).

    • If no cache exists (no requirements.json or no endpoint), prefer requirements.

    • If still ambiguous, ask one clarifying question: "Are you looking to set up something new, or troubleshoot something existing?"

  3. Check the Guardrails section before recommending an engine or deployment model.

  4. Read references/{sub-skill-id}/instructions.md for the matched sub-skill. If the file is not found at a relative path, check your prompt or environment for the skill directory absolute path and retry with {skill-directory}/references/{sub-skill-id}/instructions.md.

  5. If the request spans multiple sub-skills, execute them in pipeline order.

  6. If a sub-skill requires upstream context (engine, deployment model, endpoint) not yet in session memory, route to the upstream sub-skill first.

  7. If no sub-skill matches, activate requirements first.

  8. If a script or CLI call fails, show the error to the user and suggest a specific fix before retrying.

Sub-skill registry

Each entry has: an ID (directory name under references/), a domain description, semantic categories for matching, and upstream/downstream dependencies.

IDNameDomainSemantic CategoriesUpstreamDownstream
requirementsSolution FitGathers workload, stack, scale, latency, persistence, and budget through workspace scan + structured interview. Decides whether ElastiCache is the right service and hands off with a routing recommendation.I need a cache, speed up my app, reduce database load, lower Bedrock cost, should I use ElastiCache, what's best for my workload, evaluating cache options, ElastiCache vs X, Valkey vs X, vague new workload—setup, data-modeling, genai, monitoring, migration
setupCreate and ConnectProvisioning, connectivity, security, authentication, IaC, deployment choice. Gets the user to a working cache with least friction. Covers engine selection, serverless vs node-based, VPC, TLS, RBAC/IAM, jump-host/SSM tunnels, CLI/SDK/CFN/CDK/Terraform starters.create a cache, set up ElastiCache, provision, Valkey cluster, connect Lambda/ECS/EKS/EC2, VPC, security groups, TLS, RBAC, IAM auth, jump host, SSM tunnel, CloudFormation, CDK, Terraform, engine selection, serverless vs node-based, backup, snapshot, restore, exportrequirements (optional)data-modeling, genai, monitoring
data-modelingApplication PatternsPicks data structures, key schema, TTL strategy, invalidation approach, and client code for non-AI patterns: cache-aside, session store, rate limiting, leaderboards, counters, pub/sub, streams, shopping carts, job queues, activity feeds.session store, rate limiting, leaderboard, cache-aside, query caching, counters, streams, pub/sub, shopping cart, job queue, activity feed, key schema, TTL, invalidation, data structuressetup (cache must exist)monitoring
genaiAI and Vector WorkloadsClassifies request into Mode 1 (plain cache), Mode 2 (semantic response cache), or Mode 3 (full vector search). Selects Valkey and forces node-based Valkey 8.2 or above (recommend 9.0) when server-side vector similarity is needed. Covers semantic caching, agent memory, RAG retrieval, recommendation, personalization, conversation/session persistence for AI agents, and framework wiring (Strands, mem0, LangChain).semantic cache, RAG, agent memory, conversational memory, vector search, embeddings, recommendation, personalization, Bedrock latency, Bedrock cost, LLM caching, Strands, mem0, LangChain, conversation history, AI session store, embedding provider, framework integrationsetup (cache must exist)monitoring
monitoringOperate and ObserveDiagnoses performance, cost, and reliability using metrics first, then recommends the smallest change. Covers dashboards, alarms, log delivery, cost reporting, event routing, troubleshooting high CPU / memory / replication lag / connection spikes / low hit rate / hot keys / big keys / slot imbalance / latency spike root cause.cache is slow, cost too high, hit rate low, high CPU, memory pressure, replication lag, connection spikes, dashboards, alarms, CloudWatch, cost comparison, troubleshoot, hot key, uneven shard load, one node pinned, big key, memory bloat, which key is biggest, keyspace distribution, prefix analysis, cost attribution by tenant, memory imbalance, one shard full, slot memory skew, latency spike, slow command incident, root cause for latency bump—setup, migration
migrationEngine and Platform MigrationSelects the migration path and sequences preflight, validation, cutover, and rollback. Covers self-managed Redis → ElastiCache, Redis OSS → Valkey, node-based ↔ serverless, version upgrades. Hard validate-before-migrate gate.migrate, Redis OSS to Valkey, self-managed to ElastiCache, node-based to serverless, serverless to node-based, engine upgrade, version upgrade, zero-downtime cutover, rollback—setup, monitoring

Pipeline order

Sub-skills run independently, but common multi-step journeys follow these pipelines:

  • requirements → setup → (data-modeling | genai) → monitoring

  • migration → setup → monitoring

  • monitoring → setup | migration (if metrics indicate)

State handoff: requirements.json

.elasticache/requirements.json is the single source of truth for cross-sub-skill state. Each sub-skill reads it at start and writes its section after completing work. Read before writing; merge, do not overwrite.

SectionOwnerKey fields
top-levelrequirementsengine, deployment_model, region, runtime, patterns, use_case, vpc_id, subnet_ids, security_group_ids
infrastructuresetupcache_name, resource_id, engine_version, topology, endpoint, port, auth_model, tls, client_library, execution_path, access_mode, tunnel_instance_id, embedding_provider, embedding_model, embedding_dim, embedding_module
genaigenaimode, mode_2_path, framework
migrationmigrationsource_type, source_host, migration_path, cutover_status

Ownership note: deployment_model is set by requirements during initial interview. migration may update it after an engine or deployment model switch (e.g., node-based to serverless).

requirements.json should include "schema_version": 1 and "last_updated": "<ISO timestamp>" at the top level. Every sub-skill that writes to requirements.json must update last_updated. If last_updated is older than 7 days, warn the user that cached state may be stale.

requirements.json tracks one active cache. If the user works with multiple caches in the same project, confirm which cache is active before reading or writing state.

When a sub-skill needs upstream context (engine, endpoint, auth model), check requirements.json first. If the field is null or the file does not exist, route to the upstream sub-skill.

Global rules (apply to every sub-skill)

  1. Execution path. Use AWS CLI, SDK (boto3), CloudFormation, or CDK as the primary path for control-plane work. Use valkey-py as the primary path for data-plane work.

  2. Response depth. Summary (2-3 sentences) for "should I" or "which" questions. Standard (recommendation + config + code + next steps) by default. Expert (full decision matrix with alternatives, cost, security caveats) for "why" or "compare all" questions. Escalate on user request; never downgrade unprompted.

  3. Session memory. Track region, VPC, engine, deployment model, auth model, compute runtime, and language. Carry forward across sub-skills. Do not re-ask. If the user overrides a value, update it everywhere. Inferred values (from workspace scan or IaC) must be re-confirmed before high-risk decisions (engine, deployment model, security posture); low-risk inferences (language, framework, region) can be used as defaults silently.

  4. Source priority. Always answer from skill-local files first (sub-skill references, then scripts/). Do not fetch external documentation or web search unless the local files cannot answer the query. When local files are insufficient, fall back to official AWS docs: https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/ for features and https://aws.amazon.com/elasticache/pricing/ for pricing. Never invent price points or version constraints. If the user references a Valkey or Redis version, feature, or pricing tier not covered in local files, fall back to https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/ before answering. Do not extrapolate from local content that may be outdated.

  5. Freshness disclaimer. When outputting pricing, version constraints, or feature availability, include a one-line disclaimer: "For current pricing see https://aws.amazon.com/elasticache/pricing/. For current feature availability see https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/."

  6. Connection safety. Never create a Valkey/Redis client at module level (top of file, import time). Initialize connections inside a function or on first use. Module-level connections crash applications that import the module before the cache is reachable.

  7. Code environment. Use python3 (not python) in all commands and shebangs. Do not generate pip install or pytest commands in application code. Prefer the agent's file-writing tool over shell redirection for writing files.

  8. Input validation (write operations only). Before running any create, modify, or delete CLI command or SDK call that uses user-provided values (cache name, region, subnet IDs, security group IDs, VPC ID, KMS key, snapshot name), validate them with scripts/input_validator.py. Run python3 scripts/input_validator.py cache_name=<val> region=<val> ... or import validate_all as a library. Skip validation for read-only operations (describe, list) where bad input is harmless.

  9. Resource tagging (always apply on resource creation). When creating any cache (create-serverless-cache, create-replication-group, create-cache-cluster), ALWAYS include these tags:

    --tags Key=managed_by,Value=aws-skills Key=skill,Value=elasticache Key=skill_version,Value=1.0.0 Key=created_by,Value=elasticache-skill Key=generation_model,Value={your-model-id}

    Example: --tags Key=managed_by,Value=aws-skills Key=skill,Value=elasticache Key=skill_version,Value=1.0.0 Key=created_by,Value=elasticache-skill Key=generation_model,Value=claude-sonnet-4-20250514

    Set generation_model to your own model identifier. Include these tags even if the user does not mention tagging. If the user provides additional tags, append these to their tags rather than replacing them.

Reference loading

Load additional references only when the current turn's answer requires them.

On-demand pointers (not preloaded; fetch when the trigger applies):

  • references/shared-ux/production-readiness.md — when the user asks if their cache is ready for production, or after setup completes and the user wants to go to production

  • references/shared-ux/action-safety.md — before any destructive action (risk levels, never-auto-execute list)

  • references/shared-ux/error-remediation.md — when the user hits a specific ElastiCache error code (MOVED, CROSSSLOT, CLUSTERDOWN, MULTI/EXEC+IAM, etc.)

  • references/shared-foundation/boundary-doc.md — when the user asks what this skill covers

  • references/shared-foundation/attribution.md — when generating CLI commands, SDK code, or IaC templates

  • references/shared-foundation/architecture-diagrams.md — when the user asks for architecture diagrams or visual reference

  • references/shared-runtime/lambda.md — when connecting from Lambda (cold start gotchas, IAM auth code, lazy init)

  • references/shared-runtime/ecs.md — when connecting from ECS (SIGTERM shutdown, connection pool drain, task definition)

  • references/shared-runtime/eks.md — when connecting from EKS (IRSA, service mesh bypass, SecurityGroupPolicy CRD)

  • references/shared-runtime/api-gateway.md — when integrating with API Gateway (no direct path, caching layers comparison)

  • references/shared-runtime/rds-acceleration.md — when caching RDS/Aurora queries (thundering herd, stampede protection, invalidation)

  • references/shared-runtime/secret-injection.md — when the user asks about credential management per compute platform

  • references/shared-security/encryption-defaults.md — when adding encryption to an existing unencrypted cluster (TLS two-step migration, at-rest immutability)

  • references/shared-security/config-guardrails.md — when the user wants continuous compliance monitoring (AWS Config rules, custom Lambda rules)

  • references/shared-security/vpc-patterns.md — when debugging port/security-group issues (port 6380 serverless reader, anti-patterns)

Folder convention: references/ contains 10 folders. 6 match the sub-skills (requirements, setup, data-modeling, genai, monitoring, migration) and are routing destinations. The 4 shared-* folders (shared-foundation, shared-ux, shared-security, shared-runtime) are cross-cutting material loaded on demand, not routing destinations.

Guardrails

PriorityRule
CRITICALVector search MUST use node-based Valkey 8.2 or above. Serverless does NOT support vector search. Never suggest serverless for vector search. Apply this regardless of which sub-skill activates.
CRITICALDo not invent price points or version constraints. Use scripts/price_calculator.py and current AWS docs when precision matters.
HIGHDo not recommend Memcached when the user needs persistence, replication, RBAC or IAM auth, sorted sets, streams, pub/sub, or vector search.
HIGHDo not assume local laptop access works directly. ElastiCache is VPC-centric; explain VPC, tunnel, or jump-host access when needed.
STANDARDDo not trigger on every generic Redis mention. Trigger when the user is clearly asking about AWS, managed caching, migration, connectivity, pricing, operations, or AWS service integration.
STANDARDFor ambiguous "cache" requests inside AWS contexts, activate this skill and start with requirements.

Product truths

  • ElastiCache Serverless deploys in under a minute and removes infrastructure management.

  • Valkey serverless pricing is 33% lower than other supported engines; node-based Valkey pricing is 20% lower.

  • Serverless caches have in-transit encryption always enabled (cannot be disabled).

  • IAM auth is available for all ElastiCache Valkey versions (7.2 is the baseline Valkey version on ElastiCache) and Redis OSS 7.0+.

  • Valkey version ladder: 7.2 (baseline), 8.0 (20% more data per node (capacity improvement), per-slot metrics), 8.1 (Bloom filters, COMMANDLOG, SET IFEQ, 20% less memory via new hash table (efficiency improvement)), 8.2 (vector search), 9.0 (recommended default for new clusters). Recommend Valkey 9.0 for new clusters unless a specific feature dictates otherwise.

  • Vector search is available for Valkey 8.2 or above on node-based clusters (recommend 9.0).

  • Global Datastore is available for node-based clusters only. It does not support IPv6 or Local Zones. Global Datastore supports AUTH and RBAC. Cross-region failover must be promoted manually (no autofailover across regions). At-rest encryption must be enabled on all clusters in the Global Datastore, but each cluster can use a separate KMS key per region.

  • Online migration from self-managed Redis to ElastiCache requires: (source) AUTH must not be enabled, protected-mode set to no, replication and administrative commands must not be renamed (e.g., sync, psync, info, config, command, cluster); (target) encryption in-transit disabled, Multi-AZ enabled, engine version Redis OSS 5.0.6+ or Valkey 7.2+, not part of a Global Datastore, data tiering disabled. Shard counts must match between source and target. All source Redis instances must use the same port. Online migration is not supported for serverless caches (node-based targets only). See references/migration/topology-validation.md for the full checklist.

Files

references/migration/auth-migration.md

Authentication Migration Runbooks

Step-by-step procedures for migrating between ElastiCache authentication models and cluster topologies.

AUTH Token to RBAC Migration

Legacy AUTH token authentication uses a single shared password for all clients. RBAC provides per-user access control with fine-grained command and key permissions. This migration moves from the legacy model to the recommended model.

Prerequisites
  • Node-based replication group with TransitEncryptionEnabled: true

  • Engine version Redis OSS 6.0 or higher, or Valkey 7.2 or higher (RBAC is not supported on earlier versions)

  • AUTH token currently configured on the replication group

  • Application code ready to switch to username/password authentication

Step 1: Create RBAC Users

Create one or more RBAC users that match your application's access needs.

# Create an application user with full access
aws elasticache create-user \
  --user-id myapp-appuser \
  --user-name appuser \
  --engine <valkey|redis> \
  --access-string "on ~* +@all" \
  --authentication-mode Type=password,Passwords="<strong-password>" \
  --region <region>

# Create a read-only user for monitoring or reporting
aws elasticache create-user \
  --user-id myapp-readonly \
  --user-name readonly \
  --engine <valkey|redis> \
  --access-string "on ~* +@read" \
  --authentication-mode Type=password,Passwords="<strong-password>" \
  --region <region>

For IAM auth instead of passwords:

aws elasticache create-user \
  --user-id myapp-appuser \
  --user-name myapp-appuser \
  --engine <valkey|redis> \
  --access-string "on ~* +@all" \
  --authentication-mode Type=iam \
  --region <region>

Store RBAC passwords in Secrets Manager:

aws secretsmanager create-secret \
  --name elasticache/myapp/appuser \
  --secret-string '{"username":"appuser","password":"<strong-password>"}' \
  --tags Key=Purpose,Value=elasticache-auth \
  --region <region>
Step 2: Create User Group and Associate
# Create user group (must include the default user)
# Use --engine valkey for Valkey clusters or --engine redis for Redis OSS clusters.
aws elasticache create-user-group \
  --user-group-id myapp-usergroup \
  --engine valkey \
  --user-ids default myapp-appuser myapp-readonly \
  --region <region>

# Associate the user group with the replication group WITHOUT removing the AUTH token
aws elasticache modify-replication-group \
  --replication-group-id <cluster-id> \
  --user-group-ids-to-add myapp-usergroup \
  --region <region>

Note: At this point, both AUTH token and RBAC credentials are active. Existing clients using the AUTH token continue to work.

Step 3: Update Application to Use RBAC Credentials

Update application code to pass username and password (or IAM token) instead of just the AUTH token.

Before (AUTH token):

client = valkey.Valkey(host=endpoint, port=6379, ssl=True, password=auth_token)

After (RBAC):

client = valkey.Valkey(host=endpoint, port=6379, ssl=True,
                       username="appuser", password=rbac_password)

Deploy the updated application. Verify that it connects successfully using RBAC credentials.

Step 4: Verify RBAC Connectivity

Before removing the AUTH token, verify that all clients are successfully authenticating via RBAC:

aws elasticache describe-replication-groups \
  --replication-group-id <cluster-id> \
  --region <region>

# Confirm the output shows:
# "AuthTokenEnabled": true,
# "UserGroupIds": ["myapp-usergroup"]

Confirm that the application works correctly with RBAC credentials and that no clients still depend on the AUTH token.

Step 5: Remove AUTH Token

Now that all clients are using RBAC, remove the AUTH token:

aws elasticache modify-replication-group \
  --replication-group-id <cluster-id> \
  --auth-token-update-strategy DELETE \
  --apply-immediately \
  --region <region>
Step 6: Verify AUTH Token Removal

Verify that the AUTH token is disabled:

aws elasticache describe-replication-groups \
  --replication-group-id <cluster-id> \
  --region <region>

# Confirm the output shows:
# "AuthTokenEnabled": false,
# "UserGroupIds": ["myapp-usergroup"]
Step 7: Verify and Secure the Default User

The default user is always present in RBAC user groups. Disable it or restrict its access to prevent unauthenticated connections:

For Valkey clusters: The default user can be removed from the user group entirely, or disabled:

# Option A: Remove default user from the user group (Valkey only)
aws elasticache modify-user-group \
  --user-group-id myapp-usergroup \
  --user-ids-to-remove default \
  --region <region>

# Option B: Disable the default user (works for both Valkey and Redis OSS)
aws elasticache modify-user \
  --user-id default \
  --access-string "off ~* -@all" \
  --region <region>

For Redis OSS clusters: The default user must remain in the user group (Redis OSS requires it), but should be disabled:

# Disable the default user (required approach for Redis OSS)
aws elasticache modify-user \
  --user-id default \
  --access-string "off ~* -@all" \
  --region <region>

Note: On Redis OSS, removing the default user from a user group will fail. On Valkey, the default user is optional in user groups, so removing it is the cleanest approach.

Rollback Plan

If issues arise during migration:

  1. Before Step 5: The AUTH token is still active. Simply revert application code to use AUTH token authentication and deploy. Both auth methods work simultaneously, so rollback is safe at any point before Step 5

  2. After Step 5: The AUTH token has been removed. To roll back, re-set the AUTH token on the replication group, revert application code, and deploy

  3. Remove the user group association if needed:

    aws elasticache modify-replication-group \
      --replication-group-id <cluster-id> \
      --user-group-ids-to-remove myapp-usergroup \
      --region <region>

Cluster-Mode Disabled to Cluster-Mode Enabled Migration

Cluster-mode disabled uses a single shard (primary + replicas). Cluster-mode enabled uses multiple shards for horizontal scaling. This migration changes the endpoint model and requires client updates.

Prerequisites
  • Understand that cluster-mode enabled changes the client interaction model

  • Client libraries must support MOVED and ASK redirect handling

  • Multi-key commands must use hash tags to colocate keys on the same shard

  • For in-place migration: Minimum engine version of Valkey 7.2 or Redis OSS 7.0 is required

  • For in-place migration: Auto-failover must be enabled with at least 1 replica

  • For in-place migration: The cluster may only have keys in database 0 (multiple databases are not supported)

  • For in-place migration: CMD→CME is a one-way operation. Once cluster mode is set to enabled, it cannot be reverted back to disabled. You can only revert from compatible back to disabled

Impact Assessment
AspectCluster-Mode DisabledCluster-Mode Enabled
Shards11-500 (default limit: up to 90 nodes; 500 requires a limit increase and engine version 5.0.6+; versions below 5.0.6 limited to 250)
Max dataLimited by node memoryDistributed across shards
EndpointSingle primary endpointConfiguration endpoint (resolves to all shards)
ClientStandard clientCluster-aware client required
Multi-key opsUnrestrictedKeys must share a hash slot (use {tag})
KEYS commandWorks (not recommended)Scoped to a single shard
Step 1: Assess Client Compatibility

Verify that all client applications can handle cluster mode:

RuntimeCluster-Aware Client
Python (valkey-py)valkey.cluster.ValkeyCluster
Node.js (iovalkey)new Redis.Cluster([...])
Java (Lettuce)RedisClusterClient.create(uri)
Go (valkey-go)Automatic (handles redirects natively)
CLIvalkey-cli -c

Check for multi-key commands that span keys without hash tags:

  • MGET key1 key2 -- keys must be on the same shard

  • SUNION set1 set2 -- sets must be on the same shard

  • Lua scripts accessing multiple keys -- all keys must be in the same slot

  • MULTI/EXEC transactions -- all keys must be in the same slot

Fix: use hash tags like {user:100}:profile and {user:100}:sessions to ensure related keys land on the same shard.

Step 2: Create a New Cluster-Mode Enabled Cluster

For Valkey 7.2+ or Redis OSS 7.0+, you can perform an in-place migration from cluster-mode disabled to cluster-mode enabled using the modify-replication-group CLI command (or ModifyReplicationGroup API). This is a two-step process: first set cluster mode to compatible, then to enabled. Requirements: auto-failover must be enabled with at least 1 replica, keys must exist only in database 0, and the migration is irreversible once set to enabled (you can revert from compatible back to disabled).

# Step 1: Set cluster mode to compatible
aws elasticache modify-replication-group \
  --replication-group-id <cluster-id> \
  --cache-parameter-group-name <cluster-enabled-parameter-group> \
  --cluster-mode compatible \
  --region <region>

# Wait for the cluster to become available, then update applications
# to use cluster protocol and the configuration endpoint.

# Step 2: Set cluster mode to enabled
aws elasticache modify-replication-group \
  --replication-group-id <cluster-id> \
  --cluster-mode enabled \
  --region <region>

Note: In compatible mode, other modification operations such as scaling and engine version upgrades are not allowed. The cluster endpoints will change once cluster mode is set to enabled. Make sure to update your applications with the new endpoints.

For older engine versions (below Redis OSS 7.0), you must create a new cluster and migrate data.

# Create a new cluster-mode enabled replication group
aws elasticache create-replication-group \
  --replication-group-id <new-cluster-id> \
  --replication-group-description "Cluster-mode enabled migration target" \
  --engine valkey \
  --engine-version <version> \
  --cache-node-type <node-type> \
  --num-node-groups 3 \
  --replicas-per-node-group 1 \
  --cache-subnet-group-name <subnet-group> \
  --security-group-ids <sg-id> \
  --transit-encryption-enabled \
  --at-rest-encryption-enabled \
  --automatic-failover-enabled \
  --multi-az-enabled \
  --region <region>
Step 3: Migrate Data

Option A: Snapshot and restore (brief downtime acceptable)

# Snapshot the old cluster
aws elasticache create-snapshot \
  --replication-group-id <old-cluster-id> \
  --snapshot-name migration-snapshot \
  --region <region>

# Restore to the new cluster (must delete the new cluster first, then recreate from snapshot)
# Note: restoring a snapshot from a cluster-mode disabled cluster into a cluster-mode enabled
# cluster requires the same number of node groups. Plan shard configuration carefully.

Option B: Dual-write migration (zero downtime)

  1. Configure the application to write to both old and new clusters

  2. Run a backfill to copy existing data from old to new (application-level copy)

  3. Gradually shift reads to the new cluster

  4. Stop writes to the old cluster

  5. Decommission the old cluster

Warning: Do NOT use DUMP/RESTORE for data migration between clusters. The serialization format is engine-version-specific and may produce corrupted data on version mismatches. Use application-level copy (read from source, write to target) or the ElastiCache online migration tools instead. Note: The ElastiCache online migration tool (start-migration / complete-migration) is designed exclusively for migrating data from self-hosted open-source Valkey or Redis OSS on Amazon EC2 to ElastiCache. It is not for moving data between ElastiCache clusters. Additionally, the target cluster must not have encryption in-transit enabled, must have Multi-AZ enabled, must not be part of a global datastore, must have data tiering disabled, and the number of shards in source and target must match. Online migration is not supported for ElastiCache serverless caches or clusters running on the r6gd node type. See the Online Migration documentation for details.

Option C: Online migration via ElastiCache (only if source is self-hosted Valkey/Redis on EC2, not an ElastiCache cluster)

# Ensure the target cluster does NOT have TLS enabled and meets all prerequisites above
aws elasticache start-migration \
  --replication-group-id <new-cluster-id> \
  --customer-node-endpoint-list Address=<self-hosted-endpoint>,Port=6379

# After data is in sync, finalize the migration:
aws elasticache complete-migration \
  --replication-group-id <new-cluster-id>
Step 4: Update Application Endpoints

The new cluster uses a configuration endpoint that resolves to all shards. Update connection strings:

Before:

client = valkey.Valkey(host="old-primary-endpoint", port=6379, ssl=True, ...)

After:

client = valkey.cluster.ValkeyCluster(
    host="new-configuration-endpoint", port=6379, ssl=True, ...
)
Step 5: Validate Application Behavior
  • Verify all read and write operations succeed

  • Check for CROSSSLOT errors (indicates multi-key operations on different shards)

  • Monitor CloudWatch metrics for error rates, latency, and connection counts

  • Run valkey-cli -h <new-endpoint> -p 6379 --tls PING for basic validation

Rollback Plan

For the in-place migration path (Valkey 7.2+/Redis OSS 7.0+): Once cluster mode is set to enabled, the change is irreversible — you cannot convert back to cluster-mode disabled. You can only revert from compatible back to disabled before completing the final step. Take a snapshot before setting enabled.

For the new-cluster migration path: The old cluster remains running throughout the migration:

  1. Revert application endpoints to the old cluster

  2. Deploy the reverted application

  3. Delete the new cluster-mode enabled cluster

  4. No data loss (old cluster was never modified)

Note on Endpoint Model Change

This migration changes the endpoint model:

  • Cluster-mode disabled: single primary endpoint + single reader endpoint

  • Cluster-mode enabled: configuration endpoint that the client uses to discover all shards

Applications must update their connection logic, not just the endpoint hostname. This is the most common source of issues during this migration.

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs Python, Needs Node.js

Security

What our scanner noticed· Medium risk

  • References to credential files
  • Instructions that use the network
  • Scripts that your agent may run

This skill includes scripts that your agent may run. Read them before you use it.

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
AWS
Publisher
AWS (Official)
Source
aws/agent-toolkit-for-aws · skills/specialized-skills/database-skills/amazon-elasticache · commit 0a218f8
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • NOTICE (added by AutoGineer from NOTICE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by AWS or AWS.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download amazon-elasticache.zip