是否可以使用 Terraform 从快照创建 ElastiCache Clustered Redis 集群?
我没有看到类似于create-replication-group --node-group-configuration
cli 选项的 Terraform 选项。
错误:
Error creating Elasticache Replication Group: InvalidParameterCombination: Slots must be provided when restoring from snapshot ARNs with cluster mode enabled
地形:
resource "aws_elasticache_replication_group" "test-cluster" {
replication_group_id = "test-cluster"
replication_group_description = "test cluster"
node_type = "cache.r3.xlarge"
parameter_group_name = "default.redis3.2.cluster.on"
port = 6379
automatic_failover_enabled = true
subnet_group_name = "${var.subnet_group_name}"
security_group_ids = ["${var.security_group_id}"]
cluster_mode {
replicas_per_node_group = 3
num_node_groups = 3
}
snapshot_arns = ["${var.snapshot_arns}"]
}
答案1
刚刚收到来自 AWS 的答复,terraform 还无法实现,您需要使用 sdk 或 cli 或控制台来执行此操作,因为此功能是在 last2016 中添加的。 https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/Replication.CreatingReplGroup.NoExistingCluster.Cluster.html#Replication.CreatingReplGroup.NoExistingCluster.Cluster.API
aws elasticache create-replication-group ^
--replication-group-id rc-rg ^
--replication-group-description "Sharded replication group" ^
--engine redis ^
--engine-version 3.2.4 ^
--cache-parameter-group default.redis3.2.cluster.on ^
--snapshot-retention-limit 8 ^
--cache-node-type cache.m4.medium ^
--num-node-groups 2 ^
--node-group-configuration \
"ReplicaCount=1,Slots=0-8999,PrimaryAvailabilityZone='us-east-1c',ReplicaAvailabilityZones='us-east-1b'" \
"ReplicaCount=2,Slots=9000-16383,PrimaryAvailabilityZone='us-east-1a',ReplicaAvailabilityZones='us-east-1a','us-east-1c'"