[英]Cloud Formation template for AWS::ElastiCache::GlobalReplicationGroup
想要使用 CF 創建 Redis 全局數據存儲,遵循指南https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-elasticache-globalreplicationgroup.79D698FDC7A8D5FC6C
但沒有運氣,我可以創建 Redis 集群但不能創建全局數據存儲:我的代碼:
AWSTemplateFormatVersion: '2010-09-09'
Description: redis deployment.
Parameters:
RedisSubnets:
Description: PRIVATE Subnets for subnet group
Type: "List<String>"
VpcId:
Description: The VPC that the Postgres DB is deployed to
Type: AWS::EC2::VPC::Id
NodeType:
Description: Node type for redis service
Type: String
ClusterName:
Description: Cluster name for redis service
Type: String
AvailabilityZones:
Description: Availability zones for redis service
Type: "List<String>"
CidrIp1:
Description: Ingress CIDr
Type: String
Default: 0.0.0.0/0
CidrIp2:
Description: Ingress CIDr
Type: String
Default: 0.0.0.0/0
Resources:
RedisSubnetGroup:
Type: AWS::ElastiCache::SubnetGroup
Properties:
CacheSubnetGroupName: !Sub ${AWS::StackName}-subnetgroup
Description: "Subnet group for redis server"
SubnetIds: !Ref RedisSubnets
RedisSecurityGroup:
Type: "AWS::EC2::SecurityGroup"
Properties:
VpcId: !Ref VpcId
GroupDescription: "A component security group allowing access only to redis"
ElasticacheComponentSecurityGroup:
Type: "AWS::EC2::SecurityGroup"
Properties:
GroupDescription: "Elasticache security group"
SecurityGroupIngress:
-
IpProtocol: "tcp"
FromPort: 6379
ToPort: 6379
CidrIp: !Ref CidrIp1
-
IpProtocol: "tcp"
FromPort: 6379
ToPort: 6379
CidrIp: !Ref CidrIp2
VpcId: !Ref VpcId
RedisService:
Type: AWS::ElastiCache::ReplicationGroup
Properties:
AutoMinorVersionUpgrade: false
CacheNodeType: cache.r5.large
CacheParameterGroupName: default.redis6.x
CacheSubnetGroupName: !Ref RedisSubnetGroup
ReplicationGroupId: !Ref ClusterName
SecurityGroupIds:
- !Ref ElasticacheComponentSecurityGroup
Engine: "Redis"
EngineVersion: "6.2"
NumNodeGroups: 1
AutomaticFailoverEnabled: false
ReplicationGroupDescription: Sample Redis group for scaling
Port: 6379
globalreplication:
Type: AWS::ElastiCache::GlobalReplicationGroup
Properties:
AutomaticFailoverEnabled: false
GlobalReplicationGroupDescription: description example
GlobalReplicationGroupIdSuffix: test
Members:
- ReplicationGroupId: !Ref ClusterName
ReplicationGroupRegion: eu-west-1
Role: primary
RegionalConfigurations:
- ReplicationGroupId: test-redis-eu-west-2
ReplicationGroupRegion: eu-west-2
Outputs:
redisUrl:
Description: URL for newly created redis service
Value: !Ref RedisService
如果有人可以提供幫助,我會收到此錯誤:
資源全局復制的屬性驗證失敗,消息為:#/Members/0/Role:#: 2 個子模式中只有 1 個匹配 #/Members/0/Role: 關鍵字 [enum] 的驗證約束失敗
globalreplication:
Type: AWS::ElastiCache::GlobalReplicationGroup
DependsOn: RedisService
Properties:
AutomaticFailoverEnabled: false
GlobalReplicationGroupDescription: description example
GlobalReplicationGroupIdSuffix: test
Members:
- ReplicationGroupId: !Ref ClusterName
ReplicationGroupRegion: eu-west-1
Role: PRIMARY
這將添加主節點並創建新的全局數據存儲,然后需要在新創建的全局數據存儲中添加輔助節點,您可以在此處查看前綴https://docs.aws.amazon.com/AmazonElastiCache/latest/ red-ug/Redis-Global-Datastores-CLI.html :
RedisService:
Type: AWS::ElastiCache::ReplicationGroup
Properties:
CacheSubnetGroupName: !Ref RedisSubnetGroup
ReplicationGroupId: !Ref ClusterName
SecurityGroupIds:
- !Ref ElasticacheComponentSecurityGroup
GlobalReplicationGroupId: gxeiz-test
ReplicationGroupDescription: Sample Redis group for scaling
Port: 6379
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.