Replication Group
Provides an ElastiCache Replication Group resource. For working with a Memcached cluster or a single-node Redis instance (Cluster Mode Disabled), see the aws.elasticache.Cluster
resource.
Note: When you change an attribute, such as
engine_version
, by default the ElastiCache API applies it 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_immediately
flag to instruct the service to apply the change immediately. Usingapply_immediately
can result in a brief downtime as servers reboots. See the AWS Documentation on Modifying an ElastiCache Cache Cluster for more information. Note: Any attribute changes that re-create the resource will be applied immediately, regardless of the value ofapply_immediately
. Note: Be aware of the terminology collision around "cluster" foraws.elasticache.ReplicationGroup
. For example, it is possible to create a "Cluster Mode Disabled Redis Cluster". With "Cluster Mode Enabled", the data will be stored in shards (called "node groups"). See Redis Cluster Configuration for a diagram of the differences. To enable cluster mode, use a parameter group that has cluster mode enabled. The default parameter groups provided by AWS end with ".cluster.on", for exampledefault.redis6.x.cluster.on
.
Example Usage
Redis Cluster Mode Disabled
To create a single shard primary with single read replica:
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.elasticache.ReplicationGroup;
import com.pulumi.aws.elasticache.ReplicationGroupArgs;
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 ReplicationGroup("example", ReplicationGroupArgs.builder()
.automaticFailoverEnabled(true)
.description("example description")
.nodeType("cache.m4.large")
.numCacheClusters(2)
.parameterGroupName("default.redis3.2")
.port(6379)
.preferredCacheClusterAzs(
"us-west-2a",
"us-west-2b")
.build());
}
}
Redis Cluster Mode Enabled
To create two shards with a primary and a single read replica each:
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.elasticache.ReplicationGroup;
import com.pulumi.aws.elasticache.ReplicationGroupArgs;
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 baz = new ReplicationGroup("baz", ReplicationGroupArgs.builder()
.automaticFailoverEnabled(true)
.description("example description")
.nodeType("cache.t2.small")
.numNodeGroups(2)
.parameterGroupName("default.redis3.2.cluster.on")
.port(6379)
.replicasPerNodeGroup(1)
.build());
}
}
Redis Log Delivery configuration
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.elasticache.ReplicationGroup;
import com.pulumi.aws.elasticache.ReplicationGroupArgs;
import com.pulumi.aws.elasticache.inputs.ReplicationGroupLogDeliveryConfigurationArgs;
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 ReplicationGroup("test", ReplicationGroupArgs.builder()
.description("test description")
.nodeType("cache.t3.small")
.port(6379)
.applyImmediately(true)
.autoMinorVersionUpgrade(false)
.maintenanceWindow("tue:06:30-tue:07:30")
.snapshotWindow("01:00-02:00")
.logDeliveryConfigurations(
ReplicationGroupLogDeliveryConfigurationArgs.builder()
.destination(aws_cloudwatch_log_group.example().name())
.destinationType("cloudwatch-logs")
.logFormat("text")
.logType("slow-log")
.build(),
ReplicationGroupLogDeliveryConfigurationArgs.builder()
.destination(aws_kinesis_firehose_delivery_stream.example().name())
.destinationType("kinesis-firehose")
.logFormat("json")
.logType("engine-log")
.build())
.build());
}
}
Creating a secondary replication group for a global replication group
A Global Replication Group can have one one two secondary Replication Groups in different regions. These are added to an existing Global Replication Group.
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.elasticache.ReplicationGroup;
import com.pulumi.aws.elasticache.ReplicationGroupArgs;
import com.pulumi.aws.elasticache.GlobalReplicationGroup;
import com.pulumi.aws.elasticache.GlobalReplicationGroupArgs;
import com.pulumi.resources.CustomResourceOptions;
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 primary = new ReplicationGroup("primary", ReplicationGroupArgs.builder()
.description("primary replication group")
.engine("redis")
.engineVersion("5.0.6")
.nodeType("cache.m5.large")
.numCacheClusters(1)
.build(), CustomResourceOptions.builder()
.provider(aws.other_region())
.build());
var example = new GlobalReplicationGroup("example", GlobalReplicationGroupArgs.builder()
.globalReplicationGroupIdSuffix("example")
.primaryReplicationGroupId(primary.id())
.build(), CustomResourceOptions.builder()
.provider(aws.other_region())
.build());
var secondary = new ReplicationGroup("secondary", ReplicationGroupArgs.builder()
.description("secondary replication group")
.globalReplicationGroupId(example.globalReplicationGroupId())
.numCacheClusters(1)
.build());
}
}
Import
ElastiCache Replication Groups can be imported using the replication_group_id
, e.g.,
$ pulumi import aws:elasticache/replicationGroup:ReplicationGroup my_replication_group replication-group-1
Properties
Specifies whether any modifications are applied immediately, or during the next maintenance window. Default is false
.
Whether to enable encryption at rest.
Specifies whether a read-only replica will be automatically promoted to read/write primary if the existing primary fails. If enabled, num_cache_clusters
must be greater than 1. Must be enabled for Redis (cluster mode enabled) replication groups. Defaults to false
.
Specifies whether minor version engine upgrades will be applied automatically to the underlying Cache Cluster instances during the maintenance window. Only supported for engine type "redis"
and if the engine version is 6 or higher. Defaults to true
.
List of EC2 availability zones in which the replication group's cache clusters will be created. The order of the availability zones in the list is not considered.
Indicates if cluster mode is enabled.
Create a native Redis cluster. automatic_failover_enabled
must be set to true. Cluster Mode documented below. Only 1 cluster_mode
block is allowed. Note that configuring this block does not enable cluster mode, i.e., data sharding, this requires using a parameter group that has the parameter cluster-enabled
set to true.
Address of the replication group configuration endpoint when cluster mode is enabled.
Enables data tiering. Data tiering is only supported for replication groups using the r6gd node type. This parameter must be set to true
when using r6gd nodes.
User-created description for the replication group. Must not be empty.
Version number of the cache engine to be used for the cache clusters in this replication group. If the version is 6 or higher, 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 Attributes Reference below.
Because ElastiCache pulls the latest minor or patch for a version, this attribute returns the running version of the cache engine.
The name of your final node group (shard) snapshot. ElastiCache creates the snapshot from the primary node in the cluster. If omitted, no final snapshot will be made.
The ID of the global replication group to which this replication group should belong. If this parameter is specified, the replication group is added to the specified global replication group as a secondary replication group; otherwise, the replication group is not part of any global replication group. If global_replication_group_id
is set, the num_node_groups
parameter (or the num_node_groups
parameter of the deprecated cluster_mode
block) cannot be set.
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.
Specifies the weekly time range for when maintenance on the cache cluster is performed. The format is ddd:hh24:mi-ddd:hh24:mi
(24H Clock UTC). The minimum maintenance window is a 60 minute period. Example: sun:05:00-sun:09:00
Identifiers of all the nodes that are part of this replication group.
Specifies whether to enable Multi-AZ Support for the replication group. If true
, automatic_failover_enabled
must also be enabled. Defaults to false
.
Instance class to be used. See AWS documentation for information on supported node types and guidance on selecting node types. Required unless global_replication_group_id
is set. Cannot be set if global_replication_group_id
is set.
ARN of an SNS topic to send ElastiCache notifications to. Example: arn:aws:sns:us-east-1:012345678999:my_sns_topic
Number of cache clusters (primary and replicas) this replication group will have. If Multi-AZ is enabled, the value of this parameter must be at least 2. Updates will occur before other modifications. Conflicts with num_cache_clusters
, num_node_groups
, or the deprecated cluster_mode
. Defaults to 1
.
Number of cache clusters (primary and replicas) this replication group will have. If Multi-AZ is enabled, the value of this parameter must be at least 2. Updates will occur before other modifications. Conflicts with num_node_groups
, the deprecatednumber_cache_clusters
, or the deprecated cluster_mode
. Defaults to 1
.
Number of node groups (shards) for this Redis replication group. Changing this number will trigger a resizing operation before other settings modifications.
Name of the parameter group to associate with this replication group. If this argument is omitted, the default cache parameter group for the specified engine is used. To enable "cluster mode", i.e., data sharding, use a parameter group that has the parameter cluster-enabled
set to true.
List of EC2 availability zones in which the replication group's cache clusters will be created. The order of the availability zones in the list is considered. The first item in the list will be the primary node. Ignored when updating.
(Redis only) Address of the endpoint for the primary node in the replication group, if the cluster mode is disabled.
(Redis only) Address of the endpoint for the reader node in the replication group, if the cluster mode is disabled.
Number of replica nodes in each node group. Changing this number will trigger a resizing operation before other settings modifications. Valid values are 0 to 5.
User-created description for the replication group. Must not be empty. The following arguments are optional:
Replication group identifier. This parameter is stored as a lowercase string.
One or more Amazon VPC security groups associated with this replication group. Use this parameter only when you are creating a replication group in an Amazon Virtual Private Cloud
List of cache security group names to associate with this replication group.
List of ARNs that identify Redis RDB snapshot files stored in Amazon S3. The names object names cannot contain any commas.
Name of a snapshot from which to restore data into the new node group. Changing the snapshot_name
forces a new resource.
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 snapshot_retention_limit
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
Daily time range (in UTC) during which ElastiCache will begin taking a daily snapshot of your cache cluster. The minimum snapshot window is a 60 minute period. Example: 05:00-09:00
Name of the cache subnet group to be used for the replication group.
Map of tags to assign to the resource. Adding tags to this resource will add or overwrite any existing tags on the clusters in the replication group and not to the group itself. If configured with a provider default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Whether to enable encryption in transit.
User Group ID to associate with the replication group. Only a maximum of one (1) user group ID is valid. NOTE: This argument is a set because the AWS specification allows for multiple IDs. However, in practice, AWS only allows a maximum size of one.