Local ElastiCache for integration tests

Run local ElastiCache for integration tests with fakecloud. 75 operations, real Redis/Valkey via Docker, replication groups, serverless caches. Free, no account required.

Need local ElastiCache for integration tests? Use fakecloud.

curl -fsSL https://raw.githubusercontent.com/faiscadev/fakecloud/main/install.sh | bash
fakecloud

Point your AWS SDK at http://localhost:4566. Docker required because fakecloud runs real Redis / Valkey.

Why fakecloud for ElastiCache

Create a Redis cluster

aws --endpoint-url http://localhost:4566 elasticache create-cache-cluster \
  --cache-cluster-id mycache \
  --engine redis \
  --cache-node-type cache.t3.micro \
  --num-cache-nodes 1

Get the endpoint:

aws --endpoint-url http://localhost:4566 elasticache describe-cache-clusters \
  --cache-cluster-id mycache \
  --show-cache-node-info \
  --query 'CacheClusters[0].CacheNodes[0].Endpoint'

Connect:

redis-cli -h <endpoint> -p 6379

Real Redis — all commands work, including CLIENT LIST, INFO, CONFIG GET, modules.

Valkey

aws --endpoint-url http://localhost:4566 elasticache create-cache-cluster \
  --cache-cluster-id mycache \
  --engine valkey \
  --cache-node-type cache.t3.micro \
  --num-cache-nodes 1

Valkey is API-compatible with Redis.

Replication groups

aws --endpoint-url http://localhost:4566 elasticache create-replication-group \
  --replication-group-id my-rg \
  --replication-group-description "test rg" \
  --engine redis \
  --cache-node-type cache.t3.micro \
  --num-node-groups 1 \
  --replicas-per-node-group 1

Real primary + replica nodes via Redis replication.

Serverless caches

aws --endpoint-url http://localhost:4566 elasticache create-serverless-cache \
  --serverless-cache-name myserverless \
  --engine redis

In tests

import { ElastiCacheClient, CreateCacheClusterCommand, DescribeCacheClustersCommand } from '@aws-sdk/client-elasticache';
import { createClient } from 'redis';

const ec = new ElastiCacheClient({ endpoint: 'http://localhost:4566' });

beforeAll(async () => {
  await ec.send(new CreateCacheClusterCommand({
    CacheClusterId: 'test',
    Engine: 'redis',
    CacheNodeType: 'cache.t3.micro',
    NumCacheNodes: 1,
  }));
  // ... poll for "available" ...
});

test('app caches via real redis behind ElastiCache emulation', async () => {
  const redis = createClient({ url: 'redis://localhost:6379' });
  await redis.connect();
  await redis.set('key', 'value');
  expect(await redis.get('key')).toBe('value');
});

How it differs from alternatives

ToolReal RedisReal ValkeyReplication groupsServerless cachesPrice
fakecloudYes (Docker)Yes (Docker)YesYesFree
LocalStack ProYesYesYesPartialPaid
LocalStack CommunityNoNo— (not available)
Plain docker run redisYesN/AManualN/AFree, but no ElastiCache API
MotoStubbedStubbedStubbedStubbedFree