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
fakecloudPoint your AWS SDK at http://localhost:4566. Docker required because fakecloud runs real Redis / Valkey.
Why fakecloud for ElastiCache
- 75 ElastiCache operations at 100% conformance — cache clusters, replication groups, global replication groups, serverless caches and snapshots, subnet groups, users / user groups, failover, tagging.
- Real Redis and real Valkey. fakecloud pulls real Redis / Valkey Docker images and runs them as the ElastiCache node. Your
LPUSH,ZADD,XADD, streams, pub/sub, Lua scripts — all work because the engine is real. - Endpoint works.
DescribeCacheClustersreturns a real connectable host. Your application connects with a regular Redis client (redis-py, ioredis, lettuce, go-redis). - Paid on LocalStack; free here. ElastiCache has always been LocalStack Pro-only.
- No account, no auth token, no paid tier. AGPL-3.0.
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 1Get 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 6379Real 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 1Valkey 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 1Real primary + replica nodes via Redis replication.
Serverless caches
aws --endpoint-url http://localhost:4566 elasticache create-serverless-cache \
--serverless-cache-name myserverless \
--engine redisIn 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
| Tool | Real Redis | Real Valkey | Replication groups | Serverless caches | Price |
|---|---|---|---|---|---|
| fakecloud | Yes (Docker) | Yes (Docker) | Yes | Yes | Free |
| LocalStack Pro | Yes | Yes | Yes | Partial | Paid |
| LocalStack Community | No | No | — | — | — (not available) |
Plain docker run redis | Yes | N/A | Manual | N/A | Free, but no ElastiCache API |
| Moto | Stubbed | Stubbed | Stubbed | Stubbed | Free |
Links
- Install:
curl -fsSL https://raw.githubusercontent.com/faiscadev/fakecloud/main/install.sh | bash - Repo: github.com/faiscadev/fakecloud
- Related: Local RDS for tests, Fake AWS server for tests