Slide 51
Slide 51 text
CloudFormation Templates
"ClusterUserKeys" : {
"Type" : "AWS::IAM::AccessKey",
"Properties" : {
"UserName" : { "Ref": "ClusterUser" }
}
},
! "Ec2Instance" : {
! "Type" : "AWS::EC2::Instance",
! "Properties" : {
! "SecurityGroups" : [ { "Ref" : "InstanceSecurityGroup" } ],
! ! ! "InstanceType" : "t1.micro",
! "ImageId" : "ami-7341831a",
! ! "KeyName" : { "Ref" : "KeyName" },
! "Tags" : [{
! "Key" : "Role",
! "Value" : "Controller"
! }],
! ! ! "UserData" : { "Fn::Base64" : { "Fn::Join" : ["",
! ! ! [
! ! ! ! ! ! "#!/bin/sh\n",
! ! ! "/opt/aws/bin/cfn-init ", " -s ", { "Ref" : "AWS::StackName" }, " -r Ec2Instance ",
! ! ! "--access-key=", { "Ref" : "ClusterUserKeys" }, " ", "--secret-key=", { "Fn::GetAtt" : ["ClusterUserKeys",
"SecretAccessKey"]}, "\n",
! ! ! ! ! ! "cd /usr/src/pycrypto/pycrypto-2.4; /usr/bin/python setup.py build\n",
! ! ! ! ! ! "cd /usr/src/pycrypto/pycrypto-2.4; /usr/bin/python setup.py install\n",
! ! ! ! ! ! "cd /home/ec2-user/starcluster; /usr/bin/python distribute_setup.py\n",
! ! ! ! ! ! "cd /home/ec2-user/starcluster; /usr/bin/python setup.py install\n",
! ! ! ! ! "/bin/mkdir /home/ec2-user/.starcluster\n",
! ! ! ! ! "/bin/chown ec2-user:ec2-user -R /home/ec2-user/.starcluster\n",
! ! ! ! ! "/usr/bin/ruby /home/ec2-user/parser.rb /home/ec2-user/cc2-template.erb /home/ec2-user/values.yml > /home/ec2-
user/.starcluster/config\n",
! ! ! ! ! "/usr/bin/starcluster -c /home/ec2-user/.starcluster/config createkey ", { "Ref" : "ClusterKeypair" }, " -o /
home/ec2-user/.ssh/rsa-", { "Ref" : "ClusterKeypair" }, "\n",
! ! ! ! ! "/bin/chown ec2-user:ec2-user -R /home/ec2-user/.ssh/rsa-", { "Ref" : "ClusterKeypair" }, "\n",
! ! ! ! ! "cd /home/ec2-user/; /usr/bin/starcluster -c /home/ec2-user/.starcluster/config start ec2-cluster
\n"! ! ! ! ! !
! ! ! ! ! ! ]]}}