title: AWS cloudformation : how to properly create a redis cache cluster
body: <p>I want to create an elasticache instance using redis.</p>
  
  <p>I think that I should use it "cluster mode disabled" because everything will fit into one server.
  In order to not have a SPOF, I want to create a read replica that will be promoted by AWS in case of a failure of the master.
  If possible, it would be great to balance the read only operations between master and slave, but it is not mandatory.</p>
  
  <p>I created a functioning master/read-replica using the aws console then used cloudformer to create the cloudformation json conf. Cloudformer has created me two unlinked  <code>AWS::ElastiCache::CacheCluster</code>, but by reading the doc. I don't understand how to link them... For now I have this configuration : </p>
  
  <pre><code>{
      "cachehubcache001": {
        "Type": "AWS::ElastiCache::CacheCluster",
        "Properties": {
          "AutoMinorVersionUpgrade": "true",
          "AZMode": "single-az",
          "CacheNodeType": "cache.t2.small",
          "Engine": "redis",
          "EngineVersion": "3.2.4",
          "NumCacheNodes": "1",
          "PreferredAvailabilityZone": { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "Az1B"]},
          "PreferredMaintenanceWindow": "sun:04:00-sun:05:00",
          "CacheSubnetGroupName": {
            "Ref": "cachesubnethubprivatecachesubnetgroup"
          },
          "VpcSecurityGroupIds": [
            {
              "Fn::GetAtt": [
                "sgiHubCacheSG",
                "GroupId"
              ]
            }
          ]
        }
      },
      "cachehubcache002": {
        "Type": "AWS::ElastiCache::CacheCluster",
        "Properties": {
          "AutoMinorVersionUpgrade": "true",
          "AZMode": "single-az",
          "CacheNodeType": "cache.t2.small",
          "Engine": "redis",
          "EngineVersion": "3.2.4",
          "NumCacheNodes": "1",
          "PreferredAvailabilityZone": { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "Az1A"]},
          "PreferredMaintenanceWindow": "sun:02:00-sun:03:00",
          "CacheSubnetGroupName": {
            "Ref": "cachesubnethubprivatecachesubnetgroup"
          },
          "VpcSecurityGroupIds": [
            {
              "Fn::GetAtt": [
                "sgiHubCacheSG",
                "GroupId"
              ]
            }
          ]
        }
      },
  }
  </code></pre>
  
  <p>I know that it is wrong, but I can't figure out how to create a correct replica. I can't understand the AWS doc, for a start I can't figure out wich Type I should use between : </p>
  
  <ul>
  <li><a href="http://docs.aws.amazon.com/fr_fr/AWSCloudFormation/latest/UserGuide/aws-resource-elasticache-replicationgroup.html" rel="noreferrer">http://docs.aws.amazon.com/fr_fr/AWSCloudFormation/latest/UserGuide/aws-resource-elasticache-replicationgroup.html</a></li>
  <li><a href="http://docs.aws.amazon.com/fr_fr/AWSCloudFormation/latest/UserGuide/aws-properties-elasticache-cache-cluster.html" rel="noreferrer">http://docs.aws.amazon.com/fr_fr/AWSCloudFormation/latest/UserGuide/aws-properties-elasticache-cache-cluster.html</a></li>
  </ul>
  
  <p>Since cloudformer created <code>AWS::ElastiCache::CacheCluster</code> I'll go with it, but I've got the feeling that it should have created only one resource, and used the <code>NumCacheNodes</code> parameter in order to create two resources. </p>
  
  <p>redis can't use :</p>
  
  <ul>
  <li><code>NumCacheNodes</code></li>
  <li><code>AZMode</code> and <code>PreferredAvailabilityZones</code> </li>
  </ul>
  
  <p>so I don't know how to make this solution multi-AZ...</p>