Permalink
Browse files

Single-node membase CloudFormation template

  • Loading branch information...
1 parent 2dbd98a commit f2cc435bdbf9b020c43ecfe0a2b1002e53245cca @steveyen steveyen committed Jul 15, 2011
Showing with 134 additions and 0 deletions.
  1. +134 −0 membase.template
View
@@ -0,0 +1,134 @@
+{
+ "AWSTemplateFormatVersion" : "2010-09-09",
+ "Parameters" : {
+ "KeyName" : {
+ "Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance",
+ "Type" : "String"
+ },
+ "MembasePackageURL" : {
+ "NoEcho": "true",
+ "Description" : "URL to Membase software package",
+ "Type" : "String",
+ "Default" : "http://packages.couchbase.com/releases/1.7.0/membase-server-community_x86_1.7.0.rpm"
+ },
+ "RESTPassword" : {
+ "NoEcho": "true",
+ "Description" : "Password for REST Administrator API and web-console interface",
+ "Type" : "String"
+ },
+ "MaxRAMPerServer" : {
+ "Description" : "Maximum RAM quota in MB for each node in the cluster",
+ "Type" : "Number",
+ "Default" : "500",
+ "MinValue" : "200"
+ },
+ "MaxRAMForDefaultBucket" : {
+ "Description" : "Maximum RAM quota in MB for the default bucket. Should be <= MaxRAMPerServer",
+ "Type" : "Number",
+ "Default" : "500",
+ "MinValue" : "0"
+ },
+ "ExistingClusterHostPort" : {
+ "Description" : "Optional 'host:port', if you want to join new node(s) to an existing cluster node",
+ "Type" : "String",
+ "Default" : "host:port"
+ }
+ },
+
+ "Mappings" : {
+ "RegionMap" : {
+ "us-east-1" : {"AMI" : "ami-8c1fece5"},
+ "us-west-1" : {"AMI" : "ami-3bc9997e"},
+ "eu-west-1" : {"AMI" : "ami-47cefa33"},
+ "ap-southeast-1" : {"AMI" : "ami-6af08e38"},
+ "ap-northeast-1" : {"AMI" : "ami-300ca731"}
+ }
+ },
+
+ "Resources" : {
+ "Ec2Instance" : {
+ "Type" : "AWS::EC2::Instance",
+ "Properties" : {
+ "KeyName" : { "Ref" : "KeyName" },
+ "SecurityGroups" : [ { "Ref" : "InstanceSecurityGroup" } ],
+ "ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]},
+ "UserData" : { "Fn::Base64" : { "Fn::Join" : ["",[
+ "#!/bin/bash -ex","\n",
+ "yum -y install openssl098e","\n",
+ "wget ", { "Ref" : "MembasePackageURL" },"\n",
+ "rpm -i membase-server-community*.rpm","\n",
+ "sleep 5","\n",
+ "/opt/membase/bin/membase cluster-init -c 127.0.0.1",
+ " --cluster-init-username=Administrator",
+ " --cluster-init-password=", { "Ref" : "RESTPassword" },
+ " --cluster-init-ramsize=", { "Ref" : "MaxRAMPerServer" },"\n",
+ "curl -X PUT -H 'Content-Type:' --data-binary '{\"Status\" : \"SUCCESS\",",
+ "\"Reason\" : \"Membase node is ready\",",
+ "\"UniqueId\" : \"membase\",",
+ "\"Data\" : \"Done\"}' ",
+ "\"", {"Ref" : "WaitForInstanceWaitHandle"},"\"\n" ]]}}
+ }
+ },
+
+ "InstanceSecurityGroup" : {
+ "Type" : "AWS::EC2::SecurityGroup",
+ "Properties" : {
+ "GroupDescription" :
+ "Enable SSH access via port 22, web access to 8091, membase/memcached protocol access to 11211 and 11210, and erlang access",
+ "SecurityGroupIngress" : [ {
+ "IpProtocol" : "tcp",
+ "FromPort" : "22",
+ "ToPort" : "22",
+ "CidrIp" : "0.0.0.0/0"
+ }, {
+ "IpProtocol" : "tcp",
+ "FromPort" : "8091",
+ "ToPort" : "8091",
+ "CidrIp" : "0.0.0.0/0"
+ }, {
+ "IpProtocol" : "tcp",
+ "FromPort" : "11211",
+ "ToPort" : "11211",
+ "CidrIp" : "0.0.0.0/0"
+ }, {
+ "IpProtocol" : "tcp",
+ "FromPort" : "11210",
+ "ToPort" : "11210",
+ "CidrIp" : "0.0.0.0/0"
+ }, {
+ "IpProtocol" : "tcp",
+ "FromPort" : "4369",
+ "ToPort" : "4369",
+ "CidrIp" : "0.0.0.0/0"
+ }, {
+ "IpProtocol" : "tcp",
+ "FromPort" : "21100",
+ "ToPort" : "21299",
+ "CidrIp" : "0.0.0.0/0"
+ } ]
+ }
+ },
+
+ "WaitForInstanceWaitHandle" : {
+ "Type" : "AWS::CloudFormation::WaitConditionHandle",
+ "Properties" : {
+ }
+ },
+
+ "WaitForInstance" : {
+ "Type" : "AWS::CloudFormation::WaitCondition",
+ "DependsOn" : "Ec2Instance",
+ "Properties" : {
+ "Handle" : {"Ref" : "WaitForInstanceWaitHandle"},
+ "Timeout" : "600"
+ }
+ }
+ },
+
+ "Outputs" : {
+ "RESTWebConsoleURL" : {
+ "Description" : "The URL for the newly created Membase node(s)",
+ "Value" : { "Fn::Join" : ["", [ "http://", { "Fn::GetAtt" : [ "Ec2Instance", "PublicIp" ] }, ":8091" ]]}
+ }
+ }
+}

0 comments on commit f2cc435

Please sign in to comment.