CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-pulumi--aws

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources with infrastructure-as-code.

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

elasticache.mddocs/database/

ElastiCache - In-Memory Cache

Amazon ElastiCache provides managed Redis and Memcached for caching and real-time applications.

Common Tasks

Create a Redis cache cluster

const redis = new aws.elasticache.Cluster("cache", {
    engine: "redis",
    nodeType: "cache.t3.micro",
    numCacheNodes: 1,
    port: 6379,
});

Create a Redis replication group with failover

const redisCluster = new aws.elasticache.ReplicationGroup("redis", {
    description: "Redis cluster with automatic failover",
    engine: "redis",
    nodeType: "cache.r6g.large",
    numCacheClusters: 3,
    automaticFailoverEnabled: true,
    multiAzEnabled: true,
});

Create a Memcached cluster

const memcached = new aws.elasticache.Cluster("memcached", {
    engine: "memcached",
    nodeType: "cache.t3.micro",
    numCacheNodes: 2,
    port: 11211,
});

Core Resources

Cluster

Create ElastiCache clusters for Memcached or single-node Redis.

class Cluster extends pulumi.CustomResource {
    constructor(name: string, args: ClusterArgs, opts?: pulumi.CustomResourceOptions);

    readonly arn: pulumi.Output<string>;
    readonly cacheNodes: pulumi.Output<ClusterCacheNode[]>;
}

interface ClusterArgs {
    clusterId?: pulumi.Input<string>;
    engine: pulumi.Input<"memcached" | "redis">;
    nodeType: pulumi.Input<string>;
    numCacheNodes?: pulumi.Input<number>;
    parameterGroupName?: pulumi.Input<string>;
    port?: pulumi.Input<number>;
    subnetGroupName?: pulumi.Input<string>;
    securityGroupIds?: pulumi.Input<pulumi.Input<string>[]>;
}

Example: Redis cluster in VPC

import * as aws from "@pulumi/aws";

const subnetGroup = new aws.elasticache.SubnetGroup("cache-subnet", {
    subnetIds: [privateSubnet1.id, privateSubnet2.id],
});

const redis = new aws.elasticache.Cluster("redis-cache", {
    engine: "redis",
    nodeType: "cache.t3.micro",
    numCacheNodes: 1,
    port: 6379,
    subnetGroupName: subnetGroup.name,
    securityGroupIds: [cacheSecurityGroup.id],
    tags: { Environment: "production" },
});

export const redisEndpoint = redis.cacheNodes[0].address;

ReplicationGroup

Create Redis replication groups with automatic failover and multi-AZ support.

class ReplicationGroup extends pulumi.CustomResource {
    constructor(name: string, args: ReplicationGroupArgs, opts?: pulumi.CustomResourceOptions);
}

interface ReplicationGroupArgs {
    replicationGroupId?: pulumi.Input<string>;
    description: pulumi.Input<string>;
    engine?: pulumi.Input<"redis">;
    nodeType?: pulumi.Input<string>;
    numCacheClusters?: pulumi.Input<number>;
    automaticFailoverEnabled?: pulumi.Input<boolean>;
    multiAzEnabled?: pulumi.Input<boolean>;
}

Example: Production Redis with failover

const redisReplication = new aws.elasticache.ReplicationGroup("redis-ha", {
    replicationGroupId: "redis-ha-cluster",
    description: "High availability Redis cluster",
    engine: "redis",
    engineVersion: "7.0",
    nodeType: "cache.r6g.large",
    numCacheClusters: 3,
    automaticFailoverEnabled: true,
    multiAzEnabled: true,
    subnetGroupName: subnetGroup.name,
    securityGroupIds: [cacheSecurityGroup.id],
    atRestEncryptionEnabled: true,
    transitEncryptionEnabled: true,
    tags: { Environment: "production" },
});

export const primaryEndpoint = redisReplication.primaryEndpointAddress;
export const readerEndpoint = redisReplication.readerEndpointAddress;

Related Services

  • VPC - Configure network isolation for cache clusters
  • Lambda - Access cache from serverless functions
  • RDS - Use ElastiCache to reduce database load
  • CloudWatch - Monitor cache metrics and performance
  • Secrets Manager - Store Redis authentication tokens securely

For complete ElastiCache API, see All Services.

Install with Tessl CLI

npx tessl i tessl/npm-pulumi--aws

docs

index.md

quickstart.md

README.md

tile.json