I am trying to create this in a stack that also creates eks and a vpc and if it is possible use the same vpc for both resources (I think redis needs to make its own subnets in it and I think that is fine):
const userRedisSlowLogName = `user-redis-slow_log-${stack}`;
const userRedisEngineLogName = `user-redis-engine_log-${stack}`;
export const userSlowLog = new aws.cloudwatch.LogGroup(userRedisSlowLogName, {
name: userRedisSlowLogName,
tags: additionalDefaultTags,
});
export const userRedisEngineLog = new aws.cloudwatch.LogGroup(userRedisEngineLogName, {
name: userRedisEngineLogName,
tags: additionalDefaultTags,
});
const redisName = `user-redis-${stack}`;
const redisSubnetGroupName = `user-redis-subnet-group-${stack}`;
const redisEngineVersion = '7.1'; // Use the latest stable version
const redisMaintenanceWindow = 'sun:03:00-sun:04:00'; // Set to off-peak hours
const redisNodeType = 'cache.r6g.large'; // Use a memory-optimized instance type
const redisNumCacheClusters = 3; // Increase number of nodes for high availability and read scalability
export const userRedisSubnetGroup = new aws.elasticache.SubnetGroup(redisSubnetGroupName, {
description: 'Managed by Pulumi',
name: redisSubnetGroupName,
tags: additionalDefaultTags,
subnetIds: eksVpc.privateSubnetIds,
});
export const redisSecurityGroup = new aws.ec2.SecurityGroup('redisSecurityGroup', {
description: 'Redis Security Group',
name: 'redisSecurityGroup',
tags: additionalDefaultTags,
});
export const userRedis = new aws.elasticache.ReplicationGroup(redisName, {
autoMinorVersionUpgrade: true,
automaticFailoverEnabled: true,
engineVersion: redisEngineVersion,
maintenanceWindow: redisMaintenanceWindow,
multiAzEnabled: false,
networkType: 'ipv4',
nodeType: redisNodeType,
numCacheClusters: redisNumCacheClusters,
parameterGroupName: 'default.redis7.cluster.on', // Use the parameter group that matches the engine version
port: 6379,
replicationGroupId: redisName,
securityGroupIds: [redisSecurityGroup.id],
snapshotWindow: '07:00-08:00',
tags: additionalDefaultTags,
description: 'Managed by Pulumi',
},
{
dependsOn: [
eksCluster,
cniPolicyAttachment,
ec2ContainerpolicyAttachment,
nextgenNodePolicyAttachment,
workerNodepolicyAttachment,
],
protect: false,
});