Cfn

 view release on metacpan or  search on metacpan

t/cfn_json/ElastiCache_Redis.json  view on Meta::CPAN

        "Path": "/"
      }
    },

    "WebServerRolePolicy": {
      "Type": "AWS::IAM::Policy",
      "Properties": {
        "PolicyName" : "WebServerRole",
        "PolicyDocument" : {
          "Statement"  : [ {
            "Effect"   : "Allow",
            "Action"   : "elasticache:DescribeCacheClusters",
            "Resource" : "*"
          } ]
        },
        "Roles": [ { "Ref": "WebServerRole" } ]
      }
    },

    "WebServerInstanceProfile": {
      "Type": "AWS::IAM::InstanceProfile",
      "Properties": {
        "Path": "/",
        "Roles": [ { "Ref": "WebServerRole" } ]
      }
    },

    "WebServerSecurityGroup" : {
      "Type" : "AWS::EC2::SecurityGroup",
      "Properties" : {
        "GroupDescription" : "Enable HTTP and SSH access",
        "SecurityGroupIngress" : [
          {"IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : { "Ref" : "SSHLocation"} },
          {"IpProtocol" : "tcp", "FromPort" : "80", "ToPort" : "80", "CidrIp" : "0.0.0.0/0"}
        ]
      }      
    },  
      
    "WebServerInstance": {  
      "Type" : "AWS::EC2::Instance",
      "Metadata" : {
        "AWS::CloudFormation::Init" : {
          "config" : {
            "packages" : {
              "yum" : {
                "httpd"     : [],
                "php"       : [],
                "php-devel" : [],
                "gcc"       : [],
                "make"      : []
              }
            },

            "files" : {
              "/var/www/html/index.php" : {
                "content" : { "Fn::Join" : ["", [
                  "<?php\n",
                  "echo \"<h1>AWS CloudFormation sample application for Amazon ElastiCache Redis Cluster</h1>\";\n",
                  "\n",
                  "$cluster_config = json_decode(file_get_contents('/tmp/cacheclusterconfig'), true);\n",
                  "$endpoint = $cluster_config['CacheClusters'][0]['CacheNodes'][0]['Endpoint']['Address'];\n",
                  "$port = $cluster_config['CacheClusters'][0]['CacheNodes'][0]['Endpoint']['Port'];\n",
                  "\n",
                  "echo \"<p>Connecting to Redis Cache Cluster node '{$endpoint}' on port {$port}</p>\";\n",
                  "\n",
                  "$redis=new Redis();\n",
                  "$redis->connect($endpoint, $port);\n",
                  "$redis->set('testkey', 'Hello World!');\n",
                  "$return = $redis->get('testkey');\n",
                  "\n",
                  "echo \"<p>Retrieved value: $return</p>\";\n",
                  "?>\n"
                ]]},
                "mode"    : "000644",
                "owner"   : "apache",
                "group"   : "apache"
              },
              "/etc/cron.d/get_cluster_config" : {
                "content" : "*/5 * * * * root /usr/local/bin/get_cluster_config",
                "mode"    : "000644",
                "owner"   : "root",
                "group"   : "root"
              },
              "/usr/local/bin/get_cluster_config" : {
                "content" : { "Fn::Join" : ["", [
                  "#! /bin/bash\n",
                  "aws elasticache describe-cache-clusters ",
                  "         --cache-cluster-id ", {"Ref" : "RedisCluster"},
                  "         --show-cache-node-info --region ", { "Ref" : "AWS::Region" }, " > /tmp/cacheclusterconfig\n"
                ]]},
                "mode"    : "000755",
                "owner"   : "root",
                "group"   : "root"
              },
              "/usr/local/bin/install_phpredis" : {
                "content" : { "Fn::Join" : ["", [
                  "#! /bin/bash\n",
                  "cd /tmp\n",
                  "wget https://github.com/nicolasff/phpredis/zipball/master -O phpredis.zip\n",
                  "unzip phpredis.zip\n",
                  "cd nicolasff-phpredis-*\n",
                  "phpize\n",
                  "./configure\n",
                  "make && make install\n",
                  "touch /etc/php.d/redis.ini\n",
                  "echo extension=redis.so > /etc/php.d/redis.ini\n"
                ]]},
                "mode"    : "000755",
                "owner"   : "root",
                "group"   : "root"
              },
              "/etc/cfn/cfn-hup.conf" : {
                "content" : { "Fn::Join" : ["", [
                  "[main]\n",
                  "stack=", { "Ref" : "AWS::StackId" }, "\n",
                  "region=", { "Ref" : "AWS::Region" }, "\n"
                ]]},
                "mode"    : "000400",
                "owner"   : "root",
                "group"   : "root"
              },

              "/etc/cfn/hooks.d/cfn-auto-reloader.conf" : {
                "content": { "Fn::Join" : ["", [
                  "[cfn-auto-reloader-hook]\n",
                  "triggers=post.update\n",
                  "path=Resources.WebServerInstance.Metadata.AWS::CloudFormation::Init\n",



( run in 0.706 second using v1.01-cache-2.11-cpan-5a3173703d6 )