Cfn
view release on metacpan or search on metacpan
t/cfn_json/ElastiCache.json view on Meta::CPAN
},
"Resources" : {
"CacheCluster" : {
"Type": "AWS::ElastiCache::CacheCluster",
"Properties": {
"CacheNodeType" : { "Ref" : "CacheNodeType" },
"CacheSecurityGroupNames" : [ { "Ref" : "CacheSecurityGroup" } ],
"Engine" : "memcached",
"NumCacheNodes" : { "Ref" : "NumberOfCacheNodes" }
}
},
"CacheSecurityGroup": {
"Type": "AWS::ElastiCache::SecurityGroup",
"Properties": {
"Description" : "Lock cache down to Web Server access only"
}
},
"CacheSecurityGroupIngress": {
"Type": "AWS::ElastiCache::SecurityGroupIngress",
"Properties": {
"CacheSecurityGroupName" : { "Ref" : "CacheSecurityGroup" },
"EC2SecurityGroupName" : { "Ref" : "WebServerSecurityGroup" }
}
},
"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" : [],
"gcc-c++" : [],
"php" : [],
"php-pear" : []
}
},
"files" : {
"/var/www/html/index.php" : {
"content" : { "Fn::Join" : ["", [
"<?php\n",
"echo '<h1>AWS CloudFormation sample application for Amazon ElastiCache</h1>';\n",
"\n",
"$server_endpoint = '", { "Fn::GetAtt" : [ "CacheCluster", "ConfigurationEndpoint.Address" ]}, "';\n",
"$server_port = ", { "Fn::GetAtt" : [ "CacheCluster", "ConfigurationEndpoint.Port" ]}, ";\n",
"\n",
"/**\n",
" * The following will initialize a Mecached client to utilize the Auto Discovery feature.\n",
" * \n",
" * By configuring the client with the Dynamic client mode with single endpoint, the\n",
" * client will periodically use the configuration endpoint to retrieve the current cache\n",
" * cluster configuration. This allows scaling the cache cluster up or down in nuber of nodes\n",
" * without requiring any changes to the PHP application. \n",
" */\n",
"\n",
"$dynamic_client = new Memcached();\n",
"$dynamic_client->setOption(Memcached::OPT_CLIENT_MODE, Memcached::DYNAMIC_CLIENT_MODE);\n",
"$dynamic_client->addServer($server_endpoint, $server_port);\n",
"\n",
"$tmp_object = new stdClass;\n",
"$tmp_object->str_attr = 'test';\n",
"$tmp_object->int_attr = 123;\n",
"\n",
"$dynamic_client->set('key', $tmp_object, 10) or die ('Failed to save data to the cache');\n",
"echo '<p>Store data in the cache (data will expire in 10 seconds)</p>';\n",
"\n",
"$get_result = $dynamic_client->get('key');\n",
"echo '<p>Data from the cache:<br/>';\n",
"\n",
"var_dump($get_result);\n",
"\n",
"echo '</p>';\n",
"?>\n"
]]},
"mode" : "000644",
"owner" : "apache",
"group" : "apache"
},
"/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",
"action=/opt/aws/bin/cfn-init -v ",
" --stack ", { "Ref" : "AWS::StackName" },
" --resource WebServerInstance ",
" --region ", { "Ref" : "AWS::Region" }, "\n",
"runas=root\n"
]]},
"mode" : "000400",
"owner" : "root",
"group" : "root"
}
},
"commands" : {
"00_install_emcached_client" : {
"command" : "pecl install https://s3.amazonaws.com/elasticache-downloads/ClusterClient/PHP/latest-64bit"
},
"01_enable_auto_discovery" : {
"command" : "echo 'extension=amazon-elasticache-cluster-client.so' > /etc/php.d/memcached.ini"
}
},
"services" : {
"sysvinit" : {
"httpd" : { "enabled" : "true", "ensureRunning" : "true" },
( run in 0.565 second using v1.01-cache-2.11-cpan-ceb78f64989 )