The Redis module provides ElastiCacheRedis for private single-node Redis in an AWSX VPC and UpstashRedis for managed global Redis with its password stored in AWS Secrets Manager.
Use these components for caches, session stores, queues, and other low-latency stateful services when you want a consistent Redis backend choice across stacks.
import { ElastiCacheRedis, Vpc } from '@studion/infra-code-blocks';
const vpc = new Vpc('app');
const cache = new ElastiCacheRedis('app-cache', {
vpc: vpc.vpc,
});
export const clusterId = cache.cluster.id;
export const clusterAddress = cache.cluster.cacheNodes.apply(
nodes => nodes[0].address,
);import { UpstashRedis } from '@studion/infra-code-blocks';
const redis = new UpstashRedis('edge-cache', {
dbName: 'edge-cache',
primaryRegion: 'eu-west-1',
});
export const databaseId = redis.instance.databaseId;
export const passwordSecretArn = redis.password.secret.arn;ElastiCacheRedismerges caller input with defaults ofengineVersion: '7.1',nodeType: 'cache.t4g.micro', andparameterGroupName: 'default.redis7'.ElastiCacheRedisalways creates a VPC-bound, single-node Redisaws.elasticache.ClusterwithnumCacheNodes: 1and port6379; it does not create a replication group.- The ElastiCache subnet group is built from
vpc.isolatedSubnetIds, and the Redis security group allows TCP/6379 ingress from the VPC CIDR block. ElastiCacheRedisdoes not configure transit encryption, auth tokens, automatic failover, replication groups, backups, or multi-AZ failover.UpstashRedismerges internal defaults ofregion: 'global'andprimaryRegion: 'us-east-1'before creating the database.UpstashRedisalways setseviction: trueandtls: trueon the Upstash database.UpstashRediscreates a nestedPasswordcomponent frominstance.password, so the Upstash password is copied into AWS Secrets Manager.
Signature
class ElastiCacheRedis extends pulumi.ComponentResource {
constructor(
name: string,
args: ElastiCacheRedis.Args,
opts?: pulumi.ComponentResourceOptions,
);
}Constructor Parameters
| Parameter | Description |
|---|---|
name*string |
Logical Pulumi component name. |
args*ElastiCacheRedis.Args |
Direct ElastiCache Redis configuration object. |
optspulumi.ComponentResourceOptions |
Optional Pulumi component resource options. |
Configuration Options
Direct constructor input: args: ElastiCacheRedis.Args
| Property | Description |
|---|---|
vpc*pulumi.Input<awsx.ec2.Vpc> |
VPC used for isolated subnets, VPC CIDR ingress, and Redis networking. |
engineVersionstring |
Redis engine version passed to the ElastiCache cluster. Default: '7.1'. |
nodeTypestring |
ElastiCache node type for the single Redis node. Default: 'cache.t4g.micro'. |
parameterGroupNamepulumi.Input<string> |
ElastiCache parameter group associated with the cluster. Default: 'default.redis7'. |
tagspulumi.Input<{ [key: string]: pulumi.Input<string> }> |
Extra tags merged into the ElastiCache cluster tags. |
Outputs
| Property | Description |
|---|---|
namestring |
Component name passed to the constructor. |
vpcpulumi.Output<awsx.ec2.Vpc> |
Resolved VPC captured from constructor input for downstream networking composition. |
clusteraws.elasticache.Cluster |
Primary Redis cluster resource. |
securityGroupaws.ec2.SecurityGroup |
Security group that allows Redis access from the VPC CIDR block. |
subnetGroupaws.elasticache.SubnetGroup |
Subnet group built from the VPC isolated subnets. |
Signature
class UpstashRedis extends pulumi.ComponentResource {
constructor(
name: string,
args: UpstashRedis.Args,
opts?: pulumi.ComponentResourceOptions,
);
}Constructor Parameters
| Parameter | Description |
|---|---|
name*string |
Logical Pulumi component name. |
args*UpstashRedis.Args |
Direct Upstash Redis configuration object. |
optspulumi.ComponentResourceOptions |
Optional Pulumi component resource options. |
Configuration Options
Direct constructor input: args: UpstashRedis.Args
| Property | Description |
|---|---|
dbName*pulumi.Input<string> |
Database name passed to upstash.RedisDatabase. |
primaryRegionpulumi.Input<'us-east-1' | 'us-west-1' | 'us-west-2' | 'eu-central-1' | 'eu-west-1' | 'sa-east-1' | 'ap-southeast-1' | 'ap-southeast-2'> |
Upstash primary region for the global Redis database. Default: 'us-east-1'. |
Outputs
| Property | Description |
|---|---|
namestring |
Component name passed to the constructor. |
instanceupstash.RedisDatabase |
Primary Upstash Redis database resource with TLS and eviction enabled. |
passwordPassword |
Nested password component that stores instance.password in AWS Secrets Manager for reuse. |