AWS Redis serverless
In this example, we create an ElastiCache Serverless Redis and connect to it from a function in the same VPC. The maximum storage and ECPUs per second cap how far the cache scales.
A serverless cache always uses TLS and has a generated password, like a provisioned Redis.
const client = new Cluster( [{ host: Resource.MyRedis.host, port: Resource.MyRedis.port }], { redisOptions: { tls: { checkServerIdentity: () => undefined }, username: Resource.MyRedis.username, password: Resource.MyRedis.password, }, });// The function only talks to Redis inside the VPC, so it needs no NAT gateway.// SST warns about it anyway, as the function can't reach the internet.const vpc = new sst.aws.Vpc("MyVpc");const redis = new sst.aws.Redis("MyRedis", { vpc, serverless: { storage: { maximum: "10 GB" }, ecpuPerSecond: { maximum: 5000 }, },});new sst.aws.Function("MyApp", { handler: "index.handler", url: true, vpc, link: [redis],});View the full example.