【问题标题】:AWS::ElastiCache::CacheCluster vs AWS::ElastiCache::ReplicationGroupAWS::ElastiCache::CacheCluster 与 AWS::ElastiCache::ReplicationGroup
【发布时间】:2018-05-06 00:00:54
【问题描述】:

我之前使用它通过 cloudformation 成功获取了一个 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"]
        }
    },

因为 AWS 最近升级了 Redis 以使用 AtRestEncryptionAuthTokenTransitEncryption 我尝试将它们包含在上述代码中,但根据 this 只有 AWS::ElastiCache::ReplicationGroup 接受这些参数。

如何使用AWS::ElastiCache::ReplicationGroup 创建单个 Redis 实例?

【问题讨论】:

    标签: amazon-web-services redis amazon-cloudformation


    【解决方案1】:

    根据文档, 您需要创建 ReplicationGroup 而不是 CacheCluster 并将 NumNodeGroups 设置为 1 并将 AutomaticFailoverEnabled 设置为 false。 这两个值都是默认值,因此您可以省略它们。 API Documentation 有更多关于单节点参数值的详细信息。

    【讨论】:

      【解决方案2】:

      您需要创建缓存集群上引用的复制组作为写入操作的主要复制组。 完整代码脚本:

          "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"
                  }
              }
          }
      

      【讨论】:

        猜你喜欢
        • 2016-11-04
        • 2019-03-22
        • 2020-06-20
        • 1970-01-01
        • 2019-09-12
        • 2017-06-20
        • 2020-04-19
        • 2018-03-28
        • 2018-01-15
        相关资源
        最近更新 更多