Cluster
Provides an ElastiCache Cluster resource, which manages either a Memcached cluster, a single-node Redis instance, or a read replica in a Redis (Cluster Mode Enabled) replication group. For working with Redis (Cluster Mode Enabled) replication groups, see the aws.elasticache.ReplicationGroup resource.
Note: When you change an attribute, such as
num_cache_nodes, by default it is applied in the next maintenance window. Because of this, this provider may report a difference in its planning phase because the actual modification has not yet taken place. You can use theapply_immediatelyflag to instruct the service to apply the change immediately. Usingapply_immediatelycan result in a brief downtime as the server reboots. See the AWS Documentation on Modifying an ElastiCache Cache Cluster for ElastiCache for Memcached or ElastiCache for Redis for more information. Note: Any attribute changes that re-create the resource will be applied immediately, regardless of the value ofapply_immediately.
Example Usage
Memcached Cluster
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.elasticache.Cluster("example", {
clusterId: "cluster-example",
engine: "memcached",
nodeType: "cache.m4.large",
numCacheNodes: 2,
parameterGroupName: "default.memcached1.4",
port: 11211,
});import pulumi
import pulumi_aws as aws
example = aws.elasticache.Cluster("example",
cluster_id="cluster-example",
engine="memcached",
node_type="cache.m4.large",
num_cache_nodes=2,
parameter_group_name="default.memcached1.4",
port=11211)using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.ElastiCache.Cluster("example", new()
{
ClusterId = "cluster-example",
Engine = "memcached",
NodeType = "cache.m4.large",
NumCacheNodes = 2,
ParameterGroupName = "default.memcached1.4",
Port = 11211,
});
});package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/elasticache"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := elasticache.NewCluster(ctx, "example", &elasticache.ClusterArgs{
ClusterId: pulumi.String("cluster-example"),
Engine: pulumi.String("memcached"),
NodeType: pulumi.String("cache.m4.large"),
NumCacheNodes: pulumi.Int(2),
ParameterGroupName: pulumi.String("default.memcached1.4"),
Port: pulumi.Int(11211),
})
if err != nil {
return err
}
return nil
})
}package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.elasticache.Cluster;
import com.pulumi.aws.elasticache.ClusterArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new Cluster("example", ClusterArgs.builder()
.clusterId("cluster-example")
.engine("memcached")
.nodeType("cache.m4.large")
.numCacheNodes(2)
.parameterGroupName("default.memcached1.4")
.port(11211)
.build());
}
}resources:
example:
type: aws:elasticache:Cluster
properties:
clusterId: cluster-example
engine: memcached
nodeType: cache.m4.large
numCacheNodes: 2
parameterGroupName: default.memcached1.4
port: 11211Redis Instance
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.elasticache.Cluster("example", {
clusterId: "cluster-example",
engine: "redis",
nodeType: "cache.m4.large",
numCacheNodes: 1,
parameterGroupName: "default.redis3.2",
engineVersion: "3.2.10",
port: 6379,
});import pulumi
import pulumi_aws as aws
example = aws.elasticache.Cluster("example",
cluster_id="cluster-example",
engine="redis",
node_type="cache.m4.large",
num_cache_nodes=1,
parameter_group_name="default.redis3.2",
engine_version="3.2.10",
port=6379)using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.ElastiCache.Cluster("example", new()
{
ClusterId = "cluster-example",
Engine = "redis",
NodeType = "cache.m4.large",
NumCacheNodes = 1,
ParameterGroupName = "default.redis3.2",
EngineVersion = "3.2.10",
Port = 6379,
});
});package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/elasticache"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := elasticache.NewCluster(ctx, "example", &elasticache.ClusterArgs{
ClusterId: pulumi.String("cluster-example"),
Engine: pulumi.String("redis"),
NodeType: pulumi.String("cache.m4.large"),
NumCacheNodes: pulumi.Int(1),
ParameterGroupName: pulumi.String("default.redis3.2"),
EngineVersion: pulumi.String("3.2.10"),
Port: pulumi.Int(6379),
})
if err != nil {
return err
}
return nil
})
}package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.elasticache.Cluster;
import com.pulumi.aws.elasticache.ClusterArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new Cluster("example", ClusterArgs.builder()
.clusterId("cluster-example")
.engine("redis")
.nodeType("cache.m4.large")
.numCacheNodes(1)
.parameterGroupName("default.redis3.2")
.engineVersion("3.2.10")
.port(6379)
.build());
}
}resources:
example:
type: aws:elasticache:Cluster
properties:
clusterId: cluster-example
engine: redis
nodeType: cache.m4.large
numCacheNodes: 1
parameterGroupName: default.redis3.2
engineVersion: 3.2.10
port: 6379Redis Cluster Mode Disabled Read Replica Instance
These inherit their settings from the replication group.
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const replica = new aws.elasticache.Cluster("replica", {
clusterId: "cluster-example",
replicationGroupId: example.id,
});import pulumi
import pulumi_aws as aws
replica = aws.elasticache.Cluster("replica",
cluster_id="cluster-example",
replication_group_id=example["id"])using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var replica = new Aws.ElastiCache.Cluster("replica", new()
{
ClusterId = "cluster-example",
ReplicationGroupId = example.Id,
});
});package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/elasticache"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := elasticache.NewCluster(ctx, "replica", &elasticache.ClusterArgs{
ClusterId: pulumi.String("cluster-example"),
ReplicationGroupId: pulumi.Any(example.Id),
})
if err != nil {
return err
}
return nil
})
}package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.elasticache.Cluster;
import com.pulumi.aws.elasticache.ClusterArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var replica = new Cluster("replica", ClusterArgs.builder()
.clusterId("cluster-example")
.replicationGroupId(example.id())
.build());
}
}resources:
replica:
type: aws:elasticache:Cluster
properties:
clusterId: cluster-example
replicationGroupId: ${example.id}Redis Log Delivery configuration
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const test = new aws.elasticache.Cluster("test", {
clusterId: "mycluster",
engine: "redis",
nodeType: "cache.t3.micro",
numCacheNodes: 1,
port: 6379,
applyImmediately: true,
logDeliveryConfigurations: [
{
destination: example.name,
destinationType: "cloudwatch-logs",
logFormat: "text",
logType: "slow-log",
},
{
destination: exampleAwsKinesisFirehoseDeliveryStream.name,
destinationType: "kinesis-firehose",
logFormat: "json",
logType: "engine-log",
},
],
});import pulumi
import pulumi_aws as aws
test = aws.elasticache.Cluster("test",
cluster_id="mycluster",
engine="redis",
node_type="cache.t3.micro",
num_cache_nodes=1,
port=6379,
apply_immediately=True,
log_delivery_configurations=[
aws.elasticache.ClusterLogDeliveryConfigurationArgs(
destination=example["name"],
destination_type="cloudwatch-logs",
log_format="text",
log_type="slow-log",
),
aws.elasticache.ClusterLogDeliveryConfigurationArgs(
destination=example_aws_kinesis_firehose_delivery_stream["name"],
destination_type="kinesis-firehose",
log_format="json",
log_type="engine-log",
),
])using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var test = new Aws.ElastiCache.Cluster("test", new()
{
ClusterId = "mycluster",
Engine = "redis",
NodeType = "cache.t3.micro",
NumCacheNodes = 1,
Port = 6379,
ApplyImmediately = true,
LogDeliveryConfigurations = new[]
{
new Aws.ElastiCache.Inputs.ClusterLogDeliveryConfigurationArgs
{
Destination = example.Name,
DestinationType = "cloudwatch-logs",
LogFormat = "text",
LogType = "slow-log",
},
new Aws.ElastiCache.Inputs.ClusterLogDeliveryConfigurationArgs
{
Destination = exampleAwsKinesisFirehoseDeliveryStream.Name,
DestinationType = "kinesis-firehose",
LogFormat = "json",
LogType = "engine-log",
},
},
});
});package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/elasticache"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := elasticache.NewCluster(ctx, "test", &elasticache.ClusterArgs{
ClusterId: pulumi.String("mycluster"),
Engine: pulumi.String("redis"),
NodeType: pulumi.String("cache.t3.micro"),
NumCacheNodes: pulumi.Int(1),
Port: pulumi.Int(6379),
ApplyImmediately: pulumi.Bool(true),
LogDeliveryConfigurations: elasticache.ClusterLogDeliveryConfigurationArray{
&elasticache.ClusterLogDeliveryConfigurationArgs{
Destination: pulumi.Any(example.Name),
DestinationType: pulumi.String("cloudwatch-logs"),
LogFormat: pulumi.String("text"),
LogType: pulumi.String("slow-log"),
},
&elasticache.ClusterLogDeliveryConfigurationArgs{
Destination: pulumi.Any(exampleAwsKinesisFirehoseDeliveryStream.Name),
DestinationType: pulumi.String("kinesis-firehose"),
LogFormat: pulumi.String("json"),
LogType: pulumi.String("engine-log"),
},
},
})
if err != nil {
return err
}
return nil
})
}package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.elasticache.Cluster;
import com.pulumi.aws.elasticache.ClusterArgs;
import com.pulumi.aws.elasticache.inputs.ClusterLogDeliveryConfigurationArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var test = new Cluster("test", ClusterArgs.builder()
.clusterId("mycluster")
.engine("redis")
.nodeType("cache.t3.micro")
.numCacheNodes(1)
.port(6379)
.applyImmediately(true)
.logDeliveryConfigurations(
ClusterLogDeliveryConfigurationArgs.builder()
.destination(example.name())
.destinationType("cloudwatch-logs")
.logFormat("text")
.logType("slow-log")
.build(),
ClusterLogDeliveryConfigurationArgs.builder()
.destination(exampleAwsKinesisFirehoseDeliveryStream.name())
.destinationType("kinesis-firehose")
.logFormat("json")
.logType("engine-log")
.build())
.build());
}
}resources:
test:
type: aws:elasticache:Cluster
properties:
clusterId: mycluster
engine: redis
nodeType: cache.t3.micro
numCacheNodes: 1
port: 6379
applyImmediately: true
logDeliveryConfigurations:
- destination: ${example.name}
destinationType: cloudwatch-logs
logFormat: text
logType: slow-log
- destination: ${exampleAwsKinesisFirehoseDeliveryStream.name}
destinationType: kinesis-firehose
logFormat: json
logType: engine-logImport
Using pulumi import, import ElastiCache Clusters using the cluster_id. For example:
$ pulumi import aws:elasticache/cluster:Cluster my_cluster my_clusterProperties
Whether any database modifications are applied immediately, or during the next maintenance window. Default is false. See Amazon ElastiCache Documentation for more information..
Whether the nodes in this Memcached node group are created in a single Availability Zone or created across multiple Availability Zones in the cluster's region. Valid values for this parameter are single-az or cross-az, default is single-az. If you want to choose cross-az, num_cache_nodes must be greater than 1.
Version number of the cache engine to be used. If not set, defaults to the latest version. See Describe Cache Engine Versions in the AWS Documentation for supported versions. When engine is redis and the version is 7 or higher, the major and minor version should be set, e.g., 7.2. When the version is 6, the major and minor version can be set, e.g., 6.2, or the minor version can be unspecified which will use the latest version at creation time, e.g., 6.x. Otherwise, specify the full version desired, e.g., 5.0.6. The actual engine version used is returned in the attribute engine_version_actual, see Attribute Reference below. Cannot be provided with replication_group_id.
Specifies the destination and format of Redis SLOWLOG or Redis Engine Log. See the documentation on Amazon ElastiCache. See Log Delivery Configuration below for more details.
The IP versions for cache cluster connections. IPv6 is supported with Redis engine 6.2 onword or Memcached version 1.6.6 for all Nitro system instances. Valid values are ipv4, ipv6 or dual_stack.
The instance class used. See AWS documentation for information on supported node types for Redis and guidance on selecting node types for Redis. See AWS documentation for information on supported node types for Memcached and guidance on selecting node types for Memcached. For Memcached, changing this value will re-create the resource.
List of the Availability Zones in which cache nodes are created. If you are creating your cluster in an Amazon VPC you can only locate nodes in Availability Zones that are associated with the subnets in the selected subnet group. The number of Availability Zones listed must equal the value of num_cache_nodes. If you want all the nodes in the same Availability Zone, use availability_zone instead, or repeat the Availability Zone multiple times in the list. Default: System chosen Availability Zones. Detecting drift of existing node availability zone is not currently supported. Updating this argument by itself to migrate existing node availability zones is not currently supported and will show a perpetual difference.
Number of days for which ElastiCache will retain automatic cache cluster snapshots before deleting them. For example, if you set SnapshotRetentionLimit to 5, then a snapshot that was taken today will be retained for 5 days before being deleted. If the value of SnapshotRetentionLimit is set to zero (0), backups are turned off. Please note that setting a snapshot_retention_limit is not supported on cache.t1.micro cache nodes
Enable encryption in-transit. Supported only with Memcached versions 1.6.12 and later, running in a VPC. See the ElastiCache in-transit encryption documentation for more details.