我之前使用过这个来通过cloudformation成功获取redis实例:
size_t
AS AWS最近升级了Redis以使用 "RedisCache": {
"Type": "AWS::ElastiCache::CacheCluster",
"Properties": {
"ClusterName": {
"Fn::Join": ["-", [ {
"Ref": "EnvType"
}, {
"Ref": "EnvVersion"
}
]]
},
"AutoMinorVersionUpgrade": "true",
"AZMode": "single-az",
"CacheNodeType": "cache.t2.medium",
"Engine": "redis",
"EngineVersion": "3.2.6",
"NumCacheNodes": "1",
"PreferredAvailabilityZone": "us-west-2a",
"PreferredMaintenanceWindow": "sun:04:30-sun:05:30",
"CacheSubnetGroupName": "redis-test-subnet-group",
"VpcSecurityGroupIds": ["sg-group1", "sg-group2"]
}
},
,AtRestEncryption
和AuthToken
我尝试将其包含在上述代码中,但仅按this TransitEncryption
接受这些参数。
如何使用AWS::ElastiCache::ReplicationGroup
创建单个Redis实例?
答案 0 :(得分:2)
从文档中,
您需要创建ReplicationGroup而不是CacheCluster,并将NumNodeGroups设置为1,将AutomaticFailoverEnabled设置为false
。
这两个值都是默认值,因此您可以省略它们。
API Documentation有关于单个节点的参数值的更多详细信息。
答案 1 :(得分:1)
您需要创建在缓存群集上引用的复制组,作为写操作的主要组。 完整的代码脚本:
"cache": {
"Type": "AWS::ElastiCache::CacheCluster",
"Properties": {
"CacheSubnetGroupName": {
"Ref": "cacheSubnetGroup"
},
"AutoMinorVersionUpgrade": "true",
"Engine": {
"Ref": "CacheEngine"
},
"CacheNodeType": {
"Ref": "CacheType"
},
"NumCacheNodes": {
"Ref": "CacheNodes"
},
"VpcSecurityGroupIds": [
{
"Fn::GetAtt": [
"cacheSecurityGroup",
"GroupId"
]
}
],
"PreferredAvailabilityZone": {
"Fn::Select": [
"0",
{
"Fn::GetAZs": {
"Ref": "AWS::Region"
}
}
]
}
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "9bae52e5-d091-42f2-9473-8a422efd6ced"
}
}
},
"cacheSecurityGroup": {
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "Elasticache Security Group",
"SecurityGroupIngress": [
{
"IpProtocol": "tcp",
"FromPort": {
"Ref": "CachePort"
},
"ToPort": {
"Ref": "CachePort"
},
"CidrIp": "0.0.0.0/0"
}
],
"VpcId": {
"Ref": "VPC"
}
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "4e5fb112-e80a-4c65-b68a-c136850d3933"
}
}
},
"cacheSubnetGroup": {
"Type": "AWS::ElastiCache::SubnetGroup",
"Properties": {
"Description": "Cache Subnet Group",
"SubnetIds": [
{
"Ref": "PublicSubnet1"
},
{
"Ref": "PublicSubnet2"
}
]
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "ac3d8db2-5aa2-4998-8e7d-acfeb9e21a88"
}
}
},
"cacheReplicationGroup": {
"Type": "AWS::ElastiCache::ReplicationGroup",
"Properties": {
"ReplicationGroupDescription": "Cache Replication Group",
"AutomaticFailoverEnabled": "true",
"NumCacheClusters": {
"Ref": "CacheReplicaNodes"
},
"PrimaryClusterId": {
"Ref": "cache"
}
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "3e76370e-4996-43b6-9373-22ef20a9b2ee"
}
}
}