templates : remove in-tree templates
Now we have the heat-templates repository, and the test dependencies on the in-tree templates has been removed, we can remove these Change-Id: I85b379dbf5202136cbb987c3f176b9cc7b7ff666
This commit is contained in:
parent
04aa1215a1
commit
f754d1d53d
@ -6,7 +6,6 @@ include README.rst
|
|||||||
include MANIFEST.in pylintrc
|
include MANIFEST.in pylintrc
|
||||||
include openstack-common.conf
|
include openstack-common.conf
|
||||||
include babel.cfg install.sh run_tests.sh tox.ini uninstall.sh
|
include babel.cfg install.sh run_tests.sh tox.ini uninstall.sh
|
||||||
graft templates
|
|
||||||
include heat/cloudinit/config
|
include heat/cloudinit/config
|
||||||
include heat/cloudinit/boothook.sh
|
include heat/cloudinit/boothook.sh
|
||||||
include heat/cloudinit/loguserdata.py
|
include heat/cloudinit/loguserdata.py
|
||||||
|
@ -1,296 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "AWS CloudFormation Sample Template",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
|
|
||||||
"KeyName" : {
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "WebServer EC2 instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "m1.small",
|
|
||||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBName": {
|
|
||||||
"Default": "wordpress",
|
|
||||||
"Description" : "The WordPress database name",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBUsername": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account username",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "16",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account password",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBRootPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "Root password for MySQL",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Default": "F17",
|
|
||||||
"Description" : "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "32" },
|
|
||||||
"m1.small" : { "Arch" : "64" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "32" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
|
||||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
|
||||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
|
||||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
|
||||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
|
||||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
"CfnUser" : {
|
|
||||||
"Type" : "AWS::IAM::User"
|
|
||||||
},
|
|
||||||
"WebServerKeys" : {
|
|
||||||
"Type" : "AWS::IAM::AccessKey",
|
|
||||||
"Properties" : {
|
|
||||||
"UserName" : {"Ref": "CfnUser"}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"WebServerGroup" : {
|
|
||||||
"Type" : "AWS::AutoScaling::AutoScalingGroup",
|
|
||||||
"Properties" : {
|
|
||||||
"AvailabilityZones" : { "Fn::GetAZs" : ""},
|
|
||||||
"LaunchConfigurationName" : { "Ref" : "LaunchConfig" },
|
|
||||||
"MinSize" : "1",
|
|
||||||
"MaxSize" : "3",
|
|
||||||
"LoadBalancerNames" : [ { "Ref" : "ElasticLoadBalancer" } ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"WebServerScaleUpPolicy" : {
|
|
||||||
"Type" : "AWS::AutoScaling::ScalingPolicy",
|
|
||||||
"Properties" : {
|
|
||||||
"AdjustmentType" : "ChangeInCapacity",
|
|
||||||
"AutoScalingGroupName" : { "Ref" : "WebServerGroup" },
|
|
||||||
"Cooldown" : "60",
|
|
||||||
"ScalingAdjustment" : "1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"WebServerScaleDownPolicy" : {
|
|
||||||
"Type" : "AWS::AutoScaling::ScalingPolicy",
|
|
||||||
"Properties" : {
|
|
||||||
"AdjustmentType" : "ChangeInCapacity",
|
|
||||||
"AutoScalingGroupName" : { "Ref" : "WebServerGroup" },
|
|
||||||
"Cooldown" : "60",
|
|
||||||
"ScalingAdjustment" : "-1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"MEMAlarmHigh": {
|
|
||||||
"Type": "AWS::CloudWatch::Alarm",
|
|
||||||
"Properties": {
|
|
||||||
"AlarmDescription": "Scale-up if MEM > 50% for 1 minute",
|
|
||||||
"MetricName": "MemoryUtilization",
|
|
||||||
"Namespace": "system/linux",
|
|
||||||
"Statistic": "Average",
|
|
||||||
"Period": "60",
|
|
||||||
"EvaluationPeriods": "1",
|
|
||||||
"Threshold": "50",
|
|
||||||
"AlarmActions": [ { "Ref": "WebServerScaleUpPolicy" } ],
|
|
||||||
"Dimensions": [
|
|
||||||
{
|
|
||||||
"Name": "AutoScalingGroupName",
|
|
||||||
"Value": { "Ref": "WebServerGroup" }
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"ComparisonOperator": "GreaterThanThreshold"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"MEMAlarmLow": {
|
|
||||||
"Type": "AWS::CloudWatch::Alarm",
|
|
||||||
"Properties": {
|
|
||||||
"AlarmDescription": "Scale-down if MEM < 15% for 1 minute",
|
|
||||||
"MetricName": "MemoryUtilization",
|
|
||||||
"Namespace": "system/linux",
|
|
||||||
"Statistic": "Average",
|
|
||||||
"Period": "60",
|
|
||||||
"EvaluationPeriods": "1",
|
|
||||||
"Threshold": "15",
|
|
||||||
"AlarmActions": [ { "Ref": "WebServerScaleDownPolicy" } ],
|
|
||||||
"Dimensions": [
|
|
||||||
{
|
|
||||||
"Name": "AutoScalingGroupName",
|
|
||||||
"Value": { "Ref": "WebServerGroup" }
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"ComparisonOperator": "LessThanThreshold"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"ElasticLoadBalancer" : {
|
|
||||||
"Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
|
|
||||||
"Properties" : {
|
|
||||||
"AvailabilityZones" : { "Fn::GetAZs" : "" },
|
|
||||||
"Listeners" : [ {
|
|
||||||
"LoadBalancerPort" : "80",
|
|
||||||
"InstancePort" : "80",
|
|
||||||
"Protocol" : "HTTP"
|
|
||||||
} ],
|
|
||||||
"HealthCheck" : {
|
|
||||||
"Target" : "HTTP:80/",
|
|
||||||
"HealthyThreshold" : "3",
|
|
||||||
"UnhealthyThreshold" : "5",
|
|
||||||
"Interval" : "30",
|
|
||||||
"Timeout" : "5"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"LaunchConfig" : {
|
|
||||||
"Type" : "AWS::AutoScaling::LaunchConfiguration",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"files" : {
|
|
||||||
"/etc/cfn/cfn-credentials" : {
|
|
||||||
"content" : { "Fn::Join" : ["", [
|
|
||||||
"AWSAccessKeyId=", { "Ref" : "WebServerKeys" }, "\n",
|
|
||||||
"AWSSecretKey=", {"Fn::GetAtt": ["WebServerKeys",
|
|
||||||
"SecretAccessKey"]}, "\n"
|
|
||||||
]]},
|
|
||||||
"mode" : "000400",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
},
|
|
||||||
"/tmp/setup.mysql" : {
|
|
||||||
"content" : { "Fn::Join" : ["", [
|
|
||||||
"CREATE DATABASE ", { "Ref" : "DBName" }, ";\n",
|
|
||||||
"GRANT ALL PRIVILEGES ON ", { "Ref" : "DBName" },
|
|
||||||
".* TO '", { "Ref" : "DBUsername" }, "'@'localhost'\n",
|
|
||||||
"IDENTIFIED BY '", { "Ref" : "DBPassword" }, "';\n",
|
|
||||||
"FLUSH PRIVILEGES;\n",
|
|
||||||
"EXIT\n"
|
|
||||||
]]},
|
|
||||||
"mode" : "000644",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
},
|
|
||||||
"/tmp/stats-crontab.txt" : {
|
|
||||||
"content" : { "Fn::Join" : ["", [
|
|
||||||
"MAIL=\"\"\n",
|
|
||||||
"\n",
|
|
||||||
"* * * * * /opt/aws/bin/cfn-push-stats --watch ",
|
|
||||||
{ "Ref" : "MEMAlarmHigh" }, " --mem-util\n",
|
|
||||||
"* * * * * /opt/aws/bin/cfn-push-stats --watch ",
|
|
||||||
{ "Ref" : "MEMAlarmLow" }, " --mem-util\n"
|
|
||||||
]]},
|
|
||||||
"mode" : "000600",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"python-psutil": [],
|
|
||||||
"cronie" : [],
|
|
||||||
"mysql" : [],
|
|
||||||
"mysql-server" : [],
|
|
||||||
"httpd" : [],
|
|
||||||
"wordpress" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services" : {
|
|
||||||
"systemd" : {
|
|
||||||
"mysqld" : { "enabled" : "true", "ensureRunning" : "true" },
|
|
||||||
"httpd" : { "enabled" : "true", "ensureRunning" : "true" },
|
|
||||||
"crond" : { "enabled" : "true", "ensureRunning" : "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"/opt/aws/bin/cfn-init -s ", { "Ref" : "AWS::StackName" },
|
|
||||||
" -r LaunchConfig ",
|
|
||||||
" --region ", { "Ref" : "AWS::Region" }, "\n",
|
|
||||||
|
|
||||||
"# Setup MySQL root password and create a user\n",
|
|
||||||
"mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "'\n",
|
|
||||||
|
|
||||||
"mysql -u root --password='", { "Ref" : "DBRootPassword" },
|
|
||||||
"' < /tmp/setup.mysql\n",
|
|
||||||
|
|
||||||
"sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed --in-place --e s/database_name_here/", { "Ref" : "DBName" },
|
|
||||||
"/ --e s/username_here/", { "Ref" : "DBUsername" },
|
|
||||||
"/ --e s/password_here/", { "Ref" : "DBPassword" },
|
|
||||||
"/ /usr/share/wordpress/wp-config.php\n",
|
|
||||||
"systemctl restart httpd.service\n",
|
|
||||||
|
|
||||||
"# install crontab\n",
|
|
||||||
"crontab /tmp/stats-crontab.txt\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"URL" : {
|
|
||||||
"Description" : "The URL of the website",
|
|
||||||
"Value" : { "Fn::Join" : [ "", [ "http://", { "Fn::GetAtt" : [ "ElasticLoadBalancer", "DNSName" ]}, "/wordpress"]] }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,114 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "This template creates an instance and an EBS Volume.",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
|
|
||||||
"KeyName" : {
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "WebServer EC2 instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "m1.large",
|
|
||||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"VolumeSize" : {
|
|
||||||
"Description" : "WikiDatabase Volume size",
|
|
||||||
"Type" : "Number",
|
|
||||||
"Default" : "1",
|
|
||||||
"MinValue" : "1",
|
|
||||||
"MaxValue" : "1024",
|
|
||||||
"ConstraintDescription" : "must be between 1 and 1024 Gb."
|
|
||||||
},
|
|
||||||
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Default": "F17",
|
|
||||||
"Description" : "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "32" },
|
|
||||||
"m1.small" : { "Arch" : "32" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "32" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
|
||||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
|
||||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
|
||||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
|
||||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
|
||||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
"Ec2Instance" : {
|
|
||||||
"Type" : "AWS::EC2::Instance",
|
|
||||||
"Properties" : {
|
|
||||||
"SecurityGroups" : [ { "Ref" : "InstanceSecurityGroup" } ],
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"Volumes" : [
|
|
||||||
{ "VolumeId" : { "Ref" : "NewVolume" },
|
|
||||||
"Device" : "/dev/vdc1"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceSecurityGroup" : {
|
|
||||||
"Type" : "AWS::EC2::SecurityGroup",
|
|
||||||
"Properties" : {
|
|
||||||
"GroupDescription" : "Enable SSH access via port 22",
|
|
||||||
"SecurityGroupIngress" : [ {
|
|
||||||
"IpProtocol" : "tcp",
|
|
||||||
"FromPort" : "22",
|
|
||||||
"ToPort" : "22",
|
|
||||||
"CidrIp" : "0.0.0.0/0"
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"NewVolume" : {
|
|
||||||
"Type" : "AWS::EC2::Volume",
|
|
||||||
"Properties" : {
|
|
||||||
"Size" : { "Ref" : "VolumeSize" },
|
|
||||||
"AvailabilityZone" : { "Fn::GetAtt" : [ "Ec2Instance", "AvailabilityZone" ]}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"InstanceId" : {
|
|
||||||
"Description" : "InstanceId of the newly created EC2 instance",
|
|
||||||
"Value" : { "Ref" : "Ec2Instance" }
|
|
||||||
},
|
|
||||||
"PublicIP" : {
|
|
||||||
"Description" : "Public IP address of the newly created EC2 instance",
|
|
||||||
"Value" : { "Fn::GetAtt" : [ "Ec2Instance", "PublicIp" ] }
|
|
||||||
},
|
|
||||||
"PublicDNS" : {
|
|
||||||
"Description" : "Public DNSName of the newly created EC2 instance",
|
|
||||||
"Value" : { "Fn::GetAtt" : [ "Ec2Instance", "PublicDnsName" ] }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,130 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion": "2010-09-09",
|
|
||||||
|
|
||||||
"Description": "A load balancer instance running a local HAproxy",
|
|
||||||
|
|
||||||
"Parameters": {
|
|
||||||
|
|
||||||
"KeyName": {
|
|
||||||
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type": "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"Server1": {
|
|
||||||
"Description": "Server1 to load balance <ip:port>",
|
|
||||||
"Type": "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceType": {
|
|
||||||
"Description": "HAProxy server EC2 instance type",
|
|
||||||
"Default": "m1.small",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues": [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription": "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Default": "F17",
|
|
||||||
"Description" : "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "32" },
|
|
||||||
"m1.small" : { "Arch" : "32" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "32" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
|
||||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
|
||||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
|
||||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
|
||||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
|
||||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources": {
|
|
||||||
"LoadBalancerInstance": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"Metadata": {
|
|
||||||
"AWS::CloudFormation::Init": {
|
|
||||||
"config": {
|
|
||||||
"packages": {
|
|
||||||
"yum": {
|
|
||||||
"haproxy" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services": {
|
|
||||||
"systemd": {
|
|
||||||
"haproxy" : { "enabled": "true", "ensureRunning": "true" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"files": {
|
|
||||||
"/etc/haproxy/haproxy.cfg": {
|
|
||||||
"content": { "Fn::Join": ["", [
|
|
||||||
" global\n",
|
|
||||||
" daemon\n",
|
|
||||||
" maxconn 256\n",
|
|
||||||
"\n",
|
|
||||||
" defaults\n",
|
|
||||||
" mode http\n",
|
|
||||||
" timeout connect 5000ms\n",
|
|
||||||
" timeout client 50000ms\n",
|
|
||||||
" timeout server 50000ms\n",
|
|
||||||
"\n",
|
|
||||||
" frontend http-in\n",
|
|
||||||
" bind *:80\n",
|
|
||||||
" default_backend servers\n",
|
|
||||||
"\n",
|
|
||||||
" backend servers\n",
|
|
||||||
" balance roundrobin\n",
|
|
||||||
" option http-server-close\n",
|
|
||||||
" option forwardfor\n",
|
|
||||||
" server server1 ", { "Ref" : "Server1" }, "\n"
|
|
||||||
]]},
|
|
||||||
"mode": "000644",
|
|
||||||
"owner": "root",
|
|
||||||
"group": "root"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : {
|
|
||||||
"Fn::FindInMap" : [ "DistroArch2AMI",
|
|
||||||
{ "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch",
|
|
||||||
{ "Ref" : "InstanceType" },
|
|
||||||
"Arch" ] } ]
|
|
||||||
},
|
|
||||||
"InstanceType": { "Ref": "InstanceType" },
|
|
||||||
"KeyName": { "Ref": "KeyName" },
|
|
||||||
"UserData": { "Fn::Base64": { "Fn::Join": ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"/opt/aws/bin/cfn-init -s ",
|
|
||||||
{ "Ref": "AWS::StackName" },
|
|
||||||
" --region ", { "Ref": "AWS::Region" }, "\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs": {
|
|
||||||
"PublicIp": {
|
|
||||||
"Value": { "Fn::GetAtt": [ "LoadBalancerInstance", "PublicIp" ] },
|
|
||||||
"Description": "instance IP"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "Template to create multiple instances.",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
"KeyName" : {
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "Instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "m1.small",
|
|
||||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
"ImageId" : {
|
|
||||||
"Description" : "Name of the image to use",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "F17-x86_64-cfntools"
|
|
||||||
},
|
|
||||||
"NumInstances": {
|
|
||||||
"Default": "1",
|
|
||||||
"MinValue": "1",
|
|
||||||
"MaxValue": "100",
|
|
||||||
"Description" : "Number of instances to create",
|
|
||||||
"Type": "Number"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
"JobServerGroup" : {
|
|
||||||
"Type" : "OS::Heat::InstanceGroup",
|
|
||||||
"Properties" : {
|
|
||||||
"LaunchConfigurationName" : { "Ref" : "JobServerConfig" },
|
|
||||||
"Size" : {"Ref": "NumInstances"},
|
|
||||||
"AvailabilityZones" : { "Fn::GetAZs" : "" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"JobServerConfig" : {
|
|
||||||
"Type" : "AWS::AutoScaling::LaunchConfiguration",
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Ref" : "ImageId" },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"NovaSchedulerHints": [ {"Key": "part", "Value": "long"},
|
|
||||||
{"Key": "ready", "Value": "short"} ],
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,166 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "A Database instance running a local MySQL server",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
|
|
||||||
"KeyName" : {
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "Database server EC2 instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBName": {
|
|
||||||
"Description" : "The database name",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBUsername": {
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The database admin account username",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "16",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBPassword": {
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The database admin account password",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBRootPassword": {
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "Root password for MySQL",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Description" : "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ],
|
|
||||||
"Default": "F17"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "32" },
|
|
||||||
"m1.small" : { "Arch" : "32" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "32" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
|
||||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
|
||||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
|
||||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
|
||||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
|
||||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
"MySqlDatabaseServer": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"mysql" : [],
|
|
||||||
"mysql-server" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services" : {
|
|
||||||
"systemd" : {
|
|
||||||
"mysqld" : { "enabled" : "true", "ensureRunning" : "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
|
|
||||||
"# Helper function\n",
|
|
||||||
"function error_exit\n",
|
|
||||||
"{\n",
|
|
||||||
" /opt/aws/bin/cfn-signal -e 1 -r \"$1\" '", { "Ref" : "MySqlWaitHandle" }, "'\n",
|
|
||||||
" exit 1\n",
|
|
||||||
"}\n",
|
|
||||||
|
|
||||||
"/opt/aws/bin/cfn-init -s ", { "Ref" : "AWS::StackName" },
|
|
||||||
" -r MySqlDatabaseServer ",
|
|
||||||
" --region ", { "Ref" : "AWS::Region" },
|
|
||||||
" || error_exit 'Failed to run cfn-init'\n",
|
|
||||||
|
|
||||||
"# Setup MySQL root password and create a user\n",
|
|
||||||
"mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "'\n",
|
|
||||||
"cat << EOF | mysql -u root --password='", { "Ref" : "DBRootPassword" }, "'\n",
|
|
||||||
"CREATE DATABASE ", { "Ref" : "DBName" }, ";\n",
|
|
||||||
"GRANT ALL PRIVILEGES ON ", { "Ref" : "DBName" }, ".* TO \"", { "Ref" : "DBUsername" }, "\"@\"%\"\n",
|
|
||||||
"IDENTIFIED BY \"", { "Ref" : "DBPassword" }, "\";\n",
|
|
||||||
"FLUSH PRIVILEGES;\n",
|
|
||||||
"EXIT\n",
|
|
||||||
"EOF\n",
|
|
||||||
"# All is well so signal success\n",
|
|
||||||
"/opt/aws/bin/cfn-signal -e 0 -r \"MySQL Database setup complete\" '",
|
|
||||||
{ "Ref" : "MySqlWaitHandle" }, "'\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"MySqlWaitHandle" : {
|
|
||||||
"Type" : "AWS::CloudFormation::WaitConditionHandle"
|
|
||||||
},
|
|
||||||
|
|
||||||
"MySqlWaitCondition" : {
|
|
||||||
"Type" : "AWS::CloudFormation::WaitCondition",
|
|
||||||
"DependsOn" : "MySqlDatabaseServer",
|
|
||||||
"Properties" : {
|
|
||||||
"Handle" : {"Ref" : "MySqlWaitHandle"},
|
|
||||||
"Timeout" : "600"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"PublicIp": {
|
|
||||||
"Value": { "Fn::GetAtt" : [ "MySqlDatabaseServer", "PublicIp" ] },
|
|
||||||
"Description": "Database server IP"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,291 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion": "2010-09-09",
|
|
||||||
"Description": "Template for setting up an OpenShift Origin environment",
|
|
||||||
"Parameters": {
|
|
||||||
"KeyName": {
|
|
||||||
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern": "[-_ a-zA-Z0-9]*"
|
|
||||||
},
|
|
||||||
"Prefix": {
|
|
||||||
"Description": "Your DNS Prefix",
|
|
||||||
"Type": "String",
|
|
||||||
"Default": "example.com"
|
|
||||||
},
|
|
||||||
"DnsSecKey": {
|
|
||||||
"Description": "Bind DNS-Sec TSIG key",
|
|
||||||
"Type": "String",
|
|
||||||
"NoEcho": "TRUE"
|
|
||||||
},
|
|
||||||
"UpstreamDNS": {
|
|
||||||
"Description": "Upstream DNS server",
|
|
||||||
"Type": "String",
|
|
||||||
"Default": "8.8.8.8"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Mappings": {
|
|
||||||
"JeosImages": {
|
|
||||||
"Broker": {
|
|
||||||
"Image": "F18-x86_64-openshift-origin-broker-cfntools"
|
|
||||||
},
|
|
||||||
"Node": {
|
|
||||||
"Image": "F18-x86_64-openshift-origin-node-cfntools"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Resources": {
|
|
||||||
"OpenShiftOriginSecurityGroup": {
|
|
||||||
"Type": "AWS::EC2::SecurityGroup",
|
|
||||||
"Properties": {
|
|
||||||
"GroupDescription": "Standard firewall rules",
|
|
||||||
"SecurityGroupIngress": [
|
|
||||||
{
|
|
||||||
"IpProtocol": "udp",
|
|
||||||
"FromPort": "53",
|
|
||||||
"ToPort": "53",
|
|
||||||
"CidrIp": "0.0.0.0/0"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"IpProtocol": "tcp",
|
|
||||||
"FromPort": "53",
|
|
||||||
"ToPort": "53",
|
|
||||||
"CidrIp": "0.0.0.0/0"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"IpProtocol": "tcp",
|
|
||||||
"FromPort": "22",
|
|
||||||
"ToPort": "22",
|
|
||||||
"CidrIp": "0.0.0.0/0"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"IpProtocol": "tcp",
|
|
||||||
"FromPort": "80",
|
|
||||||
"ToPort": "80",
|
|
||||||
"CidrIp": "0.0.0.0/0"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"IpProtocol": "tcp",
|
|
||||||
"FromPort": "443",
|
|
||||||
"ToPort": "443",
|
|
||||||
"CidrIp": "0.0.0.0/0"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"IpProtocol": "tcp",
|
|
||||||
"FromPort": "8000",
|
|
||||||
"ToPort": "8000",
|
|
||||||
"CidrIp": "0.0.0.0/0"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"IpProtocol": "tcp",
|
|
||||||
"FromPort": "8443",
|
|
||||||
"ToPort": "8443",
|
|
||||||
"CidrIp": "0.0.0.0/0"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"brokerWaitHandle": {
|
|
||||||
"Type": "AWS::CloudFormation::WaitConditionHandle"
|
|
||||||
},
|
|
||||||
"brokerWaitCondition": {
|
|
||||||
"Type": "AWS::CloudFormation::WaitCondition",
|
|
||||||
"DependsOn": "BrokerInstance",
|
|
||||||
"Properties": {
|
|
||||||
"Handle": {
|
|
||||||
"Ref": "brokerWaitHandle"
|
|
||||||
},
|
|
||||||
"Timeout": "6000"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"BrokerInstance": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"Properties": {
|
|
||||||
"ImageId": {
|
|
||||||
"Fn::FindInMap": [ "JeosImages", "Broker", "Image" ]
|
|
||||||
},
|
|
||||||
"InstanceType": "m1.medium",
|
|
||||||
"KeyName": {
|
|
||||||
"Ref": "KeyName"
|
|
||||||
},
|
|
||||||
"SecurityGroups": [
|
|
||||||
{
|
|
||||||
"Ref": "OpenShiftOriginSecurityGroup"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"Tags": [
|
|
||||||
{
|
|
||||||
"Key": "Name",
|
|
||||||
"Value": {
|
|
||||||
"Fn::Join": [ "-", [ "openshift", { "Ref": "Prefix" }, "broker" ] ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"UserData": {
|
|
||||||
"Fn::Base64": {
|
|
||||||
"Fn::Join": [
|
|
||||||
"",
|
|
||||||
[
|
|
||||||
"#!/bin/bash -x", "\n",
|
|
||||||
"cat << EOF > /root/configure.pp\n",
|
|
||||||
"\\$my_hostname=\"\\${ec2_instance_id}.", { "Ref": "Prefix" }, "\"\n",
|
|
||||||
"file { \"update network settings - hostname\":", "\n",
|
|
||||||
" path => \"/etc/sysconfig/network\",\n",
|
|
||||||
" content => \"NETWORKING=yes\\nNETWORKING_IPV6=no\\nHOSTNAME=\\${my_hostname}\"\n",
|
|
||||||
"}\n",
|
|
||||||
"exec { \"set hostname\":\n",
|
|
||||||
" command => \"/bin/hostname \\${my_hostname} ; echo \\${my_hostname} > /etc/hostname\"\n",
|
|
||||||
"}\n",
|
|
||||||
"augeas{ \"etc hosts setup\" :\n",
|
|
||||||
" context => \"/files/etc/hosts\",\n",
|
|
||||||
" changes => [\n",
|
|
||||||
" \"set 01/ipaddr \\${ipaddress}\",\n",
|
|
||||||
" \"set 01/canonical \\${my_hostname}\",\n",
|
|
||||||
" ],\n",
|
|
||||||
"}\n",
|
|
||||||
"augeas{ \"network peerdns setup\" :\n",
|
|
||||||
" context => \"/files/etc/sysconfig/network-scripts/ifcfg-eth0\",\n",
|
|
||||||
" changes => [\n",
|
|
||||||
" \"set PEERDNS no\",\n",
|
|
||||||
" ],\n",
|
|
||||||
"}\n",
|
|
||||||
"class { \"openshift_origin\" :\n",
|
|
||||||
" node_fqdn => \\$my_hostname,\n",
|
|
||||||
" cloud_domain => \"", { "Ref": "Prefix" }, "\",", "\n",
|
|
||||||
" named_tsig_priv_key => \"", { "Ref": "DnsSecKey" }, "\",", "\n",
|
|
||||||
" dns_servers => [\"", { "Ref": "UpstreamDNS" }, "\"],\n",
|
|
||||||
" os_unmanaged_users => [\"ec2-user\"],\n",
|
|
||||||
" enable_network_services => true,\n",
|
|
||||||
" configure_firewall => false,\n",
|
|
||||||
" configure_ntp => true,\n",
|
|
||||||
" configure_activemq => true,\n",
|
|
||||||
" configure_qpid => false,\n",
|
|
||||||
" configure_mongodb => true,\n",
|
|
||||||
" configure_named => true,\n",
|
|
||||||
" configure_broker => true,\n",
|
|
||||||
" configure_console => true,\n",
|
|
||||||
" configure_node => false,\n",
|
|
||||||
" development_mode => true,\n",
|
|
||||||
" named_ipaddress => \\$ipaddress,\n",
|
|
||||||
" mongodb_fqdn => \\$my_hostname,\n",
|
|
||||||
" mq_fqdn => \\$my_hostname,\n",
|
|
||||||
" broker_fqdn => \\$my_hostname,\n",
|
|
||||||
"}\n",
|
|
||||||
"EOF\n",
|
|
||||||
"puppet module install openshift/openshift_origin", "\n",
|
|
||||||
"puppet apply --verbose /root/configure.pp | tee /var/log/configure_openshift.log", "\n",
|
|
||||||
"service network restart | tee /var/log/configure_openshift.log;\n",
|
|
||||||
"service mongod restart | tee /var/log/configure_openshift.log;\n",
|
|
||||||
"service activemq restart | tee /var/log/configure_openshift.log;\n",
|
|
||||||
"service httpd restart | tee /var/log/configure_openshift.log;\n",
|
|
||||||
"service openshift-broker restart | tee /var/log/configure_openshift.log;\n",
|
|
||||||
"service openshift-console restart | tee /var/log/configure_openshift.log;\n",
|
|
||||||
"service named restart | tee /var/log/configure_openshift.log;\n",
|
|
||||||
"export EC2_INSTANCE_ID=\"`facter ec2_instance_id`\"\n",
|
|
||||||
"export IP_ADDRESS=\"`facter ipaddress`\"\n",
|
|
||||||
"cat << _EOF > /root/nsupdate.cmd\n",
|
|
||||||
"key ", { "Ref": "Prefix" }," ",{ "Ref": "DnsSecKey" },"\n",
|
|
||||||
"server ${IP_ADDRESS} 53\n",
|
|
||||||
"update delete ${EC2_INSTANCE_ID}.",{ "Ref": "Prefix" }," A\n",
|
|
||||||
"update add ${EC2_INSTANCE_ID}.",{ "Ref": "Prefix" }," 180 A ${IP_ADDRESS}\n",
|
|
||||||
"send\n",
|
|
||||||
"_EOF\n",
|
|
||||||
"cat /root/nsupdate.cmd | nsupdate\n",
|
|
||||||
"# All is well so signal success\n",
|
|
||||||
"/opt/aws/bin/cfn-signal -e 0 -r \"Broker setup complete\" \"", { "Ref": "brokerWaitHandle" }, "\"\n"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"NodeInstance": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"DependsOn": "brokerWaitCondition",
|
|
||||||
"Properties": {
|
|
||||||
"ImageId": {
|
|
||||||
"Fn::FindInMap": [ "JeosImages", "Node", "Image" ]
|
|
||||||
},
|
|
||||||
"InstanceType": "m1.medium",
|
|
||||||
"KeyName": { "Ref": "KeyName" },
|
|
||||||
"SecurityGroups": [ { "Ref": "OpenShiftOriginSecurityGroup" } ],
|
|
||||||
"Tags": [ { "Key": "Name", "Value": { "Fn::Join": [ "-", [ "openshift", { "Ref": "Prefix" }, "node" ] ] } } ],
|
|
||||||
"UserData": {
|
|
||||||
"Fn::Base64": {
|
|
||||||
"Fn::Join": [
|
|
||||||
"",
|
|
||||||
[
|
|
||||||
"#!/bin/bash -x", "\n",
|
|
||||||
"cat << EOF > /root/configure.pp\n",
|
|
||||||
"\\$my_hostname=\"\\${ec2_instance_id}.", { "Ref": "Prefix" }, "\"\n",
|
|
||||||
"file { \"update network settings - hostname\":", "\n",
|
|
||||||
" path => \"/etc/sysconfig/network\",\n",
|
|
||||||
" content => \"NETWORKING=yes\\nNETWORKING_IPV6=no\\nHOSTNAME=\\${my_hostname}\"\n",
|
|
||||||
"}\n",
|
|
||||||
"exec { \"set hostname\":\n",
|
|
||||||
" command => \"/bin/hostname \\${my_hostname} ; echo \\${my_hostname} > /etc/hostname\"\n",
|
|
||||||
"}\n",
|
|
||||||
"augeas{ \"etc hosts setup\" :\n",
|
|
||||||
" context => \"/files/etc/hosts\",\n",
|
|
||||||
" changes => [\n",
|
|
||||||
" \"set 01/ipaddr \\${ipaddress}\",\n",
|
|
||||||
" \"set 01/canonical \\${my_hostname}\",\n",
|
|
||||||
" ],\n",
|
|
||||||
"}\n",
|
|
||||||
"augeas{ \"network peerdns setup\" :\n",
|
|
||||||
" context => \"/files/etc/sysconfig/network-scripts/ifcfg-eth0\",\n",
|
|
||||||
" changes => [\n",
|
|
||||||
" \"set PEERDNS no\",\n",
|
|
||||||
" ],\n",
|
|
||||||
"}\n",
|
|
||||||
"class { \"openshift_origin\" :\n",
|
|
||||||
" node_fqdn => \\$my_hostname,\n",
|
|
||||||
" cloud_domain => \"", { "Ref": "Prefix" }, "\",", "\n",
|
|
||||||
" named_tsig_priv_key => \"", { "Ref": "DnsSecKey" }, "\",", "\n",
|
|
||||||
" dns_servers => [\"", { "Fn::GetAtt": [ "BrokerInstance", "PublicIp" ] }, "\"],\n",
|
|
||||||
" os_unmanaged_users => [\"ec2-user\"],\n",
|
|
||||||
" enable_network_services => true,\n",
|
|
||||||
" configure_firewall => false,\n",
|
|
||||||
" configure_ntp => true,\n",
|
|
||||||
" configure_activemq => false,\n",
|
|
||||||
" configure_qpid => false,\n",
|
|
||||||
" configure_mongodb => false,\n",
|
|
||||||
" configure_named => false,\n",
|
|
||||||
" configure_broker => false,\n",
|
|
||||||
" configure_console => false,\n",
|
|
||||||
" configure_node => true,\n",
|
|
||||||
" development_mode => true,\n",
|
|
||||||
" named_ipaddress => \"", { "Fn::GetAtt": [ "BrokerInstance", "PublicIp" ] }, "\",\n",
|
|
||||||
" mongodb_fqdn => \"", { "Fn::GetAtt": [ "BrokerInstance", "PublicIp" ] }, "\",\n",
|
|
||||||
" mq_fqdn => \"", { "Fn::GetAtt": [ "BrokerInstance", "PublicIp" ] }, "\",\n",
|
|
||||||
" broker_fqdn => \"", { "Fn::GetAtt": [ "BrokerInstance", "PublicIp" ] }, "\",\n",
|
|
||||||
"}\n",
|
|
||||||
"EOF\n",
|
|
||||||
"puppet apply --verbose /root/configure.pp | tee /var/log/configure_openshift.log;", "\n",
|
|
||||||
"service network restart | tee /var/log/configure_openshift.log;\n",
|
|
||||||
"service cgconfig restart | tee /var/log/configure_openshift.log;\n",
|
|
||||||
"service cgred restart | tee /var/log/configure_openshift.log;\n",
|
|
||||||
"service openshift-cgroups restart | tee /var/log/configure_openshift.log;\n",
|
|
||||||
"service openshift-node-web-proxy restart | tee /var/log/configure_openshift.log;\n",
|
|
||||||
"service mcollective restart | tee /var/log/configure_openshift.log;\n",
|
|
||||||
"service httpd restart | tee /var/log/configure_openshift.log;\n",
|
|
||||||
"service sshd restart | tee /var/log/configure_openshift.log;\n",
|
|
||||||
"export EC2_INSTANCE_ID=\"`facter ec2_instance_id`\"\n",
|
|
||||||
"export IP_ADDRESS=\"`facter ipaddress`\"\n",
|
|
||||||
"cat << _EOF > /root/nsupdate.cmd\n",
|
|
||||||
"key ", { "Ref": "Prefix" }," ",{ "Ref": "DnsSecKey" },"\n",
|
|
||||||
"server ",{ "Fn::GetAtt": [ "BrokerInstance", "PublicIp" ] }," 53\n",
|
|
||||||
"update delete ${EC2_INSTANCE_ID}.",{ "Ref": "Prefix" }," A\n",
|
|
||||||
"update add ${EC2_INSTANCE_ID}.",{ "Ref": "Prefix" }," 180 A ${IP_ADDRESS}\n",
|
|
||||||
"send\n",
|
|
||||||
"_EOF\n",
|
|
||||||
"cat /root/nsupdate.cmd | nsupdate\n"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,227 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description": "Sample template to bring up Puppet Master instance that can be used to bootstrap and manage Puppet Clients. The Puppet Master is populated from an embedded template that defines the set of applications to load. **WARNING** This template creates one or more Amazon EC2 instances. You will be billed for the AWS resources used if you create a stack from this template.",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "WebServer EC2 instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "m1.large",
|
|
||||||
"AllowedValues" : [ "t1.micro","m1.small","m1.medium","m1.large","m1.xlarge","m2.xlarge","m2.2xlarge","m2.4xlarge","c1.medium","c1.xlarge","cc1.4xlarge","cc2.8xlarge","cg1.4xlarge"],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
"KeyName" : {
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the PuppetMaster",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
"ContentManifest" : {
|
|
||||||
"Default" : "/wordpress/: { include wordpress }",
|
|
||||||
"Description" : "Manifest of roles to add to nodes.pp",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
"ContentLocation" : {
|
|
||||||
"Default" : "https://s3.amazonaws.com/cloudformation-examples/wordpress-puppet-config.tar.gz",
|
|
||||||
"Description" : "Location of package (Zip, GZIP or Git repository URL) that includes the PuppetMaster content",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Default": "F17",
|
|
||||||
"Description" : "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "32" },
|
|
||||||
"m1.small" : { "Arch" : "32" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "32" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
|
||||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
|
||||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
|
||||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
|
||||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
|
||||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Resources" : {
|
|
||||||
"CFNInitUser" : {
|
|
||||||
"Type" : "AWS::IAM::User"
|
|
||||||
},
|
|
||||||
|
|
||||||
"CFNKeys" : {
|
|
||||||
"Type" : "AWS::IAM::AccessKey",
|
|
||||||
"Properties" : {
|
|
||||||
"UserName" : { "Ref": "CFNInitUser" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"PuppetMasterInstance" : {
|
|
||||||
"Type" : "AWS::EC2::Instance",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"puppet" : [],
|
|
||||||
"puppet-server" : [],
|
|
||||||
"ruby-devel" : [],
|
|
||||||
"gcc" : [],
|
|
||||||
"make" : [],
|
|
||||||
"rubygems" : []
|
|
||||||
},
|
|
||||||
"rubygems" : {
|
|
||||||
"json" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"sources" : {
|
|
||||||
"/etc/puppet" : { "Ref" : "ContentLocation" }
|
|
||||||
},
|
|
||||||
"files" : {
|
|
||||||
"/etc/yum.repos.d/epel.repo" : {
|
|
||||||
"source" : "https://s3.amazonaws.com/cloudformation-examples/enable-epel-on-amazon-linux-ami",
|
|
||||||
"mode" : "000644",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
},
|
|
||||||
"/etc/puppet/autosign.conf" : {
|
|
||||||
"content" : "*.internal\n",
|
|
||||||
"mode" : "100644",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "wheel"
|
|
||||||
},
|
|
||||||
"/etc/puppet/fileserver.conf" : {
|
|
||||||
"content" : "[modules]\n allow *.internal\n",
|
|
||||||
"mode" : "100644",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "wheel"
|
|
||||||
},
|
|
||||||
"/etc/puppet/puppet.conf" : {
|
|
||||||
"content" : { "Fn::Join" : ["", [
|
|
||||||
"[main]\n",
|
|
||||||
" logdir=/var/log/puppet\n",
|
|
||||||
" rundir=/var/run/puppet\n",
|
|
||||||
" ssldir=$vardir/ssl\n",
|
|
||||||
" pluginsync=true\n",
|
|
||||||
"[agent]\n",
|
|
||||||
" classfile=$vardir/classes.txt\n",
|
|
||||||
" localconfig=$vardir/localconfig\n"]] },
|
|
||||||
"mode" : "000644",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
},
|
|
||||||
"/etc/puppet/modules/cfn/manifests/init.pp" : {
|
|
||||||
"content" : "class cfn {}",
|
|
||||||
"mode" : "100644",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "wheel"
|
|
||||||
},
|
|
||||||
"/etc/puppet/modules/cfn/lib/facter/cfn.rb" : {
|
|
||||||
"source" : "https://s3.amazonaws.com/cloudformation-examples/cfn-facter-plugin.rb",
|
|
||||||
"mode" : "100644",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "wheel"
|
|
||||||
},
|
|
||||||
"/etc/puppet/manifests/nodes.pp" : {
|
|
||||||
"content" : {"Fn::Join" : ["", [
|
|
||||||
"node basenode {\n",
|
|
||||||
" include cfn\n",
|
|
||||||
"}\n",
|
|
||||||
"node /^.*internal$/ inherits basenode {\n",
|
|
||||||
" case $cfn_roles {\n",
|
|
||||||
" ", { "Ref" : "ContentManifest" }, "\n",
|
|
||||||
" }\n",
|
|
||||||
"}\n"]]},
|
|
||||||
"mode" : "100644",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "wheel"
|
|
||||||
},
|
|
||||||
"/etc/puppet/manifests/site.pp" : {
|
|
||||||
"content" : "import \"nodes\"\n",
|
|
||||||
"mode" : "100644",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "wheel"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services" : {
|
|
||||||
"sysvinit" : {
|
|
||||||
"puppetmaster" : {
|
|
||||||
"enabled" : "true",
|
|
||||||
"ensureRunning" : "true"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties" : {
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"SecurityGroups" : [ { "Ref" : "PuppetGroup" } ],
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash\n",
|
|
||||||
"yum update -y aws-cfn-bootstrap\n",
|
|
||||||
|
|
||||||
"/opt/aws/bin/cfn-init --region ", { "Ref" : "AWS::Region" },
|
|
||||||
" -s ", { "Ref" : "AWS::StackName" }, " -r PuppetMasterInstance ",
|
|
||||||
" --access-key ", { "Ref" : "CFNKeys" },
|
|
||||||
" --secret-key ", { "Fn::GetAtt" : ["CFNKeys", "SecretAccessKey"]}, "\n",
|
|
||||||
"/opt/aws/bin/cfn-signal -e $? '", { "Ref" : "PuppetMasterWaitHandle" }, "'\n"]]}}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"EC2SecurityGroup" : {
|
|
||||||
"Type" : "AWS::EC2::SecurityGroup",
|
|
||||||
"Properties" : {
|
|
||||||
"GroupDescription" : "Group for clients to communicate with Puppet Master"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"PuppetGroup" : {
|
|
||||||
"Type" : "AWS::EC2::SecurityGroup",
|
|
||||||
"Properties" : {
|
|
||||||
"GroupDescription" : "Group for puppet communication",
|
|
||||||
"SecurityGroupIngress" : [
|
|
||||||
{ "IpProtocol" : "tcp", "FromPort" : "8140", "ToPort" : "8140", "CidrIp": "0.0.0.0/0"},
|
|
||||||
{ "IpProtocol" : "tcp", "FromPort": "22", "ToPort": "22", "CidrIp": "0.0.0.0/0" }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"PuppetMasterWaitHandle" : {
|
|
||||||
"Type" : "AWS::CloudFormation::WaitConditionHandle"
|
|
||||||
},
|
|
||||||
|
|
||||||
"PuppetMasterWaitCondition" : {
|
|
||||||
"Type" : "AWS::CloudFormation::WaitCondition",
|
|
||||||
"DependsOn" : "PuppetMasterInstance",
|
|
||||||
"Properties" : {
|
|
||||||
"Handle" : { "Ref" : "PuppetMasterWaitHandle" },
|
|
||||||
"Timeout" : "600"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"PuppetMasterDNSName" : {
|
|
||||||
"Value" : { "Fn::GetAtt" : [ "PuppetMasterInstance", "PrivateDnsName" ] },
|
|
||||||
"Description" : "DNS Name of PuppetMaster"
|
|
||||||
},
|
|
||||||
"PuppetClientSecurityGroup" : {
|
|
||||||
"Value" : { "Ref" : "EC2SecurityGroup" },
|
|
||||||
"Description" : "Clients of the Puppet Master should be part of this security group"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,100 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "Template to test Quantum resources",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
"network": {
|
|
||||||
"Type": "OS::Quantum::Net",
|
|
||||||
"Properties": {
|
|
||||||
"name": "the_network"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"unnamed_network": {
|
|
||||||
"Type": "OS::Quantum::Net"
|
|
||||||
},
|
|
||||||
"admin_down_network": {
|
|
||||||
"Type": "OS::Quantum::Net",
|
|
||||||
"Properties": {
|
|
||||||
"admin_state_up": false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"subnet": {
|
|
||||||
"Type": "OS::Quantum::Subnet",
|
|
||||||
"Properties": {
|
|
||||||
"network_id": { "Ref" : "network" },
|
|
||||||
"ip_version": 4,
|
|
||||||
"cidr": "10.0.3.0/24",
|
|
||||||
"allocation_pools": [{"start": "10.0.3.20", "end": "10.0.3.150"}]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"port": {
|
|
||||||
"Type": "OS::Quantum::Port",
|
|
||||||
"Properties": {
|
|
||||||
"device_id": "d6b4d3a5-c700-476f-b609-1493dd9dadc0",
|
|
||||||
"name": "port1",
|
|
||||||
"network_id": { "Ref" : "network" },
|
|
||||||
"fixed_ips": [{
|
|
||||||
"subnet_id": { "Ref" : "subnet" },
|
|
||||||
"ip_address": "10.0.3.21"
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"router": {
|
|
||||||
"Type": "OS::Quantum::Router"
|
|
||||||
},
|
|
||||||
|
|
||||||
"router_interface": {
|
|
||||||
"Type": "OS::Quantum::RouterInterface",
|
|
||||||
"Properties": {
|
|
||||||
"router_id": { "Ref" : "router" },
|
|
||||||
"subnet_id": { "Ref" : "subnet" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Outputs" : {
|
|
||||||
"the_network_status" : {
|
|
||||||
"Value" : { "Fn::GetAtt" : [ "network", "status" ]},
|
|
||||||
"Description" : "Status of network"
|
|
||||||
},
|
|
||||||
"port_device_owner" : {
|
|
||||||
"Value" : { "Fn::GetAtt" : [ "port", "device_owner" ]},
|
|
||||||
"Description" : "Device owner of the port"
|
|
||||||
},
|
|
||||||
"port_fixed_ips" : {
|
|
||||||
"Value" : { "Fn::GetAtt" : [ "port", "fixed_ips" ]},
|
|
||||||
"Description" : "Fixed IPs of the port"
|
|
||||||
},
|
|
||||||
"port_mac_address" : {
|
|
||||||
"Value" : { "Fn::GetAtt" : [ "port", "mac_address" ]},
|
|
||||||
"Description" : "MAC address of the port"
|
|
||||||
},
|
|
||||||
"port_status" : {
|
|
||||||
"Value" : { "Fn::GetAtt" : [ "port", "status" ]},
|
|
||||||
"Description" : "Status of the port"
|
|
||||||
},
|
|
||||||
"port_show" : {
|
|
||||||
"Value" : { "Fn::GetAtt" : [ "port", "show" ]},
|
|
||||||
"Description" : "All attributes for port"
|
|
||||||
},
|
|
||||||
"subnet_show" : {
|
|
||||||
"Value" : { "Fn::GetAtt" : [ "subnet", "show" ]},
|
|
||||||
"Description" : "All attributes for subnet"
|
|
||||||
},
|
|
||||||
"network_show" : {
|
|
||||||
"Value" : { "Fn::GetAtt" : [ "network", "show" ]},
|
|
||||||
"Description" : "All attributes for network"
|
|
||||||
},
|
|
||||||
"router_show" : {
|
|
||||||
"Value" : { "Fn::GetAtt" : [ "router", "show" ]},
|
|
||||||
"Description" : "All attributes for router"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
HeatTemplateFormatVersion: '2012-12-12'
|
|
||||||
Description: Template to test Quantum resources
|
|
||||||
Resources:
|
|
||||||
network:
|
|
||||||
Type: OS::Quantum::Net
|
|
||||||
Properties: {name: the_network}
|
|
||||||
unnamed_network:
|
|
||||||
Type: 'OS::Quantum::Net'
|
|
||||||
admin_down_network:
|
|
||||||
Type: OS::Quantum::Net
|
|
||||||
Properties: {admin_state_up: false}
|
|
||||||
subnet:
|
|
||||||
Type: OS::Quantum::Subnet
|
|
||||||
Properties:
|
|
||||||
network_id: {Ref: network}
|
|
||||||
ip_version: 4
|
|
||||||
cidr: 10.0.3.0/24
|
|
||||||
allocation_pools:
|
|
||||||
- {end: 10.0.3.150, start: 10.0.3.20}
|
|
||||||
port:
|
|
||||||
Type: OS::Quantum::Port
|
|
||||||
Properties:
|
|
||||||
device_id: d6b4d3a5-c700-476f-b609-1493dd9dadc0
|
|
||||||
name: port1
|
|
||||||
network_id: {Ref: network}
|
|
||||||
fixed_ips:
|
|
||||||
- subnet_id: {Ref: subnet}
|
|
||||||
ip_address: 10.0.3.21
|
|
||||||
router:
|
|
||||||
Type: 'OS::Quantum::Router'
|
|
||||||
router_interface:
|
|
||||||
Type: OS::Quantum::RouterInterface
|
|
||||||
Properties:
|
|
||||||
router_id: {Ref: router}
|
|
||||||
subnet_id: {Ref: subnet}
|
|
||||||
Outputs:
|
|
||||||
the_network_status:
|
|
||||||
Value:
|
|
||||||
Fn::GetAtt: [network, status]
|
|
||||||
Description: Status of network
|
|
||||||
port_device_owner:
|
|
||||||
Value:
|
|
||||||
Fn::GetAtt: [port, device_owner]
|
|
||||||
Description: Device owner of the port
|
|
||||||
port_fixed_ips:
|
|
||||||
Value:
|
|
||||||
Fn::GetAtt: [port, fixed_ips]
|
|
||||||
Description: Fixed IPs of the port
|
|
||||||
port_mac_address:
|
|
||||||
Value:
|
|
||||||
Fn::GetAtt: [port, mac_address]
|
|
||||||
Description: MAC address of the port
|
|
||||||
port_status:
|
|
||||||
Value:
|
|
||||||
Fn::GetAtt: [port, status]
|
|
||||||
Description: Status of the port
|
|
||||||
port_show:
|
|
||||||
Value:
|
|
||||||
Fn::GetAtt: [port, show]
|
|
||||||
Description: All attributes for port
|
|
||||||
subnet_show:
|
|
||||||
Value:
|
|
||||||
Fn::GetAtt: [subnet, show]
|
|
||||||
Description: All attributes for subnet
|
|
||||||
network_show:
|
|
||||||
Value:
|
|
||||||
Fn::GetAtt: [network, show]
|
|
||||||
Description: All attributes for network
|
|
||||||
router_show:
|
|
||||||
Value:
|
|
||||||
Fn::GetAtt: [router, show]
|
|
||||||
Description: All attributes for router
|
|
@ -1,52 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "Template to test Quantum resources",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
|
|
||||||
"external_network" : {
|
|
||||||
"Description" : "UUID of an existing external network",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
"internal_network" : {
|
|
||||||
"Description" : "UUID of an existing internal network",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
"internal_subnet" : {
|
|
||||||
"Description" : "UUID of an existing internal subnet",
|
|
||||||
"Type" : "String"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
|
|
||||||
"port_floating": {
|
|
||||||
"Type": "OS::Quantum::Port",
|
|
||||||
"Properties": {
|
|
||||||
"network_id": { "Ref" : "internal_network" },
|
|
||||||
"fixed_ips": [{
|
|
||||||
"subnet_id": { "Ref" : "internal_subnet" },
|
|
||||||
"ip_address": "10.0.0.10"
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"floating_ip": {
|
|
||||||
"Type": "OS::Quantum::FloatingIP",
|
|
||||||
"Properties": {
|
|
||||||
"floating_network_id": { "Ref" : "external_network" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"floating_ip_assoc": {
|
|
||||||
"Type": "OS::Quantum::FloatingIPAssociation",
|
|
||||||
"Properties": {
|
|
||||||
"floatingip_id": { "Ref" : "floating_ip" },
|
|
||||||
"port_id": { "Ref" : "port_floating" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Outputs" : {
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,93 +0,0 @@
|
|||||||
-------------------------------------------------------------------------------
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
- The gold templates: -
|
|
||||||
- The gold images contain no cfntools -
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
WordPress_Single_Instance_gold.template
|
|
||||||
- Creates a gold image wordpress single instance - not working
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
- The cfntools templates: -
|
|
||||||
- The CFNTOOLS images contain analogs of AWS cfn tools for full orchestration -
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
*******************************************************************************
|
|
||||||
* INSECURE TEMPLATES *
|
|
||||||
* The following templates do not properly secure the mysql server and allow *
|
|
||||||
* any user to connect to the wordpress database. *
|
|
||||||
*******************************************************************************
|
|
||||||
|
|
||||||
WordPress_2_Instances.template
|
|
||||||
- Creates a two instance wordpress/mysql server
|
|
||||||
Note: There is an instance for mysql and instance for wordpress
|
|
||||||
|
|
||||||
WordPress_2_Instances_With_EBS.template
|
|
||||||
- Creates a two instance wordpress/mysql server with persistent volume
|
|
||||||
Note: There is an instance for mysql and instance for wordpress
|
|
||||||
|
|
||||||
WordPress_Composed_Instances.template
|
|
||||||
- Creates a two instance wordpress/mysql server.
|
|
||||||
- The MySQL server is loaded as a nested template from the URL of the latest
|
|
||||||
MySQL_Single_Instance template on GitHub.
|
|
||||||
Note: There is an instance for mysql and instance for wordpress
|
|
||||||
|
|
||||||
MySQL_Single_Instance.template
|
|
||||||
- Creates a single instance MySQL server, for use in template composition
|
|
||||||
|
|
||||||
*******************************************************************************
|
|
||||||
* SECURE TEMPLATES *
|
|
||||||
* These templates either are single vm or use EIP and security groups to *
|
|
||||||
* secure the servers *
|
|
||||||
*******************************************************************************
|
|
||||||
|
|
||||||
WordPress_Single_Instance.template
|
|
||||||
- Creates a single instance wordpress/mysql server
|
|
||||||
|
|
||||||
WordPress_Single_Instance_With_EBS.template
|
|
||||||
- Creates a single instance wordpress/mysql server with EBS Volume
|
|
||||||
|
|
||||||
WordPress_Single_Instance_With_EIP.template
|
|
||||||
- Creates a single instance wordpress/mysql server with EIP with full security
|
|
||||||
|
|
||||||
WordPress_Single_Instance_With_EBS_EIP.template
|
|
||||||
- Creates a single instance wordpress/mysql server with EIP with full security
|
|
||||||
and EBS Volume
|
|
||||||
|
|
||||||
WordPress_Single_Instance_deb.template
|
|
||||||
- Creates a single instance wordpress/mysql server, ubuntu based template
|
|
||||||
|
|
||||||
WordPress_Single_Instance_puppet.template
|
|
||||||
- Creates a single instance wordpress/mysql server
|
|
||||||
- Uses the Puppet client to install server roles
|
|
||||||
|
|
||||||
WordPress_Single_Instance_With_HA.template
|
|
||||||
- Creates a single instance wordpress/mysql server
|
|
||||||
- Includes configuration to use heat HA features
|
|
||||||
|
|
||||||
PuppetMaster_Single_Instance.template
|
|
||||||
- Sample template to bring up a Puppet Master instance
|
|
||||||
|
|
||||||
WordPress_2_Instances_With_EBS_EIP.template
|
|
||||||
- Creates a two instance wordpress/mysql server with persistent volume
|
|
||||||
- EIP with full security
|
|
||||||
Note: There is an instance for mysql and instance for wordpress
|
|
||||||
|
|
||||||
Rails_Single_Instance.template
|
|
||||||
- Create a Ruby on Rails stack
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
- Other templates: -
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
getting_started.template
|
|
||||||
- Skeleton example template
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
- END OF TEMPLATES -
|
|
||||||
-------------------------------------------------------------------------------
|
|
@ -1,254 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "AWS CloudFormation Sample Template Rails_Single_Instance: Create a Ruby on Rails stack using a single EC2 instance with a local MySQL database for storage. This template demonstrates using the AWS CloudFormation bootstrap scripts to install the packages and files necessary to deploy the packages and files at instance launch time. **WARNING** This template creates an Amazon EC2 instance. You will be billed for the AWS resources used if you create a stack from this template.",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
|
|
||||||
"KeyName" : {
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type" : "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern" : "[-_ a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "can contain only alphanumeric characters, spaces, dashes and underscores."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBName": {
|
|
||||||
"Default": "MyDatabase",
|
|
||||||
"Description" : "MySQL database name",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBUsername": {
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "Username for MySQL database access",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "16",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBPassword": {
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "Password MySQL database access",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBRootPassword": {
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "Root password for MySQL",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "WebServer EC2 instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "m1.small",
|
|
||||||
"AllowedValues" : [ "t1.micro","m1.small","m1.medium","m1.large","m1.xlarge","m2.xlarge","m2.2xlarge","m2.4xlarge","c1.medium","c1.xlarge","cc1.4xlarge","cc2.8xlarge","cg1.4xlarge"],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "64" },
|
|
||||||
"m1.small" : { "Arch" : "64" },
|
|
||||||
"m1.medium" : { "Arch" : "64" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "64" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64HVM" },
|
|
||||||
"cc2.8xlarge" : { "Arch" : "64HVM" },
|
|
||||||
"cg1.4xlarge" : { "Arch" : "64HVM" }
|
|
||||||
},
|
|
||||||
|
|
||||||
"AWSRegionArch2AMI" : {
|
|
||||||
"us-east-1" : { "32" : "ami-31814f58", "64" : "ami-1b814f72", "64HVM" : "ami-0da96764" },
|
|
||||||
"us-west-2" : { "32" : "ami-38fe7308", "64" : "ami-30fe7300", "64HVM" : "NOT_YET_SUPPORTED" },
|
|
||||||
"us-west-1" : { "32" : "ami-11d68a54", "64" : "ami-1bd68a5e", "64HVM" : "NOT_YET_SUPPORTED" },
|
|
||||||
"eu-west-1" : { "32" : "ami-973b06e3", "64" : "ami-953b06e1", "64HVM" : "NOT_YET_SUPPORTED" },
|
|
||||||
"ap-southeast-1" : { "32" : "ami-b4b0cae6", "64" : "F17-x86_64-cfntools", "64HVM" : "NOT_YET_SUPPORTED" },
|
|
||||||
"ap-northeast-1" : { "32" : "ami-0644f007", "64" : "ami-0a44f00b", "64HVM" : "NOT_YET_SUPPORTED" },
|
|
||||||
"sa-east-1" : { "32" : "ami-3e3be423", "64" : "ami-3c3be421", "64HVM" : "NOT_YET_SUPPORTED" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
|
|
||||||
"CfnUser" : {
|
|
||||||
"Type" : "AWS::IAM::User"
|
|
||||||
},
|
|
||||||
|
|
||||||
"HostKeys" : {
|
|
||||||
"Type" : "AWS::IAM::AccessKey",
|
|
||||||
"Properties" : {
|
|
||||||
"UserName" : {"Ref": "CfnUser"}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"WebServer": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"gcc-c++" : [],
|
|
||||||
"make" : [],
|
|
||||||
"ruby-devel" : [],
|
|
||||||
"rubygems" : [],
|
|
||||||
"mysql" : [],
|
|
||||||
"mysql-server" : [],
|
|
||||||
"mysql-devel" : [],
|
|
||||||
"mysql-libs" : []
|
|
||||||
},
|
|
||||||
|
|
||||||
"rubygems" : {
|
|
||||||
"rack" : ["1.3.6"],
|
|
||||||
"execjs" : [],
|
|
||||||
"therubyracer" : [],
|
|
||||||
"rails" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"sources" : {
|
|
||||||
"/home/ec2-user/sample" : "https://s3.amazonaws.com/cloudformation-examples/CloudFormationRailsSample.zip"
|
|
||||||
},
|
|
||||||
|
|
||||||
"files" : {
|
|
||||||
"/tmp/setup.mysql" : {
|
|
||||||
"content" : { "Fn::Join" : ["", [
|
|
||||||
"CREATE DATABASE ", { "Ref" : "DBName" }, ";\n",
|
|
||||||
"GRANT ALL PRIVILEGES ON ", { "Ref" : "DBName" }, ".* TO '", { "Ref" : "DBUsername" }, "'@'localhost'\n",
|
|
||||||
"IDENTIFIED BY '", { "Ref" : "DBPassword" }, "';\n",
|
|
||||||
"FLUSH PRIVILEGES;\n",
|
|
||||||
"EXIT\n"
|
|
||||||
]]},
|
|
||||||
"mode" : "000644",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
},
|
|
||||||
|
|
||||||
"/home/ec2-user/sample/config/database.yml" : {
|
|
||||||
"content" : { "Fn::Join" : ["", [
|
|
||||||
"development:\n",
|
|
||||||
" adapter: mysql2\n",
|
|
||||||
" encoding: utf8\n",
|
|
||||||
" reconnect: false\n",
|
|
||||||
" pool: 5\n",
|
|
||||||
" database: ", { "Ref" : "DBName" }, "\n",
|
|
||||||
" username: ", { "Ref" : "DBUsername" }, "\n",
|
|
||||||
" password: ", { "Ref" : "DBPassword" }, "\n",
|
|
||||||
" socket: /var/lib/mysql/mysql.sock\n"
|
|
||||||
]]},
|
|
||||||
"mode" : "000644",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"services" : {
|
|
||||||
"sysvinit" : {
|
|
||||||
"mysqld" : {
|
|
||||||
"enabled" : "true",
|
|
||||||
"ensureRunning" : "true"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "AWSRegionArch2AMI", { "Ref" : "AWS::Region" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"SecurityGroups" : [ {"Ref" : "FrontendGroup"} ],
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"yum update -y aws-cfn-bootstrap\n",
|
|
||||||
|
|
||||||
"# Helper function\n",
|
|
||||||
"function error_exit\n",
|
|
||||||
"{\n",
|
|
||||||
" /opt/aws/bin/cfn-signal -e 1 -r \"$1\" '", { "Ref" : "WaitHandle" }, "'\n",
|
|
||||||
" exit 1\n",
|
|
||||||
"}\n",
|
|
||||||
|
|
||||||
"# Install Rails packages\n",
|
|
||||||
"/opt/aws/bin/cfn-init -s ", { "Ref" : "AWS::StackName" }, " -r WebServer ",
|
|
||||||
" --access-key Ref_HostKeys",
|
|
||||||
" --secret-key Fn_GetAtt_HostKeys_SecretAccessKey",
|
|
||||||
" --region ", { "Ref" : "AWS::Region" }, " || error_exit 'Failed to run cfn-init'\n",
|
|
||||||
|
|
||||||
"# Setup MySQL root password and create a user\n",
|
|
||||||
"mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "' || error_exit 'Failed to initialize root password'\n",
|
|
||||||
"mysql -u root --password='", { "Ref" : "DBRootPassword" }, "' < /tmp/setup.mysql || error_exit 'Failed to create database user'\n",
|
|
||||||
|
|
||||||
"# Install anu other Gems, create the database and run a migration\n",
|
|
||||||
"cd /home/ec2-user/sample\n",
|
|
||||||
"bundle install || error_exit 'Failed to install bundle'\n",
|
|
||||||
"rake db:create || error_exit 'Failed to create database'\n",
|
|
||||||
"rake db:migrate || error_exit 'Failed to execute database migration'\n",
|
|
||||||
|
|
||||||
"# Startup the rails server\n",
|
|
||||||
"rails server -d\n",
|
|
||||||
"echo \"cd /home/ec2-user/sample\" >> /etc/rc.local\n",
|
|
||||||
"echo \"rails server -d\" >> /etc/rc.local\n",
|
|
||||||
|
|
||||||
"# All is well so signal success\n",
|
|
||||||
"/opt/aws/bin/cfn-signal -e 0 -r \"Rails application setup complete\" '", { "Ref" : "WaitHandle" }, "'\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"WaitHandle" : {
|
|
||||||
"Type" : "AWS::CloudFormation::WaitConditionHandle"
|
|
||||||
},
|
|
||||||
|
|
||||||
"WaitCondition" : {
|
|
||||||
"Type" : "AWS::CloudFormation::WaitCondition",
|
|
||||||
"DependsOn" : "WebServer",
|
|
||||||
"Properties" : {
|
|
||||||
"Handle" : {"Ref" : "WaitHandle"},
|
|
||||||
"Timeout" : "1500"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"FrontendGroup" : {
|
|
||||||
"Type" : "AWS::EC2::SecurityGroup",
|
|
||||||
"Properties" : {
|
|
||||||
"GroupDescription" : "Enable HTTP access via port 3000 plus SSH access",
|
|
||||||
"SecurityGroupIngress" : [
|
|
||||||
{"IpProtocol" : "tcp", "FromPort" : "3000", "ToPort" : "3000", "CidrIp" : "0.0.0.0/0"},
|
|
||||||
{"IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : "0.0.0.0/0"}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"WebsiteURL" : {
|
|
||||||
"Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "WebServer", "PublicIp" ]}, ":3000" ]] },
|
|
||||||
"Description" : "URL for newly created Rails application"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "Template to test S3 Bucket resources",
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
"S3BucketWebsite" : {
|
|
||||||
"Type" : "AWS::S3::Bucket",
|
|
||||||
"DeletionPolicy" : "Delete",
|
|
||||||
"Properties" : {
|
|
||||||
"AccessControl" : "PublicRead",
|
|
||||||
"WebsiteConfiguration" : {
|
|
||||||
"IndexDocument" : "index.html",
|
|
||||||
"ErrorDocument" : "error.html"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"S3Bucket" : {
|
|
||||||
"Type" : "AWS::S3::Bucket",
|
|
||||||
"Properties" : {
|
|
||||||
"AccessControl" : "Private"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"WebsiteURL" : {
|
|
||||||
"Value" : { "Fn::GetAtt" : [ "S3Bucket", "WebsiteURL" ] },
|
|
||||||
"Description" : "URL for website hosted on S3"
|
|
||||||
},
|
|
||||||
"DomainName" : {
|
|
||||||
"Value" : { "Fn::GetAtt" : [ "S3Bucket", "DomainName" ] },
|
|
||||||
"Description" : "Domain of S3 host"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "Template to test OS::Swift::Container resources",
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
"SwiftContainerWebsite" : {
|
|
||||||
"Type" : "OS::Swift::Container",
|
|
||||||
"DeletionPolicy" : "Delete",
|
|
||||||
"Properties" : {
|
|
||||||
"X-Container-Read" : ".r:*",
|
|
||||||
"X-Container-Meta" : {
|
|
||||||
"Web-Index" : "index.html",
|
|
||||||
"Web-Error" : "error.html"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"SwiftContainer" : {
|
|
||||||
"Type" : "OS::Swift::Container",
|
|
||||||
"Properties" : {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"WebsiteURL" : {
|
|
||||||
"Value" : { "Fn::GetAtt" : [ "SwiftContainer", "WebsiteURL" ] },
|
|
||||||
"Description" : "URL for website hosted on S3"
|
|
||||||
},
|
|
||||||
"DomainName" : {
|
|
||||||
"Value" : { "Fn::GetAtt" : [ "SwiftContainer", "DomainName" ] },
|
|
||||||
"Description" : "Domain of Swift host"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,179 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "AWS CloudFormation Sample Template WordPress_Multi_Instance: WordPress is web software you can use to create a beautiful website or blog. This template installs two instances: one running a WordPress deployment and the other using a local MySQL database to store the data.",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
|
|
||||||
"KeyName" : {
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "WebServer EC2 instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "m1.large",
|
|
||||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBName": {
|
|
||||||
"Default": "wordpress",
|
|
||||||
"Description" : "The WordPress database name",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBUsername": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account username",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "16",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account password",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBRootPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "Root password for MySQL",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Default": "F17",
|
|
||||||
"Description" : "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "32" },
|
|
||||||
"m1.small" : { "Arch" : "32" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "32" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
|
||||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
|
||||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
|
||||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
|
||||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
|
||||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
"DatabaseServer": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"mysql" : [],
|
|
||||||
"mysql-server" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services" : {
|
|
||||||
"systemd" : {
|
|
||||||
"mysqld" : { "enabled" : "true", "ensureRunning" : "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"/opt/aws/bin/cfn-init\n",
|
|
||||||
"# Setup MySQL root password and create a user\n",
|
|
||||||
"mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "'\n",
|
|
||||||
"cat << EOF | mysql -u root --password='", { "Ref" : "DBRootPassword" }, "'\n",
|
|
||||||
"CREATE DATABASE ", { "Ref" : "DBName" }, ";\n",
|
|
||||||
"GRANT ALL PRIVILEGES ON ", { "Ref" : "DBName" }, ".* TO \"", { "Ref" : "DBUsername" }, "\"@\"%\"\n",
|
|
||||||
"IDENTIFIED BY \"", { "Ref" : "DBPassword" }, "\";\n",
|
|
||||||
"FLUSH PRIVILEGES;\n",
|
|
||||||
"EXIT\n",
|
|
||||||
"EOF\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"WebServer": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"DependsOn": "DatabaseServer",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"httpd" : [],
|
|
||||||
"wordpress" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services" : {
|
|
||||||
"systemd" : {
|
|
||||||
"httpd" : { "enabled" : "true", "ensureRunning" : "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"/opt/aws/bin/cfn-init\n",
|
|
||||||
"sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed -i \"s/Require local/Require all granted/\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed --in-place --e s/database_name_here/", { "Ref" : "DBName" }, "/ --e s/username_here/", { "Ref" : "DBUsername" }, "/ --e s/password_here/", { "Ref" : "DBPassword" }, "/ --e s/localhost/", { "Fn::GetAtt" : [ "DatabaseServer", "PublicIp" ]}, "/ /usr/share/wordpress/wp-config.php\n",
|
|
||||||
"systemctl restart httpd.service\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"WebsiteURL" : {
|
|
||||||
"Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "WebServer", "PublicIp" ]}, "/wordpress"]] },
|
|
||||||
"Description" : "URL for Wordpress wiki"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,221 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "AWS CloudFormation Sample Template WordPress_Multi_Instance: WordPress is web software you can use to create a beautiful website or blog. This template installs two instances: one running a WordPress deployment and the other using a local MySQL database to store the data.",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
|
|
||||||
"KeyName" : {
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "WebServer EC2 instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "m1.large",
|
|
||||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"VolumeSize" : {
|
|
||||||
"Description" : "WikiDatabase Volume size",
|
|
||||||
"Type" : "Number",
|
|
||||||
"Default" : "1",
|
|
||||||
"MinValue" : "1",
|
|
||||||
"MaxValue" : "1024",
|
|
||||||
"ConstraintDescription" : "must be between 1 and 1024 Gb."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBName": {
|
|
||||||
"Default": "wordpress",
|
|
||||||
"Description" : "The WordPress database name",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBUsername": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account username",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "16",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account password",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBRootPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "Root password for MySQL",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Default": "F17",
|
|
||||||
"Description" : "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "32" },
|
|
||||||
"m1.small" : { "Arch" : "32" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "32" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
|
||||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
|
||||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
|
||||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
|
||||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
|
||||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
"WikiDatabase": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"mysql" : [],
|
|
||||||
"mysql-server" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services" : {
|
|
||||||
"systemd" : {
|
|
||||||
"mysqld" : { "enabled" : "true", "ensureRunning" : "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"/opt/aws/bin/cfn-init\n",
|
|
||||||
|
|
||||||
"# Wait for the volume to appear\n",
|
|
||||||
"while [ ! -e /dev/vdc ]; do echo Waiting for volume to attach; sleep 1; done\n",
|
|
||||||
"parted -s /dev/vdc mklabel msdos\n",
|
|
||||||
"parted -s /dev/vdc mkpart primary ext3 1 1000\n",
|
|
||||||
"# Format the EBS volume and mount it\n",
|
|
||||||
"systemctl stop mysqld.service\n",
|
|
||||||
"sleep 1\n",
|
|
||||||
"mv /var/lib/mysql /var/lib/mysql.data\n",
|
|
||||||
"/sbin/mkfs -t ext3 /dev/vdc1\n",
|
|
||||||
"mkdir /var/lib/mysql\n",
|
|
||||||
"mount /dev/vdc1 /var/lib/mysql\n",
|
|
||||||
"chown mysql.mysql /var/lib/mysql\n",
|
|
||||||
"mv -n /var/lib/mysql.data/* /var/lib/mysql\n",
|
|
||||||
"systemctl start mysqld.service\n",
|
|
||||||
"sleep 1\n",
|
|
||||||
"# Setup MySQL root password and create a user\n",
|
|
||||||
"mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "'\n",
|
|
||||||
"cat << EOF | mysql -u root --password='", { "Ref" : "DBRootPassword" }, "'\n",
|
|
||||||
"CREATE DATABASE ", { "Ref" : "DBName" }, ";\n",
|
|
||||||
"GRANT ALL PRIVILEGES ON ", { "Ref" : "DBName" }, ".* TO \"", { "Ref" : "DBUsername" }, "\"@\"%\"\n",
|
|
||||||
"IDENTIFIED BY \"", { "Ref" : "DBPassword" }, "\";\n",
|
|
||||||
"FLUSH PRIVILEGES;\n",
|
|
||||||
"EXIT\n",
|
|
||||||
"EOF\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"DataVolume" : {
|
|
||||||
"Type" : "AWS::EC2::Volume",
|
|
||||||
"Properties" : {
|
|
||||||
"Size" : { "Ref" : "VolumeSize" },
|
|
||||||
"AvailabilityZone" : { "Fn::GetAtt" : [ "WikiDatabase", "AvailabilityZone" ]},
|
|
||||||
"Tags" : [{ "Key" : "Usage", "Value" : "Wiki Data Volume" }]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"WebServer": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"DependsOn": "WikiDatabase",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"httpd" : [],
|
|
||||||
"wordpress" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services" : {
|
|
||||||
"systemd" : {
|
|
||||||
"httpd" : { "enabled" : "true", "ensureRunning" : "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"/opt/aws/bin/cfn-init\n",
|
|
||||||
"sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed -i \"s/Require local/Require all granted/\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed --in-place --e s/database_name_here/", { "Ref" : "DBName" }, "/ --e s/username_here/", { "Ref" : "DBUsername" }, "/ --e s/password_here/", { "Ref" : "DBPassword" }, "/ --e s/localhost/", { "Fn::GetAtt" : [ "WikiDatabase", "PublicIp" ]}, "/ /usr/share/wordpress/wp-config.php\n",
|
|
||||||
"systemctl restart httpd.service\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"MountPoint" : {
|
|
||||||
"Type" : "AWS::EC2::VolumeAttachment",
|
|
||||||
"Properties" : {
|
|
||||||
"InstanceId" : { "Ref" : "WikiDatabase" },
|
|
||||||
"VolumeId" : { "Ref" : "DataVolume" },
|
|
||||||
"Device" : "/dev/vdc"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"WebsiteURL" : {
|
|
||||||
"Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "WebServer", "PublicIp" ]}, "/wordpress"]] },
|
|
||||||
"Description" : "URL for Wordpress wiki"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,257 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "AWS CloudFormation Sample Template WordPress_Multi_Instance: WordPress is web software you can use to create a beautiful website or blog. This template installs two instances: one running a WordPress deployment and the other using a local MySQL database to store the data.",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
|
|
||||||
"KeyName" : {
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "WebServer EC2 instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "m1.large",
|
|
||||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"VolumeSize" : {
|
|
||||||
"Description" : "WikiDatabase Volume size",
|
|
||||||
"Type" : "Number",
|
|
||||||
"Default" : "1",
|
|
||||||
"MinValue" : "1",
|
|
||||||
"MaxValue" : "1024",
|
|
||||||
"ConstraintDescription" : "must be between 1 and 1024 Gb."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBName": {
|
|
||||||
"Default": "wordpress",
|
|
||||||
"Description" : "The WordPress database name",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBUsername": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account username",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "16",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account password",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBRootPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "Root password for MySQL",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Default": "F17",
|
|
||||||
"Description" : "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "32" },
|
|
||||||
"m1.small" : { "Arch" : "32" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "32" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
|
||||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
|
||||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
|
||||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
|
||||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
|
||||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
"DatabaseIPAddress" : {
|
|
||||||
"Type" : "AWS::EC2::EIP"
|
|
||||||
},
|
|
||||||
|
|
||||||
"DatabaseIPAssoc" : {
|
|
||||||
"Type" : "AWS::EC2::EIPAssociation",
|
|
||||||
"Properties" : {
|
|
||||||
"InstanceId" : { "Ref" : "WikiDatabase" },
|
|
||||||
"EIP" : { "Ref" : "DatabaseIPAddress" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"WebServerIPAddress" : {
|
|
||||||
"Type" : "AWS::EC2::EIP"
|
|
||||||
},
|
|
||||||
|
|
||||||
"WebServerIPAssoc" : {
|
|
||||||
"Type" : "AWS::EC2::EIPAssociation",
|
|
||||||
"Properties" : {
|
|
||||||
"InstanceId" : { "Ref" : "WebServer" },
|
|
||||||
"EIP" : { "Ref" : "WebServerIPAddress" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"WikiDatabaseSecurityGroup" : {
|
|
||||||
"Type" : "AWS::EC2::SecurityGroup",
|
|
||||||
"Properties" : {
|
|
||||||
"GroupDescription" : "Enable HTTP access via port 80 plus SSH access",
|
|
||||||
"SecurityGroupIngress" : [
|
|
||||||
{"IpProtocol" : "icmp", "FromPort" : "-1", "ToPort" : "-1", "CidrIp" : "0.0.0.0/0"},
|
|
||||||
{"IpProtocol" : "tcp", "FromPort" : "80", "ToPort" : "80", "CidrIp" : "0.0.0.0/0"},
|
|
||||||
{"IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : "0.0.0.0/0"}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"WikiDatabase": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"mysql" : [],
|
|
||||||
"mysql-server" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services" : {
|
|
||||||
"systemd" : {
|
|
||||||
"mysqld" : { "enabled" : "true", "ensureRunning" : "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"SecurityGroups" : [ {"Ref" : "WikiDatabaseSecurityGroup"} ],
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"/opt/aws/bin/cfn-init\n",
|
|
||||||
|
|
||||||
"# Wait for the volume to appear\n",
|
|
||||||
"while [ ! -e /dev/vdc ]; do echo Waiting for volume to attach; sleep 1; done\n",
|
|
||||||
"parted -s /dev/vdc mklabel msdos\n",
|
|
||||||
"parted -s /dev/vdc mkpart primary ext3 1 1000\n",
|
|
||||||
"# Format the EBS volume and mount it\n",
|
|
||||||
"systemctl stop mysqld.service\n",
|
|
||||||
"sleep 1\n",
|
|
||||||
"mv /var/lib/mysql /var/lib/mysql.data\n",
|
|
||||||
"/sbin/mkfs -t ext3 /dev/vdc1\n",
|
|
||||||
"mkdir /var/lib/mysql\n",
|
|
||||||
"mount /dev/vdc1 /var/lib/mysql\n",
|
|
||||||
"chown mysql.mysql /var/lib/mysql\n",
|
|
||||||
"mv -n /var/lib/mysql.data/* /var/lib/mysql\n",
|
|
||||||
"systemctl start mysqld.service\n",
|
|
||||||
"sleep 1\n",
|
|
||||||
"# Setup MySQL root password and create a user\n",
|
|
||||||
"mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "'\n",
|
|
||||||
"cat << EOF | mysql -u root --password='", { "Ref" : "DBRootPassword" }, "'\n",
|
|
||||||
"CREATE DATABASE ", { "Ref" : "DBName" }, ";\n",
|
|
||||||
"GRANT ALL PRIVILEGES ON ", { "Ref" : "DBName" }, ".* TO \"", { "Ref" : "DBUsername" }, "\"@\"", { "Ref" : "WebServerIPAddress" }, "\"\n",
|
|
||||||
"IDENTIFIED BY \"", { "Ref" : "DBPassword" }, "\";\n",
|
|
||||||
"FLUSH PRIVILEGES;\n",
|
|
||||||
"EXIT\n",
|
|
||||||
"EOF\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"DataVolume" : {
|
|
||||||
"Type" : "AWS::EC2::Volume",
|
|
||||||
"Properties" : {
|
|
||||||
"Size" : { "Ref" : "VolumeSize" },
|
|
||||||
"AvailabilityZone" : { "Fn::GetAtt" : [ "WikiDatabase", "AvailabilityZone" ]},
|
|
||||||
"Tags" : [{ "Key" : "Usage", "Value" : "Wiki Data Volume" }]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"WebServer": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"DependsOn": "WikiDatabase",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"httpd" : [],
|
|
||||||
"wordpress" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services" : {
|
|
||||||
"systemd" : {
|
|
||||||
"httpd" : { "enabled" : "true", "ensureRunning" : "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"/opt/aws/bin/cfn-init\n",
|
|
||||||
"sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed -i \"s/Require local/Require all granted/\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed --in-place --e s/database_name_here/", { "Ref" : "DBName" }, "/ --e s/username_here/", { "Ref" : "DBUsername" }, "/ --e s/password_here/", { "Ref" : "DBPassword" }, "/ --e s/localhost/", { "Ref" : "DatabaseIPAddress" }, "/ /usr/share/wordpress/wp-config.php\n",
|
|
||||||
"systemctl restart httpd.service\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"MountPoint" : {
|
|
||||||
"Type" : "AWS::EC2::VolumeAttachment",
|
|
||||||
"Properties" : {
|
|
||||||
"InstanceId" : { "Ref" : "WikiDatabase" },
|
|
||||||
"VolumeId" : { "Ref" : "DataVolume" },
|
|
||||||
"Device" : "/dev/vdc"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"WebsiteURL" : {
|
|
||||||
"Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "WebServer", "PublicIp" ]}, "/wordpress"]] },
|
|
||||||
"Description" : "URL for Wordpress wiki"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,138 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion": "2010-09-09",
|
|
||||||
|
|
||||||
"Description": "This template installs one instance running a WordPress deployment",
|
|
||||||
|
|
||||||
"Parameters": {
|
|
||||||
|
|
||||||
"KeyName": {
|
|
||||||
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type": "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceType": {
|
|
||||||
"Description": "WebServer EC2 instance type",
|
|
||||||
"Type": "String",
|
|
||||||
"Default": "m1.large",
|
|
||||||
"AllowedValues": ["t1.micro", "m1.small", "m1.large", "m1.xlarge",
|
|
||||||
"m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium",
|
|
||||||
"c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription": "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBIpaddress": {
|
|
||||||
"Description": "The IP address of the database",
|
|
||||||
"Type": "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBName": {
|
|
||||||
"Default": "wordpress",
|
|
||||||
"Description": "The WordPress database name",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern": "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription": "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBUsername": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description": "The WordPress database admin account username",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "16",
|
|
||||||
"AllowedPattern": "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription": "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description": "The WordPress database admin account password",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern": "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription": "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Default": "F17",
|
|
||||||
"Description": "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues": [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings": {
|
|
||||||
"AWSInstanceType2Arch": {
|
|
||||||
"t1.micro" : { "Arch": "32" },
|
|
||||||
"m1.small" : { "Arch": "32" },
|
|
||||||
"m1.large" : { "Arch": "64" },
|
|
||||||
"m1.xlarge" : { "Arch": "64" },
|
|
||||||
"m2.xlarge" : { "Arch": "64" },
|
|
||||||
"m2.2xlarge" : { "Arch": "64" },
|
|
||||||
"m2.4xlarge" : { "Arch": "64" },
|
|
||||||
"c1.medium" : { "Arch": "32" },
|
|
||||||
"c1.xlarge" : { "Arch": "64" },
|
|
||||||
"cc1.4xlarge": { "Arch": "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"F18" : { "32": "F18-i386-cfntools", "64": "F18-x86_64-cfntools" },
|
|
||||||
"F17" : { "32": "F17-i386-cfntools", "64": "F17-x86_64-cfntools" },
|
|
||||||
"U10" : { "32": "U10-i386-cfntools", "64": "U10-x86_64-cfntools" },
|
|
||||||
"RHEL-6.1": { "32": "rhel61-i386-cfntools", "64": "rhel61-x86_64-cfntools" },
|
|
||||||
"RHEL-6.2": { "32": "rhel62-i386-cfntools", "64": "rhel62-x86_64-cfntools" },
|
|
||||||
"RHEL-6.3": { "32": "rhel63-i386-cfntools", "64": "rhel63-x86_64-cfntools" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources": {
|
|
||||||
"WebServer": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"Metadata": {
|
|
||||||
"AWS::CloudFormation::Init": {
|
|
||||||
"config": {
|
|
||||||
"packages": {
|
|
||||||
"yum": {
|
|
||||||
"httpd" : [],
|
|
||||||
"wordpress" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services": {
|
|
||||||
"systemd": {
|
|
||||||
"httpd" : { "enabled": "true", "ensureRunning": "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId": { "Fn::FindInMap": [ "DistroArch2AMI", { "Ref": "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap": [ "AWSInstanceType2Arch", { "Ref": "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref": "InstanceType" },
|
|
||||||
"KeyName" : { "Ref": "KeyName" },
|
|
||||||
"UserData" : { "Fn::Base64": { "Fn::Join": ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"/opt/aws/bin/cfn-init\n",
|
|
||||||
"sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed -i \"s/Require local/Require all granted/\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed --in-place --e s/database_name_here/", { "Ref": "DBName" },
|
|
||||||
"/ --e s/username_here/", { "Ref": "DBUsername" },
|
|
||||||
"/ --e s/password_here/", { "Ref": "DBPassword" },
|
|
||||||
"/ --e s/localhost/", { "Ref": "DBIpaddress"},
|
|
||||||
"/ /usr/share/wordpress/wp-config.php\n",
|
|
||||||
"systemctl restart httpd.service\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs": {
|
|
||||||
"PublicIp": {
|
|
||||||
"Value": {"Fn::GetAtt": [ "WebServer", "PublicIp"]},
|
|
||||||
"Description": "IP address of WebServer instance"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,155 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "WordPress is web software you can use to create a beautiful website or blog. This template installs two instances: one running a WordPress deployment and the other, created within a separate stack embedded in this one with template composition, using a local MySQL database to store the data.",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
|
|
||||||
"KeyName" : {
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "WebServer EC2 instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "m1.large",
|
|
||||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBName": {
|
|
||||||
"Default": "wordpress",
|
|
||||||
"Description" : "The WordPress database name",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBUsername": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account username",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "16",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account password",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBRootPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "Root password for MySQL",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Default": "F17",
|
|
||||||
"Description" : "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "32" },
|
|
||||||
"m1.small" : { "Arch" : "32" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "32" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
|
||||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
|
||||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
|
||||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
|
||||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
|
||||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
"DatabaseTemplate": {
|
|
||||||
"Type": "AWS::CloudFormation::Stack",
|
|
||||||
"Properties": {
|
|
||||||
"TemplateURL": "https://raw.github.com/openstack/heat/master/templates/MySQL_Single_Instance.template",
|
|
||||||
"Parameters": {
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"DBName" : { "Ref" : "DBName" },
|
|
||||||
"DBUsername" : { "Ref" : "DBUsername" },
|
|
||||||
"DBPassword" : { "Ref" : "DBPassword" },
|
|
||||||
"DBRootPassword" : { "Ref" : "DBRootPassword" },
|
|
||||||
"LinuxDistribution" : { "Ref" : "LinuxDistribution" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"WebServer": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"DependsOn": "DatabaseTemplate",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"httpd" : [],
|
|
||||||
"wordpress" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services" : {
|
|
||||||
"systemd" : {
|
|
||||||
"httpd" : { "enabled" : "true", "ensureRunning" : "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"/opt/aws/bin/cfn-init\n",
|
|
||||||
"sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed -i \"s/Require local/Require all granted/\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed --in-place --e s/database_name_here/", { "Ref" : "DBName" }, "/ --e s/username_here/", { "Ref" : "DBUsername" }, "/ --e s/password_here/", { "Ref" : "DBPassword" }, "/ --e s/localhost/", { "Fn::GetAtt" : [ "DatabaseTemplate", "Outputs.PublicIp" ]}, "/ /usr/share/wordpress/wp-config.php\n",
|
|
||||||
"systemctl restart httpd.service\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"WebsiteURL" : {
|
|
||||||
"Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "WebServer", "PublicIp" ]}, "/wordpress"]] },
|
|
||||||
"Description" : "URL for Wordpress wiki"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,144 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "AWS CloudFormation Sample Template WordPress_Single_Instance: WordPress is web software you can use to create a beautiful website or blog. This template installs a single-instance WordPress deployment using a local MySQL database to store the data.",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "WebServer EC2 instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "m1.large",
|
|
||||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBName": {
|
|
||||||
"Default": "wordpress",
|
|
||||||
"Description" : "The WordPress database name",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBUsername": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account username",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "16",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account password",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBRootPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "Root password for MySQL",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Default": "F17",
|
|
||||||
"Description" : "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "32" },
|
|
||||||
"m1.small" : { "Arch" : "32" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "32" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"F18" : { "32" : "F18-i386-gold", "64" : "F18-x86_64-gold" },
|
|
||||||
"F17" : { "32" : "F17-i386-gold", "64" : "F17-x86_64-gold" },
|
|
||||||
"U10" : { "32" : "U10-i386-gold", "64" : "U10-x86_64-gold" },
|
|
||||||
"RHEL-6.1" : { "32" : "rhel61-i386-gold", "64" : "rhel61-x86_64-gold" },
|
|
||||||
"RHEL-6.2" : { "32" : "rhel62-i386-gold", "64" : "rhel62-x86_64-gold" },
|
|
||||||
"RHEL-6.3" : { "32" : "rhel63-i386-gold", "64" : "rhel63-x86_64-gold" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
|
|
||||||
"WebServer": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"httpd" : [],
|
|
||||||
"mysql" : [],
|
|
||||||
"mysql-server" : [],
|
|
||||||
"wordpress" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services" : {
|
|
||||||
"systemd" : {
|
|
||||||
"httpd" : { "enabled" : "true", "ensureRunning" : "true" },
|
|
||||||
"mysqld" : { "enabled" : "true", "ensureRunning" : "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"# Setup MySQL root password and create a user\n",
|
|
||||||
"mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "'\n",
|
|
||||||
"cat >> /tmp/mysql-wordpress-config << EOF\n",
|
|
||||||
"CREATE DATABASE ", { "Ref" : "DBName" }, ";\n",
|
|
||||||
"GRANT ALL PRIVILEGES ON ", { "Ref" : "DBName" }, ".* TO \"", { "Ref" : "DBUsername" }, "\"@\"localhost\"\n",
|
|
||||||
"IDENTIFIED BY \"", { "Ref" : "DBPassword" }, "\";\n",
|
|
||||||
"FLUSH PRIVILEGES;\n",
|
|
||||||
"EXIT\n",
|
|
||||||
"EOF\n",
|
|
||||||
"cat /tmp/mysql-wordpress-config | mysql -u root --password='", { "Ref" : "DBRootPassword" }, "' < /tmp/mysql-wordpress-config\n",
|
|
||||||
"sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed -i \"s/Require local/Require all granted/\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed --in-place --e s/database_name_here/", { "Ref" : "DBName" }, "/ --e s/username_here/", { "Ref" : "DBUsername" }, "/ --e s/password_here/", { "Ref" : "DBPassword" }, "/ /usr/share/wordpress/wp-config.php\n",
|
|
||||||
"cp /usr/share/wordpress/wp-config.php /usr/share/wordpress/wp-config.orig\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"WebsiteURL" : {
|
|
||||||
"Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "WebServer", "PublicIp" ]}, "/wordpress"]] },
|
|
||||||
"Description" : "URL for Wordpress wiki"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,149 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "AWS CloudFormation Sample Template WordPress_Single_Instance: WordPress is web software you can use to create a beautiful website or blog. This template installs a single-instance WordPress deployment using a local MySQL database to store the data.",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
|
|
||||||
"KeyName" : {
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "WebServer EC2 instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "m1.large",
|
|
||||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBName": {
|
|
||||||
"Default": "wordpress",
|
|
||||||
"Description" : "The WordPress database name",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBUsername": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account username",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "16",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account password",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBRootPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "Root password for MySQL",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Default": "F17",
|
|
||||||
"Description" : "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "32" },
|
|
||||||
"m1.small" : { "Arch" : "32" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "32" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
|
||||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
|
||||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
|
||||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
|
||||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
|
||||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
"WikiDatabase": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"mysql" : [],
|
|
||||||
"mysql-server" : [],
|
|
||||||
"httpd" : [],
|
|
||||||
"wordpress" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services" : {
|
|
||||||
"systemd" : {
|
|
||||||
"mysqld" : { "enabled" : "true", "ensureRunning" : "true" },
|
|
||||||
"httpd" : { "enabled" : "true", "ensureRunning" : "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"/opt/aws/bin/cfn-init\n",
|
|
||||||
"# Setup MySQL root password and create a user\n",
|
|
||||||
"mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "'\n",
|
|
||||||
"cat << EOF | mysql -u root --password='", { "Ref" : "DBRootPassword" }, "'\n",
|
|
||||||
"CREATE DATABASE ", { "Ref" : "DBName" }, ";\n",
|
|
||||||
"GRANT ALL PRIVILEGES ON ", { "Ref" : "DBName" }, ".* TO \"", { "Ref" : "DBUsername" }, "\"@\"localhost\"\n",
|
|
||||||
"IDENTIFIED BY \"", { "Ref" : "DBPassword" }, "\";\n",
|
|
||||||
"FLUSH PRIVILEGES;\n",
|
|
||||||
"EXIT\n",
|
|
||||||
"EOF\n",
|
|
||||||
"sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed -i \"s/Require local/Require all granted/\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed --in-place --e s/database_name_here/", { "Ref" : "DBName" }, "/ --e s/username_here/", { "Ref" : "DBUsername" }, "/ --e s/password_here/", { "Ref" : "DBPassword" }, "/ /usr/share/wordpress/wp-config.php\n",
|
|
||||||
"systemctl restart httpd.service\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"WebsiteURL" : {
|
|
||||||
"Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "WikiDatabase", "PublicIp" ]}, "/wordpress"]] },
|
|
||||||
"Description" : "URL for Wordpress wiki"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,161 +0,0 @@
|
|||||||
HeatTemplateFormatVersion: '2012-12-12'
|
|
||||||
Description: 'AWS CloudFormation Sample Template WordPress_Single_Instance:
|
|
||||||
WordPress is web software you can use to create a beautiful website or blog. This
|
|
||||||
template installs a single-instance WordPress deployment using a local MySQL database
|
|
||||||
to store the data.'
|
|
||||||
Parameters:
|
|
||||||
KeyName: {Description: Name of an existing EC2 KeyPair
|
|
||||||
to enable SSH access to the instances, Type: String}
|
|
||||||
InstanceType:
|
|
||||||
Description: WebServer EC2 instance type
|
|
||||||
Type: String
|
|
||||||
Default: m1.large
|
|
||||||
AllowedValues: [t1.micro, m1.small, m1.large, m1.xlarge, m2.xlarge,
|
|
||||||
m2.2xlarge, m2.4xlarge, c1.medium, c1.xlarge, cc1.4xlarge]
|
|
||||||
ConstraintDescription: must be a valid EC2 instance type.
|
|
||||||
DBName: {Default: wordpress, Description: The
|
|
||||||
WordPress database name, Type: String, MinLength: '1',
|
|
||||||
MaxLength: '64', AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*',
|
|
||||||
ConstraintDescription: must begin with a letter and contain only
|
|
||||||
alphanumeric characters.}
|
|
||||||
DBUsername: {Default: admin, NoEcho: 'true',
|
|
||||||
Description: The WordPress database admin account username, Type: String,
|
|
||||||
MinLength: '1', MaxLength: '16', AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*',
|
|
||||||
ConstraintDescription: must begin with a letter and contain only
|
|
||||||
alphanumeric characters.}
|
|
||||||
DBPassword: {Default: admin, NoEcho: 'true',
|
|
||||||
Description: The WordPress database admin account password, Type: String,
|
|
||||||
MinLength: '1', MaxLength: '41', AllowedPattern: '[a-zA-Z0-9]*',
|
|
||||||
ConstraintDescription: must contain only alphanumeric characters.}
|
|
||||||
DBRootPassword: {Default: admin, NoEcho: 'true',
|
|
||||||
Description: Root password for MySQL, Type: String,
|
|
||||||
MinLength: '1', MaxLength: '41', AllowedPattern: '[a-zA-Z0-9]*',
|
|
||||||
ConstraintDescription: must contain only alphanumeric characters.}
|
|
||||||
LinuxDistribution:
|
|
||||||
Default: F17
|
|
||||||
Description: Distribution of choice
|
|
||||||
Type: String
|
|
||||||
AllowedValues: [F18, F17, U10, RHEL-6.1, RHEL-6.2, RHEL-6.3]
|
|
||||||
Mappings:
|
|
||||||
AWSInstanceType2Arch:
|
|
||||||
t1.micro: {Arch: '32'}
|
|
||||||
m1.small: {Arch: '32'}
|
|
||||||
m1.large: {Arch: '64'}
|
|
||||||
m1.xlarge: {Arch: '64'}
|
|
||||||
m2.xlarge: {Arch: '64'}
|
|
||||||
m2.2xlarge: {Arch: '64'}
|
|
||||||
m2.4xlarge: {Arch: '64'}
|
|
||||||
c1.medium: {Arch: '32'}
|
|
||||||
c1.xlarge: {Arch: '64'}
|
|
||||||
cc1.4xlarge: {Arch: '64'}
|
|
||||||
DistroArch2AMI:
|
|
||||||
F18: {'32': F18-i386-cfntools, '64': F18-x86_64-cfntools}
|
|
||||||
F17: {'32': F17-i386-cfntools, '64': F17-x86_64-cfntools}
|
|
||||||
U10: {'32': U10-i386-cfntools, '64': U10-x86_64-cfntools}
|
|
||||||
RHEL-6.1: {'32': rhel61-i386-cfntools, '64': rhel61-x86_64-cfntools}
|
|
||||||
RHEL-6.2: {'32': rhel62-i386-cfntools, '64': rhel62-x86_64-cfntools}
|
|
||||||
RHEL-6.3: {'32': rhel63-i386-cfntools, '64': rhel63-x86_64-cfntools}
|
|
||||||
Resources:
|
|
||||||
WikiDatabase:
|
|
||||||
Type: AWS::EC2::Instance
|
|
||||||
Metadata:
|
|
||||||
AWS::CloudFormation::Init:
|
|
||||||
config:
|
|
||||||
packages:
|
|
||||||
yum:
|
|
||||||
mysql: []
|
|
||||||
mysql-server: []
|
|
||||||
httpd: []
|
|
||||||
wordpress: []
|
|
||||||
services:
|
|
||||||
systemd:
|
|
||||||
mysqld: {enabled: 'true', ensureRunning: 'true'}
|
|
||||||
httpd: {enabled: 'true', ensureRunning: 'true'}
|
|
||||||
Properties:
|
|
||||||
ImageId:
|
|
||||||
Fn::FindInMap:
|
|
||||||
- DistroArch2AMI
|
|
||||||
- {Ref: LinuxDistribution}
|
|
||||||
- Fn::FindInMap:
|
|
||||||
- AWSInstanceType2Arch
|
|
||||||
- {Ref: InstanceType}
|
|
||||||
- Arch
|
|
||||||
InstanceType: {Ref: InstanceType}
|
|
||||||
KeyName: {Ref: KeyName}
|
|
||||||
UserData:
|
|
||||||
Fn::Base64:
|
|
||||||
Fn::Join:
|
|
||||||
- ''
|
|
||||||
- - '#!/bin/bash -v
|
|
||||||
|
|
||||||
'
|
|
||||||
- '/opt/aws/bin/cfn-init
|
|
||||||
|
|
||||||
'
|
|
||||||
- '# Setup MySQL root password and create a user
|
|
||||||
|
|
||||||
'
|
|
||||||
- mysqladmin -u root password '
|
|
||||||
- {Ref: DBRootPassword}
|
|
||||||
- '''
|
|
||||||
|
|
||||||
'
|
|
||||||
- cat << EOF | mysql -u root --password='
|
|
||||||
- {Ref: DBRootPassword}
|
|
||||||
- '''
|
|
||||||
|
|
||||||
'
|
|
||||||
- 'CREATE DATABASE '
|
|
||||||
- {Ref: DBName}
|
|
||||||
- ';
|
|
||||||
|
|
||||||
'
|
|
||||||
- 'GRANT ALL PRIVILEGES ON '
|
|
||||||
- {Ref: DBName}
|
|
||||||
- .* TO "
|
|
||||||
- {Ref: DBUsername}
|
|
||||||
- '"@"localhost"
|
|
||||||
|
|
||||||
'
|
|
||||||
- IDENTIFIED BY "
|
|
||||||
- {Ref: DBPassword}
|
|
||||||
- '";
|
|
||||||
|
|
||||||
'
|
|
||||||
- 'FLUSH PRIVILEGES;
|
|
||||||
|
|
||||||
'
|
|
||||||
- 'EXIT
|
|
||||||
|
|
||||||
'
|
|
||||||
- 'EOF
|
|
||||||
|
|
||||||
'
|
|
||||||
- 'sed -i "/Deny from All/d" /etc/httpd/conf.d/wordpress.conf
|
|
||||||
|
|
||||||
'
|
|
||||||
- 'sed -i "s/Require local/Require all granted/" /etc/httpd/conf.d/wordpress.conf
|
|
||||||
|
|
||||||
'
|
|
||||||
- sed --in-place --e s/database_name_here/
|
|
||||||
- {Ref: DBName}
|
|
||||||
- / --e s/username_here/
|
|
||||||
- {Ref: DBUsername}
|
|
||||||
- / --e s/password_here/
|
|
||||||
- {Ref: DBPassword}
|
|
||||||
- '/ /usr/share/wordpress/wp-config.php
|
|
||||||
|
|
||||||
'
|
|
||||||
- 'systemctl restart httpd.service
|
|
||||||
|
|
||||||
'
|
|
||||||
Outputs:
|
|
||||||
WebsiteURL:
|
|
||||||
Value:
|
|
||||||
Fn::Join:
|
|
||||||
- ''
|
|
||||||
- - http://
|
|
||||||
- Fn::GetAtt: [WikiDatabase, PublicIp]
|
|
||||||
- /wordpress
|
|
||||||
Description: URL for Wordpress wiki
|
|
||||||
|
|
@ -1,192 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "AWS CloudFormation Sample Template WordPress_Single_Instance: WordPress is web software you can use to create a beautiful website or blog. This template installs a single-instance WordPress deployment using a local MySQL database to store the data.",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
|
|
||||||
"KeyName" : {
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "WebServer EC2 instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "m1.large",
|
|
||||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"VolumeSize" : {
|
|
||||||
"Description" : "WikiDatabase Volume size",
|
|
||||||
"Type" : "Number",
|
|
||||||
"Default" : "1",
|
|
||||||
"MinValue" : "1",
|
|
||||||
"MaxValue" : "1024",
|
|
||||||
"ConstraintDescription" : "must be between 1 and 1024 Gb."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBName": {
|
|
||||||
"Default": "wordpress",
|
|
||||||
"Description" : "The WordPress database name",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBUsername": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account username",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "16",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account password",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBRootPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "Root password for MySQL",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Default": "F17",
|
|
||||||
"Description" : "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "32" },
|
|
||||||
"m1.small" : { "Arch" : "32" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "32" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
|
||||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
|
||||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
|
||||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
|
||||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
|
||||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
"WikiDatabase": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"mysql" : [],
|
|
||||||
"mysql-server" : [],
|
|
||||||
"httpd" : [],
|
|
||||||
"wordpress" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services" : {
|
|
||||||
"systemd" : {
|
|
||||||
"mysqld" : { "enabled" : "true", "ensureRunning" : "true" },
|
|
||||||
"httpd" : { "enabled" : "true", "ensureRunning" : "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"/opt/aws/bin/cfn-init\n",
|
|
||||||
|
|
||||||
"# Wait for the volume to appear\n",
|
|
||||||
"while [ ! -e /dev/vdc ]; do echo Waiting for volume to attach; sleep 1; done\n",
|
|
||||||
"parted -s /dev/vdc mklabel msdos\n",
|
|
||||||
"parted -s /dev/vdc mkpart primary ext3 1 1000\n",
|
|
||||||
"# Format the EBS volume and mount it\n",
|
|
||||||
"systemctl stop mysqld.service\n",
|
|
||||||
"sleep 1\n",
|
|
||||||
"mv /var/lib/mysql /var/lib/mysql.data\n",
|
|
||||||
"/sbin/mkfs -t ext3 /dev/vdc1\n",
|
|
||||||
"mkdir /var/lib/mysql\n",
|
|
||||||
"mount /dev/vdc1 /var/lib/mysql\n",
|
|
||||||
"chown mysql.mysql /var/lib/mysql\n",
|
|
||||||
"mv -n /var/lib/mysql.data/* /var/lib/mysql\n",
|
|
||||||
"systemctl start mysqld.service\n",
|
|
||||||
"sleep 1\n",
|
|
||||||
"# Setup MySQL root password and create a user\n",
|
|
||||||
"mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "'\n",
|
|
||||||
"cat << EOF | mysql -u root --password='", { "Ref" : "DBRootPassword" }, "'\n",
|
|
||||||
"CREATE DATABASE ", { "Ref" : "DBName" }, ";\n",
|
|
||||||
"GRANT ALL PRIVILEGES ON ", { "Ref" : "DBName" }, ".* TO \"", { "Ref" : "DBUsername" }, "\"@\"localhost\"\n",
|
|
||||||
"IDENTIFIED BY \"", { "Ref" : "DBPassword" }, "\";\n",
|
|
||||||
"FLUSH PRIVILEGES;\n",
|
|
||||||
"EXIT\n",
|
|
||||||
"EOF\n",
|
|
||||||
"sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed -i \"s/Require local/Require all granted/\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed --in-place --e s/database_name_here/", { "Ref" : "DBName" }, "/ --e s/username_here/", { "Ref" : "DBUsername" }, "/ --e s/password_here/", { "Ref" : "DBPassword" }, "/ /usr/share/wordpress/wp-config.php\n",
|
|
||||||
"systemctl restart httpd.service\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"DataVolume" : {
|
|
||||||
"Type" : "AWS::EC2::Volume",
|
|
||||||
"Properties" : {
|
|
||||||
"Size" : { "Ref" : "VolumeSize" },
|
|
||||||
"AvailabilityZone" : { "Fn::GetAtt" : [ "WikiDatabase", "AvailabilityZone" ]},
|
|
||||||
"Tags" : [{ "Key" : "Usage", "Value" : "Wiki Data Volume" }]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"MountPoint" : {
|
|
||||||
"Type" : "AWS::EC2::VolumeAttachment",
|
|
||||||
"Properties" : {
|
|
||||||
"InstanceId" : { "Ref" : "WikiDatabase" },
|
|
||||||
"VolumeId" : { "Ref" : "DataVolume" },
|
|
||||||
"Device" : "/dev/vdc"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"WebsiteURL" : {
|
|
||||||
"Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "WikiDatabase", "PublicIp" ]}, "/wordpress"]] },
|
|
||||||
"Description" : "URL for Wordpress wiki"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,217 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "AWS CloudFormation Sample Template WordPress_Single_Instance: WordPress is web software you can use to create a beautiful website or blog. This template installs a single-instance WordPress deployment using a local MySQL database to store the data.",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
|
|
||||||
"KeyName" : {
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "WikiServer EC2 instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "m1.large",
|
|
||||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"VolumeSize" : {
|
|
||||||
"Description" : "WikiServer Volume size",
|
|
||||||
"Type" : "Number",
|
|
||||||
"Default" : "1",
|
|
||||||
"MinValue" : "1",
|
|
||||||
"MaxValue" : "1024",
|
|
||||||
"ConstraintDescription" : "must be between 1 and 1024 Gb."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBName": {
|
|
||||||
"Default": "wordpress",
|
|
||||||
"Description" : "The WordPress database name",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBUsername": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account username",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "16",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account password",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBRootPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "Root password for MySQL",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Default": "F17",
|
|
||||||
"Description" : "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "32" },
|
|
||||||
"m1.small" : { "Arch" : "32" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "32" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
|
||||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
|
||||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
|
||||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
|
||||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
|
||||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
|
|
||||||
"IPAddress" : {
|
|
||||||
"Type" : "AWS::EC2::EIP"
|
|
||||||
},
|
|
||||||
|
|
||||||
"IPAssoc" : {
|
|
||||||
"Type" : "AWS::EC2::EIPAssociation",
|
|
||||||
"Properties" : {
|
|
||||||
"InstanceId" : { "Ref" : "WikiServer" },
|
|
||||||
"EIP" : { "Ref" : "IPAddress" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"WikiServerSecurityGroup" : {
|
|
||||||
"Type" : "AWS::EC2::SecurityGroup",
|
|
||||||
"Properties" : {
|
|
||||||
"GroupDescription" : "Enable HTTP access via port 80 plus SSH access",
|
|
||||||
"SecurityGroupIngress" : [
|
|
||||||
{"IpProtocol" : "icmp", "FromPort" : "-1", "ToPort" : "-1", "CidrIp" : "0.0.0.0/0"},
|
|
||||||
{"IpProtocol" : "tcp", "FromPort" : "80", "ToPort" : "80", "CidrIp" : "0.0.0.0/0"},
|
|
||||||
{"IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : "0.0.0.0/0"}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"WikiServer": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"httpd" : [],
|
|
||||||
"mysql" : [],
|
|
||||||
"mysql-server" : [],
|
|
||||||
"wordpress" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services" : {
|
|
||||||
"systemd" : {
|
|
||||||
"httpd" : { "enabled" : "true", "ensureRunning" : "true" },
|
|
||||||
"mysqld" : { "enabled" : "true", "ensureRunning" : "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"SecurityGroups" : [ {"Ref" : "WikiServerSecurityGroup"} ],
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"/opt/aws/bin/cfn-init\n",
|
|
||||||
"# Wait for the volume to appear\n",
|
|
||||||
"while [ ! -e /dev/vdc ]; do echo Waiting for volume to attach; sleep 1; done\n",
|
|
||||||
"parted -s /dev/vdc mklabel msdos\n",
|
|
||||||
"parted -s /dev/vdc mkpart primary ext3 1 1000\n",
|
|
||||||
"# Format the EBS volume and mount it\n",
|
|
||||||
"systemctl stop mysqld.service\n",
|
|
||||||
"sleep 1\n",
|
|
||||||
"mv /var/lib/mysql /var/lib/mysql.data\n",
|
|
||||||
"/sbin/mkfs -t ext3 /dev/vdc1\n",
|
|
||||||
"mkdir /var/lib/mysql\n",
|
|
||||||
"mount /dev/vdc1 /var/lib/mysql\n",
|
|
||||||
"chown mysql.mysql /var/lib/mysql\n",
|
|
||||||
"mv -n /var/lib/mysql.data/* /var/lib/mysql\n",
|
|
||||||
"systemctl start mysqld.service\n",
|
|
||||||
"sleep 1\n",
|
|
||||||
"# Setup MySQL root password and create a user\n",
|
|
||||||
"mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "'\n",
|
|
||||||
"cat << EOF | mysql -u root --password='", { "Ref" : "DBRootPassword" }, "'\n",
|
|
||||||
"CREATE DATABASE ", { "Ref" : "DBName" }, ";\n",
|
|
||||||
"GRANT ALL PRIVILEGES ON ", { "Ref" : "DBName" }, ".* TO \"", { "Ref" : "DBUsername" }, "\"@\"localhost\"\n",
|
|
||||||
"IDENTIFIED BY \"", { "Ref" : "DBPassword" }, "\";\n",
|
|
||||||
"FLUSH PRIVILEGES;\n",
|
|
||||||
"EXIT\n",
|
|
||||||
"EOF\n",
|
|
||||||
"sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed -i \"s/Require local/Require all granted/\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed --in-place --e s/database_name_here/", { "Ref" : "DBName" }, "/ --e s/username_here/", { "Ref" : "DBUsername" }, "/ --e s/password_here/", { "Ref" : "DBPassword" }, "/ /usr/share/wordpress/wp-config.php\n",
|
|
||||||
"systemctl restart httpd.service\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"DataVolume" : {
|
|
||||||
"Type" : "AWS::EC2::Volume",
|
|
||||||
"Properties" : {
|
|
||||||
"Size" : { "Ref" : "VolumeSize" },
|
|
||||||
"AvailabilityZone" : { "Fn::GetAtt" : [ "WikiServer", "AvailabilityZone" ]},
|
|
||||||
"Tags" : [{ "Key" : "Usage", "Value" : "Wiki Data Volume" }]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"MountPoint" : {
|
|
||||||
"Type" : "AWS::EC2::VolumeAttachment",
|
|
||||||
"Properties" : {
|
|
||||||
"InstanceId" : { "Ref" : "WikiServer" },
|
|
||||||
"VolumeId" : { "Ref" : "DataVolume" },
|
|
||||||
"Device" : "/dev/vdc"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"WebsiteURL" : {
|
|
||||||
"Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "WikiServer", "PublicIp" ]}, "/wordpress"]] },
|
|
||||||
"Description" : "URL for Wordpress wiki"
|
|
||||||
},
|
|
||||||
"InstanceIPAddress" : {
|
|
||||||
"Value" : { "Ref" : "IPAddress" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,177 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "AWS CloudFormation Sample Template WordPress_Single_Instance: WordPress is web software you can use to create a beautiful website or blog. This template installs a single-instance WordPress deployment using a local MySQL database to store the data.",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
|
|
||||||
"KeyName" : {
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "WebServer EC2 instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "m1.large",
|
|
||||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBName": {
|
|
||||||
"Default": "wordpress",
|
|
||||||
"Description" : "The WordPress database name",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBUsername": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account username",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "16",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account password",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBRootPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "Root password for MySQL",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Default": "F17",
|
|
||||||
"Description" : "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "32" },
|
|
||||||
"m1.small" : { "Arch" : "32" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "32" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
|
||||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
|
||||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
|
||||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
|
||||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
|
||||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
|
|
||||||
"IPAddress" : {
|
|
||||||
"Type" : "AWS::EC2::EIP"
|
|
||||||
},
|
|
||||||
|
|
||||||
"IPAssoc" : {
|
|
||||||
"Type" : "AWS::EC2::EIPAssociation",
|
|
||||||
"Properties" : {
|
|
||||||
"InstanceId" : { "Ref" : "WebServer" },
|
|
||||||
"EIP" : { "Ref" : "IPAddress" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"WebServerSecurityGroup" : {
|
|
||||||
"Type" : "AWS::EC2::SecurityGroup",
|
|
||||||
"Properties" : {
|
|
||||||
"GroupDescription" : "Enable HTTP access via port 80 plus SSH access",
|
|
||||||
"SecurityGroupIngress" : [
|
|
||||||
{"IpProtocol" : "icmp", "FromPort" : "-1", "ToPort" : "-1", "CidrIp" : "0.0.0.0/0"},
|
|
||||||
{"IpProtocol" : "tcp", "FromPort" : "80", "ToPort" : "80", "CidrIp" : "0.0.0.0/0"},
|
|
||||||
{"IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : "0.0.0.0/0"}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"WebServer": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"httpd" : [],
|
|
||||||
"mysql" : [],
|
|
||||||
"mysql-server" : [],
|
|
||||||
"wordpress" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services" : {
|
|
||||||
"systemd" : {
|
|
||||||
"httpd" : { "enabled" : "true", "ensureRunning" : "true" },
|
|
||||||
"mysqld" : { "enabled" : "true", "ensureRunning" : "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"SecurityGroups" : [ {"Ref" : "WebServerSecurityGroup"} ],
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"/opt/aws/bin/cfn-init\n",
|
|
||||||
"# Setup MySQL root password and create a user\n",
|
|
||||||
"mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "'\n",
|
|
||||||
"cat << EOF | mysql -u root --password='", { "Ref" : "DBRootPassword" }, "'\n",
|
|
||||||
"CREATE DATABASE ", { "Ref" : "DBName" }, ";\n",
|
|
||||||
"GRANT ALL PRIVILEGES ON ", { "Ref" : "DBName" }, ".* TO \"", { "Ref" : "DBUsername" }, "\"@\"localhost\"\n",
|
|
||||||
"IDENTIFIED BY \"", { "Ref" : "DBPassword" }, "\";\n",
|
|
||||||
"FLUSH PRIVILEGES;\n",
|
|
||||||
"EXIT\n",
|
|
||||||
"EOF\n",
|
|
||||||
"sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed -i \"s/Require local/Require all granted/\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed --in-place --e s/database_name_here/", { "Ref" : "DBName" }, "/ --e s/username_here/", { "Ref" : "DBUsername" }, "/ --e s/password_here/", { "Ref" : "DBPassword" }, "/ /usr/share/wordpress/wp-config.php\n",
|
|
||||||
"systemctl restart httpd.service\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"WebsiteURL" : {
|
|
||||||
"Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "WebServer", "PublicIp" ]}, "/wordpress"]] },
|
|
||||||
"Description" : "URL for Wordpress wiki"
|
|
||||||
},
|
|
||||||
"InstanceIPAddress" : {
|
|
||||||
"Value" : { "Ref" : "IPAddress" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,296 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "AWS CloudFormation Sample Template WordPress_Multi_Instance: WordPress is web software you can use to create a beautiful website or blog. This template installs two instances: one running a WordPress deployment and the other using a local MySQL database to store the data.",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
|
|
||||||
"KeyName" : {
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "WebServer EC2 instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "m1.large",
|
|
||||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBName": {
|
|
||||||
"Default": "wordpress",
|
|
||||||
"Description" : "The WordPress database name",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBUsername": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account username",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "16",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account password",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBRootPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "Root password for MySQL",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Default": "F17",
|
|
||||||
"Description" : "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
|
||||||
},
|
|
||||||
"HupPollInterval": {
|
|
||||||
"Default": "1",
|
|
||||||
"Description" : "Interval for cfn-hup",
|
|
||||||
"Type": "String"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "32" },
|
|
||||||
"m1.small" : { "Arch" : "32" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "32" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
|
||||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
|
||||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
|
||||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
|
||||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
|
||||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
"CfnUser" : {
|
|
||||||
"Type" : "AWS::IAM::User"
|
|
||||||
},
|
|
||||||
"WebServerKeys" : {
|
|
||||||
"Type" : "AWS::IAM::AccessKey",
|
|
||||||
"Properties" : {
|
|
||||||
"UserName" : {"Ref": "CfnUser"}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"WebServerRestartPolicy" : {
|
|
||||||
"Type" : "OS::Heat::HARestarter",
|
|
||||||
"Properties" : {
|
|
||||||
"InstanceId" : { "Ref" : "WikiDatabase" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"HttpFailureAlarm": {
|
|
||||||
"Type": "AWS::CloudWatch::Alarm",
|
|
||||||
"Properties": {
|
|
||||||
"AlarmDescription": "Restart the WikiDatabase if httpd fails > 3 times in 10 minutes",
|
|
||||||
"MetricName": "ServiceFailure",
|
|
||||||
"Namespace": "system/linux",
|
|
||||||
"Statistic": "SampleCount",
|
|
||||||
"Period": "300",
|
|
||||||
"EvaluationPeriods": "1",
|
|
||||||
"Threshold": "2",
|
|
||||||
"AlarmActions": [ { "Ref": "WebServerRestartPolicy" } ],
|
|
||||||
"ComparisonOperator": "GreaterThanThreshold"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"WikiDatabase": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"files" : {
|
|
||||||
"/etc/cfn/cfn-credentials" : {
|
|
||||||
"content" : { "Fn::Join" : ["", [
|
|
||||||
"AWSAccessKeyId=", { "Ref" : "WebServerKeys" }, "\n",
|
|
||||||
"AWSSecretKey=", {"Fn::GetAtt": ["WebServerKeys",
|
|
||||||
"SecretAccessKey"]}, "\n"
|
|
||||||
]]},
|
|
||||||
"mode" : "000400",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
},
|
|
||||||
|
|
||||||
"/etc/cfn/cfn-hup.conf" : {
|
|
||||||
"content" : { "Fn::Join" : ["", [
|
|
||||||
"[main]\n",
|
|
||||||
"stack=", { "Ref" : "AWS::StackName" }, "\n",
|
|
||||||
"credential-file=/etc/cfn/cfn-credentials\n",
|
|
||||||
"region=", { "Ref" : "AWS::Region" }, "\n",
|
|
||||||
"interval=", { "Ref" : "HupPollInterval" }, "\n"
|
|
||||||
]]},
|
|
||||||
"mode" : "000400",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
},
|
|
||||||
|
|
||||||
"/etc/cfn/notify-on-httpd-restarted" : {
|
|
||||||
"content" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/sh\n",
|
|
||||||
"/opt/aws/bin/cfn-push-stats --watch ",
|
|
||||||
{ "Ref" : "HttpFailureAlarm" },
|
|
||||||
" --service-failure\n"
|
|
||||||
]]},
|
|
||||||
"mode" : "000700",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
},
|
|
||||||
|
|
||||||
"/tmp/cfn-hup-crontab.txt" : {
|
|
||||||
"content" : { "Fn::Join" : ["", [
|
|
||||||
"MAIL=\"\"\n",
|
|
||||||
"\n",
|
|
||||||
"* * * * * /opt/aws/bin/cfn-hup -f\n"
|
|
||||||
]]},
|
|
||||||
"mode" : "000600",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
},
|
|
||||||
|
|
||||||
"/tmp/setup.mysql" : {
|
|
||||||
"content" : { "Fn::Join" : ["", [
|
|
||||||
"CREATE DATABASE ", { "Ref" : "DBName" }, ";\n",
|
|
||||||
"GRANT ALL PRIVILEGES ON ", { "Ref" : "DBName" },
|
|
||||||
".* TO '", { "Ref" : "DBUsername" }, "'@'localhost'\n",
|
|
||||||
"IDENTIFIED BY '", { "Ref" : "DBPassword" }, "';\n",
|
|
||||||
"FLUSH PRIVILEGES;\n",
|
|
||||||
"EXIT\n"
|
|
||||||
]]},
|
|
||||||
"mode" : "000644",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
},
|
|
||||||
|
|
||||||
"/etc/cfn/hooks.conf" : {
|
|
||||||
"content": { "Fn::Join" : ["", [
|
|
||||||
"[cfn-http-restarted]\n",
|
|
||||||
"triggers=service.restarted\n",
|
|
||||||
"path=Resources.WikiDatabase.Metadata\n",
|
|
||||||
"action=/etc/cfn/notify-on-httpd-restarted\n",
|
|
||||||
"runas=root\n"
|
|
||||||
]]},
|
|
||||||
"mode" : "000400",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"cronie" : [],
|
|
||||||
"mysql" : [],
|
|
||||||
"mysql-server" : [],
|
|
||||||
"httpd" : [],
|
|
||||||
"wordpress" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services" : {
|
|
||||||
"systemd" : {
|
|
||||||
"mysqld" : { "enabled" : "true", "ensureRunning" : "true" },
|
|
||||||
"httpd" : { "enabled" : "true", "ensureRunning" : "true" },
|
|
||||||
"crond" : { "enabled" : "true", "ensureRunning" : "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"# Helper function\n",
|
|
||||||
"function error_exit\n",
|
|
||||||
"{\n",
|
|
||||||
" /opt/aws/bin/cfn-signal -e 1 -r \"$1\" '", { "Ref" : "WaitHandle" }, "'\n",
|
|
||||||
" exit 1\n",
|
|
||||||
"}\n",
|
|
||||||
|
|
||||||
"/opt/aws/bin/cfn-init -s ", { "Ref" : "AWS::StackName" },
|
|
||||||
" -r WikiDatabase ",
|
|
||||||
" --access-key ", { "Ref" : "WebServerKeys" },
|
|
||||||
" --secret-key ", {"Fn::GetAtt": ["WebServerKeys", "SecretAccessKey"]},
|
|
||||||
" --region ", { "Ref" : "AWS::Region" },
|
|
||||||
" || error_exit 'Failed to run cfn-init'\n",
|
|
||||||
|
|
||||||
"# Setup MySQL root password and create a user\n",
|
|
||||||
"mysqladmin -u root password '", { "Ref" : "DBRootPassword" },
|
|
||||||
"' || error_exit 'Failed to initialize root password'\n",
|
|
||||||
|
|
||||||
"mysql -u root --password='", { "Ref" : "DBRootPassword" },
|
|
||||||
"' < /tmp/setup.mysql || error_exit 'Failed to create database.'\n",
|
|
||||||
|
|
||||||
"sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed -i \"s/Require local/Require all granted/\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed --in-place --e s/database_name_here/", { "Ref" : "DBName" },
|
|
||||||
"/ --e s/username_here/", { "Ref" : "DBUsername" },
|
|
||||||
"/ --e s/password_here/", { "Ref" : "DBPassword" },
|
|
||||||
"/ /usr/share/wordpress/wp-config.php\n",
|
|
||||||
|
|
||||||
"systemctl restart httpd.service\n",
|
|
||||||
|
|
||||||
"# install cfn-hup crontab\n",
|
|
||||||
"crontab /tmp/cfn-hup-crontab.txt\n",
|
|
||||||
|
|
||||||
"# All is well so signal success\n",
|
|
||||||
"/opt/aws/bin/cfn-signal -e 0 -r \"Wiki server setup complete\" '",
|
|
||||||
{ "Ref" : "WaitHandle" }, "'\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"WaitHandle" : {
|
|
||||||
"Type" : "AWS::CloudFormation::WaitConditionHandle"
|
|
||||||
},
|
|
||||||
|
|
||||||
"WaitCondition" : {
|
|
||||||
"Type" : "AWS::CloudFormation::WaitCondition",
|
|
||||||
"DependsOn" : "WikiDatabase",
|
|
||||||
"Properties" : {
|
|
||||||
"Handle" : {"Ref" : "WaitHandle"},
|
|
||||||
"Count" : "1",
|
|
||||||
"Timeout" : "600"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"WebsiteURL" : {
|
|
||||||
"Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "WikiDatabase", "PublicIp" ]}, "/wordpress"]] },
|
|
||||||
"Description" : "URL for Wordpress wiki"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,305 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "AWS CloudFormation Sample Template WordPress_Multi_Instance: WordPress is web software you can use to create a beautiful website or blog. This template installs two instances: one running a WordPress deployment and the other using a local MySQL database to store the data.",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
|
|
||||||
"KeyName" : {
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "WebServer EC2 instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "m1.large",
|
|
||||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBName": {
|
|
||||||
"Default": "wordpress",
|
|
||||||
"Description" : "The WordPress database name",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBUsername": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account username",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "16",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account password",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBRootPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "Root password for MySQL",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Default": "F17",
|
|
||||||
"Description" : "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
|
||||||
},
|
|
||||||
"HupPollInterval": {
|
|
||||||
"Default": "1",
|
|
||||||
"Description" : "Interval for cfn-hup",
|
|
||||||
"Type": "String"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "32" },
|
|
||||||
"m1.small" : { "Arch" : "32" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "32" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
|
||||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
|
||||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
|
||||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
|
||||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
|
||||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
"CfnUser" : {
|
|
||||||
"Type" : "AWS::IAM::User",
|
|
||||||
"Properties" : {
|
|
||||||
"Policies" : [ { "Ref": "WebServerAccessPolicy"} ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"WebServerAccessPolicy" : {
|
|
||||||
"Type" : "OS::Heat::AccessPolicy",
|
|
||||||
"Properties" : {
|
|
||||||
"AllowedResources" : [ "WikiDatabase" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"WebServerKeys" : {
|
|
||||||
"Type" : "AWS::IAM::AccessKey",
|
|
||||||
"Properties" : {
|
|
||||||
"UserName" : {"Ref": "CfnUser"}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"WebServerRestartPolicy" : {
|
|
||||||
"Type" : "OS::Heat::HARestarter",
|
|
||||||
"Properties" : {
|
|
||||||
"InstanceId" : { "Ref" : "WikiDatabase" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"HttpFailureAlarm": {
|
|
||||||
"Type": "AWS::CloudWatch::Alarm",
|
|
||||||
"Properties": {
|
|
||||||
"AlarmDescription": "Restart the WikiDatabase if httpd fails > 3 times in 10 minutes",
|
|
||||||
"MetricName": "ServiceFailure",
|
|
||||||
"Namespace": "system/linux",
|
|
||||||
"Statistic": "SampleCount",
|
|
||||||
"Period": "300",
|
|
||||||
"EvaluationPeriods": "1",
|
|
||||||
"Threshold": "2",
|
|
||||||
"AlarmActions": [ { "Ref": "WebServerRestartPolicy" } ],
|
|
||||||
"ComparisonOperator": "GreaterThanThreshold"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"WikiDatabase": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"files" : {
|
|
||||||
"/etc/cfn/cfn-credentials" : {
|
|
||||||
"content" : { "Fn::Join" : ["", [
|
|
||||||
"AWSAccessKeyId=", { "Ref" : "WebServerKeys" }, "\n",
|
|
||||||
"AWSSecretKey=", {"Fn::GetAtt": ["WebServerKeys",
|
|
||||||
"SecretAccessKey"]}, "\n"
|
|
||||||
]]},
|
|
||||||
"mode" : "000400",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
},
|
|
||||||
|
|
||||||
"/etc/cfn/cfn-hup.conf" : {
|
|
||||||
"content" : { "Fn::Join" : ["", [
|
|
||||||
"[main]\n",
|
|
||||||
"stack=", { "Ref" : "AWS::StackName" }, "\n",
|
|
||||||
"credential-file=/etc/cfn/cfn-credentials\n",
|
|
||||||
"region=", { "Ref" : "AWS::Region" }, "\n",
|
|
||||||
"interval=", { "Ref" : "HupPollInterval" }, "\n"
|
|
||||||
]]},
|
|
||||||
"mode" : "000400",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
},
|
|
||||||
|
|
||||||
"/etc/cfn/notify-on-httpd-restarted" : {
|
|
||||||
"content" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/sh\n",
|
|
||||||
"/opt/aws/bin/cfn-push-stats --watch ",
|
|
||||||
{ "Ref" : "HttpFailureAlarm" },
|
|
||||||
" --service-failure\n"
|
|
||||||
]]},
|
|
||||||
"mode" : "000700",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
},
|
|
||||||
|
|
||||||
"/tmp/cfn-hup-crontab.txt" : {
|
|
||||||
"content" : { "Fn::Join" : ["", [
|
|
||||||
"MAIL=\"\"\n",
|
|
||||||
"\n",
|
|
||||||
"* * * * * /opt/aws/bin/cfn-hup -f\n"
|
|
||||||
]]},
|
|
||||||
"mode" : "000600",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
},
|
|
||||||
|
|
||||||
"/tmp/setup.mysql" : {
|
|
||||||
"content" : { "Fn::Join" : ["", [
|
|
||||||
"CREATE DATABASE ", { "Ref" : "DBName" }, ";\n",
|
|
||||||
"GRANT ALL PRIVILEGES ON ", { "Ref" : "DBName" },
|
|
||||||
".* TO '", { "Ref" : "DBUsername" }, "'@'localhost'\n",
|
|
||||||
"IDENTIFIED BY '", { "Ref" : "DBPassword" }, "';\n",
|
|
||||||
"FLUSH PRIVILEGES;\n",
|
|
||||||
"EXIT\n"
|
|
||||||
]]},
|
|
||||||
"mode" : "000644",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
},
|
|
||||||
|
|
||||||
"/etc/cfn/hooks.conf" : {
|
|
||||||
"content": { "Fn::Join" : ["", [
|
|
||||||
"[cfn-http-restarted]\n",
|
|
||||||
"triggers=service.restarted\n",
|
|
||||||
"path=Resources.WikiDatabase.Metadata\n",
|
|
||||||
"action=/etc/cfn/notify-on-httpd-restarted\n",
|
|
||||||
"runas=root\n"
|
|
||||||
]]},
|
|
||||||
"mode" : "000400",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"cronie" : [],
|
|
||||||
"mysql" : [],
|
|
||||||
"mysql-server" : [],
|
|
||||||
"httpd" : [],
|
|
||||||
"wordpress" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services" : {
|
|
||||||
"systemd" : {
|
|
||||||
"mysqld" : { "enabled" : "true", "ensureRunning" : "true" },
|
|
||||||
"httpd" : { "enabled" : "true", "ensureRunning" : "true" },
|
|
||||||
"crond" : { "enabled" : "true", "ensureRunning" : "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"# Helper function\n",
|
|
||||||
"function error_exit\n",
|
|
||||||
"{\n",
|
|
||||||
" /opt/aws/bin/cfn-signal -e 1 -r \"$1\" '", { "Ref" : "WaitHandle" }, "'\n",
|
|
||||||
" exit 1\n",
|
|
||||||
"}\n",
|
|
||||||
|
|
||||||
"/opt/aws/bin/cfn-init -s ", { "Ref" : "AWS::StackName" },
|
|
||||||
" -r WikiDatabase ",
|
|
||||||
" --access-key ", { "Ref" : "WebServerKeys" },
|
|
||||||
" --secret-key ", {"Fn::GetAtt": ["WebServerKeys", "SecretAccessKey"]},
|
|
||||||
" --region ", { "Ref" : "AWS::Region" },
|
|
||||||
" || error_exit 'Failed to run cfn-init'\n",
|
|
||||||
|
|
||||||
"# Setup MySQL root password and create a user\n",
|
|
||||||
"mysqladmin -u root password '", { "Ref" : "DBRootPassword" },
|
|
||||||
"' || error_exit 'Failed to initialize root password'\n",
|
|
||||||
|
|
||||||
"mysql -u root --password='", { "Ref" : "DBRootPassword" },
|
|
||||||
"' < /tmp/setup.mysql || error_exit 'Failed to create database.'\n",
|
|
||||||
|
|
||||||
"sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed -i \"s/Require local/Require all granted/\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed --in-place --e s/database_name_here/", { "Ref" : "DBName" },
|
|
||||||
"/ --e s/username_here/", { "Ref" : "DBUsername" },
|
|
||||||
"/ --e s/password_here/", { "Ref" : "DBPassword" },
|
|
||||||
"/ /usr/share/wordpress/wp-config.php\n",
|
|
||||||
|
|
||||||
"systemctl restart httpd.service\n",
|
|
||||||
|
|
||||||
"# install cfn-hup crontab\n",
|
|
||||||
"crontab /tmp/cfn-hup-crontab.txt\n",
|
|
||||||
|
|
||||||
"# All is well so signal success\n",
|
|
||||||
"/opt/aws/bin/cfn-signal -e 0 -r \"Wiki server setup complete\" '",
|
|
||||||
{ "Ref" : "WaitHandle" }, "'\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"WaitHandle" : {
|
|
||||||
"Type" : "AWS::CloudFormation::WaitConditionHandle"
|
|
||||||
},
|
|
||||||
|
|
||||||
"WaitCondition" : {
|
|
||||||
"Type" : "AWS::CloudFormation::WaitCondition",
|
|
||||||
"DependsOn" : "WikiDatabase",
|
|
||||||
"Properties" : {
|
|
||||||
"Handle" : {"Ref" : "WaitHandle"},
|
|
||||||
"Count" : "1",
|
|
||||||
"Timeout" : "600"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"WebsiteURL" : {
|
|
||||||
"Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "WikiDatabase", "PublicIp" ]}, "/wordpress"]] },
|
|
||||||
"Description" : "URL for Wordpress wiki"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,270 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "AWS CloudFormation Sample Template WordPress_Multi_Instance: WordPress is web software you can use to create a beautiful website or blog. This template installs two instances: one running a WordPress deployment and the other using a local MySQL database to store the data.",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
|
|
||||||
"KeyName" : {
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "WebServer EC2 instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "m1.large",
|
|
||||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBName": {
|
|
||||||
"Default": "wordpress",
|
|
||||||
"Description" : "The WordPress database name",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBUsername": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account username",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "16",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account password",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBRootPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "Root password for MySQL",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Default": "F17",
|
|
||||||
"Description" : "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
|
||||||
},
|
|
||||||
"HupPollInterval": {
|
|
||||||
"Default": "1",
|
|
||||||
"Description" : "Interval for cfn-hup",
|
|
||||||
"Type": "String"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "32" },
|
|
||||||
"m1.small" : { "Arch" : "32" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "32" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
|
||||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
|
||||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
|
||||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
|
||||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
|
||||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
"CfnUser" : {
|
|
||||||
"Type" : "AWS::IAM::User"
|
|
||||||
},
|
|
||||||
"WebServerKeys" : {
|
|
||||||
"Type" : "AWS::IAM::AccessKey",
|
|
||||||
"Properties" : {
|
|
||||||
"UserName" : {"Ref": "CfnUser"}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"WebServerRestartPolicy" : {
|
|
||||||
"Type" : "OS::Heat::HARestarter",
|
|
||||||
"Properties" : {
|
|
||||||
"InstanceId" : { "Ref" : "WikiDatabase" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"HeartbeatFailureAlarm": {
|
|
||||||
"Type": "AWS::CloudWatch::Alarm",
|
|
||||||
"DependsOn" : "WaitCondition",
|
|
||||||
"Properties": {
|
|
||||||
"AlarmDescription": "Restart the WikiDatabase if we miss a heartbeat",
|
|
||||||
"MetricName": "Heartbeat",
|
|
||||||
"Namespace": "system/linux",
|
|
||||||
"Statistic": "SampleCount",
|
|
||||||
"Period": "60",
|
|
||||||
"EvaluationPeriods": "1",
|
|
||||||
"Threshold": "1",
|
|
||||||
"AlarmActions": [ { "Ref": "WebServerRestartPolicy" } ],
|
|
||||||
"ComparisonOperator": "LessThanThreshold"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"WikiDatabase": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"files" : {
|
|
||||||
"/etc/cfn/cfn-credentials" : {
|
|
||||||
"content" : { "Fn::Join" : ["", [
|
|
||||||
"AWSAccessKeyId=", { "Ref" : "WebServerKeys" }, "\n",
|
|
||||||
"AWSSecretKey=", {"Fn::GetAtt": ["WebServerKeys",
|
|
||||||
"SecretAccessKey"]}, "\n"
|
|
||||||
]]},
|
|
||||||
"mode" : "000400",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
},
|
|
||||||
"/etc/cfn/cfn-hup.conf" : {
|
|
||||||
"content" : { "Fn::Join" : ["", [
|
|
||||||
"[main]\n",
|
|
||||||
"stack=", { "Ref" : "AWS::StackName" }, "\n",
|
|
||||||
"credential-file=/etc/cfn/cfn-credentials\n",
|
|
||||||
"region=", { "Ref" : "AWS::Region" }, "\n",
|
|
||||||
"interval=", { "Ref" : "HupPollInterval" }, "\n"
|
|
||||||
]]},
|
|
||||||
"mode" : "000400",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
},
|
|
||||||
"/tmp/cfn-hup-crontab.txt" : {
|
|
||||||
"content" : { "Fn::Join" : ["", [
|
|
||||||
"MAIL=\"\"\n",
|
|
||||||
"\n",
|
|
||||||
"* * * * * /opt/aws/bin/cfn-hup -f\n",
|
|
||||||
"* * * * * /opt/aws/bin/cfn-push-stats ",
|
|
||||||
" --watch ", { "Ref" : "HeartbeatFailureAlarm" },
|
|
||||||
" --heartbeat\n"
|
|
||||||
]]},
|
|
||||||
"mode" : "000600",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
},
|
|
||||||
|
|
||||||
"/tmp/setup.mysql" : {
|
|
||||||
"content" : { "Fn::Join" : ["", [
|
|
||||||
"CREATE DATABASE ", { "Ref" : "DBName" }, ";\n",
|
|
||||||
"GRANT ALL PRIVILEGES ON ", { "Ref" : "DBName" },
|
|
||||||
".* TO '", { "Ref" : "DBUsername" }, "'@'localhost'\n",
|
|
||||||
"IDENTIFIED BY '", { "Ref" : "DBPassword" }, "';\n",
|
|
||||||
"FLUSH PRIVILEGES;\n",
|
|
||||||
"EXIT\n"
|
|
||||||
]]},
|
|
||||||
"mode" : "000644",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"cronie" : [],
|
|
||||||
"mysql" : [],
|
|
||||||
"mysql-server" : [],
|
|
||||||
"httpd" : [],
|
|
||||||
"wordpress" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services" : {
|
|
||||||
"systemd" : {
|
|
||||||
"mysqld" : { "enabled" : "true", "ensureRunning" : "true" },
|
|
||||||
"httpd" : { "enabled" : "true", "ensureRunning" : "true" },
|
|
||||||
"crond" : { "enabled" : "true", "ensureRunning" : "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"# Helper function\n",
|
|
||||||
"function error_exit\n",
|
|
||||||
"{\n",
|
|
||||||
" /opt/aws/bin/cfn-signal -e 1 -r \"$1\" '", { "Ref" : "WaitHandle" }, "'\n",
|
|
||||||
" exit 1\n",
|
|
||||||
"}\n",
|
|
||||||
|
|
||||||
"/opt/aws/bin/cfn-init -s ", { "Ref" : "AWS::StackName" },
|
|
||||||
" -r WikiDatabase ",
|
|
||||||
" --region ", { "Ref" : "AWS::Region" },
|
|
||||||
" || error_exit 'Failed to run cfn-init'\n",
|
|
||||||
|
|
||||||
"# Setup MySQL root password and create a user\n",
|
|
||||||
"mysqladmin -u root password '", { "Ref" : "DBRootPassword" },
|
|
||||||
"' || error_exit 'Failed to initialize root password'\n",
|
|
||||||
|
|
||||||
"mysql -u root --password='", { "Ref" : "DBRootPassword" },
|
|
||||||
"' < /tmp/setup.mysql || error_exit 'Failed to create database.'\n",
|
|
||||||
|
|
||||||
"sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed -i \"s/Require local/Require all granted/\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed --in-place --e s/database_name_here/", { "Ref" : "DBName" },
|
|
||||||
"/ --e s/username_here/", { "Ref" : "DBUsername" },
|
|
||||||
"/ --e s/password_here/", { "Ref" : "DBPassword" },
|
|
||||||
"/ /usr/share/wordpress/wp-config.php\n",
|
|
||||||
|
|
||||||
"systemctl restart httpd.service\n",
|
|
||||||
|
|
||||||
"# install cfn-hup crontab\n",
|
|
||||||
"crontab /tmp/cfn-hup-crontab.txt\n",
|
|
||||||
|
|
||||||
"# All is well so signal success\n",
|
|
||||||
"/opt/aws/bin/cfn-signal -e 0 -r \"Wiki server setup complete\" '",
|
|
||||||
{ "Ref" : "WaitHandle" }, "'\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"WaitHandle" : {
|
|
||||||
"Type" : "AWS::CloudFormation::WaitConditionHandle"
|
|
||||||
},
|
|
||||||
|
|
||||||
"WaitCondition" : {
|
|
||||||
"Type" : "AWS::CloudFormation::WaitCondition",
|
|
||||||
"DependsOn" : "WikiDatabase",
|
|
||||||
"Properties" : {
|
|
||||||
"Handle" : {"Ref" : "WaitHandle"},
|
|
||||||
"Timeout" : "600"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"WebsiteURL" : {
|
|
||||||
"Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "WikiDatabase", "PublicIp" ]}, "/wordpress"]] },
|
|
||||||
"Description" : "URL for Wordpress wiki"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,192 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "AWS CloudFormation Sample Template WordPress_Single_Instance: WordPress is web software you can use to create a beautiful website or blog. This template installs a single-instance WordPress deployment using a local MySQL database to store the data.",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
|
|
||||||
"KeyName" : {
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "WebServer EC2 instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "m1.large",
|
|
||||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBName": {
|
|
||||||
"Default": "wordpress",
|
|
||||||
"Description" : "The WordPress database name",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBUsername": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account username",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "16",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account password",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBRootPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "Root password for MySQL",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Default": "F17",
|
|
||||||
"Description" : "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "32" },
|
|
||||||
"m1.small" : { "Arch" : "32" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "32" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
|
||||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
|
||||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
|
||||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
|
||||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
|
||||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
|
|
||||||
"network": {
|
|
||||||
"Type": "OS::Quantum::Net"
|
|
||||||
},
|
|
||||||
|
|
||||||
"subnet": {
|
|
||||||
"Type": "OS::Quantum::Subnet",
|
|
||||||
"Properties": {
|
|
||||||
"network_id": { "Ref" : "network" },
|
|
||||||
"ip_version": 4,
|
|
||||||
"cidr": "10.0.1.0/24",
|
|
||||||
"allocation_pools": [{"start": "10.0.1.2", "end": "10.0.1.150"}]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"port": {
|
|
||||||
"Type": "OS::Quantum::Port",
|
|
||||||
"Properties": {
|
|
||||||
"device_id": { "Ref" : "WebServer" },
|
|
||||||
"network_id": { "Ref" : "network" },
|
|
||||||
"fixed_ips": [{
|
|
||||||
"subnet_id": { "Ref" : "subnet" },
|
|
||||||
"ip_address": "10.0.1.2"
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"WebServerSecurityGroup" : {
|
|
||||||
"Type" : "AWS::EC2::SecurityGroup",
|
|
||||||
"Properties" : {
|
|
||||||
"GroupDescription" : "Enable HTTP access via port 80 plus SSH access",
|
|
||||||
"SecurityGroupIngress" : [
|
|
||||||
{"IpProtocol" : "icmp", "FromPort" : "-1", "ToPort" : "-1", "CidrIp" : "0.0.0.0/0"},
|
|
||||||
{"IpProtocol" : "tcp", "FromPort" : "80", "ToPort" : "80", "CidrIp" : "0.0.0.0/0"},
|
|
||||||
{"IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : "0.0.0.0/0"}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"WebServer": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"httpd" : [],
|
|
||||||
"mysql" : [],
|
|
||||||
"mysql-server" : [],
|
|
||||||
"wordpress" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services" : {
|
|
||||||
"systemd" : {
|
|
||||||
"httpd" : { "enabled" : "true", "ensureRunning" : "true" },
|
|
||||||
"mysqld" : { "enabled" : "true", "ensureRunning" : "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"SecurityGroups" : [ {"Ref" : "WebServerSecurityGroup"} ],
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"/opt/aws/bin/cfn-init\n",
|
|
||||||
"# Setup MySQL root password and create a user\n",
|
|
||||||
"mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "'\n",
|
|
||||||
"cat << EOF | mysql -u root --password='", { "Ref" : "DBRootPassword" }, "'\n",
|
|
||||||
"CREATE DATABASE ", { "Ref" : "DBName" }, ";\n",
|
|
||||||
"GRANT ALL PRIVILEGES ON ", { "Ref" : "DBName" }, ".* TO \"", { "Ref" : "DBUsername" }, "\"@\"localhost\"\n",
|
|
||||||
"IDENTIFIED BY \"", { "Ref" : "DBPassword" }, "\";\n",
|
|
||||||
"FLUSH PRIVILEGES;\n",
|
|
||||||
"EXIT\n",
|
|
||||||
"EOF\n",
|
|
||||||
"sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed -i \"s/Require local/Require all granted/\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed --in-place --e s/database_name_here/", { "Ref" : "DBName" }, "/ --e s/username_here/", { "Ref" : "DBUsername" }, "/ --e s/password_here/", { "Ref" : "DBPassword" }, "/ /usr/share/wordpress/wp-config.php\n",
|
|
||||||
"systemctl restart httpd.service\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"WebsiteURL" : {
|
|
||||||
"Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "WebServer", "PublicIp" ]}, "/wordpress"]] },
|
|
||||||
"Description" : "URL for Wordpress wiki"
|
|
||||||
},
|
|
||||||
"InstanceIPAddress" : {
|
|
||||||
"Value" : { "Ref" : "IPAddress" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,138 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "AWS CloudFormation Sample Template WordPress_Single_Instance: WordPress is web software you can use to create a beautiful website or blog. This template installs a single-instance WordPress deployment using a local MySQL database to store the data.",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
|
|
||||||
"KeyName" : {
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "WebServer EC2 instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "m1.large",
|
|
||||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBName": {
|
|
||||||
"Default": "wordpress",
|
|
||||||
"Description" : "The WordPress database name",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBUsername": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account username",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "16",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account password",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBRootPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "Root password for MySQL",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Default": "U10",
|
|
||||||
"Description" : "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues" : "U10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "32" },
|
|
||||||
"m1.small" : { "Arch" : "32" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "32" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
"WebServer": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"services" : {
|
|
||||||
"sysvinit" : {
|
|
||||||
"mysql" : { "enabled" : "true", "ensureRunning" : "true" },
|
|
||||||
"apache2" : { "enabled" : "true", "ensureRunning" : "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"apt-get -y update\n",
|
|
||||||
"apt-get -y install apache2\n",
|
|
||||||
"apt-get -y install wordpress\n",
|
|
||||||
"echo mysql-server mysql-server/root_password select ", { "Ref" : "DBPassword" }, " | debconf-set-selections\n",
|
|
||||||
"echo mysql-server mysql-server/root_password_again select ", { "Ref" : "DBPassword" }, " | debconf-set-selections\n",
|
|
||||||
"apt-get -y install mysql-server\n",
|
|
||||||
"cat > /etc/apache2/conf.d/wordpress.conf <<EOF\n",
|
|
||||||
"Alias /wordpress /usr/share/wordpress\n",
|
|
||||||
"<Directory /usr/share/wordpress>\n",
|
|
||||||
" AllowOverride Options\n",
|
|
||||||
"</Directory>\n",
|
|
||||||
"EOF\n",
|
|
||||||
"/opt/aws/bin/cfn-init\n",
|
|
||||||
"bash /usr/share/doc/wordpress/examples/setup-mysql -n ", { "Ref" : "DBName" }, " 127.0.0.1\n",
|
|
||||||
"mv /etc/wordpress/config-127.0.0.1.php /etc/wordpress/config-`hostname -i`.php\n",
|
|
||||||
"service apache2 restart\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"WebsiteURL" : {
|
|
||||||
"Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "WebServer", "PublicIp" ]}, "/wordpress"]] },
|
|
||||||
"Description" : "URL for Wordpress wiki"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,150 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "AWS CloudFormation Sample Template WordPress_Single_Instance: WordPress is web software you can use to create a beautiful website or blog. This template installs a single-instance WordPress deployment using a local MySQL database to store the data.",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
|
|
||||||
"KeyName" : {
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "WebServer EC2 instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "m1.large",
|
|
||||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBName": {
|
|
||||||
"Default": "wordpress",
|
|
||||||
"Description" : "The WordPress database name",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBUsername": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account username",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "16",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account password",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBRootPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "Root password for MySQL",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Default": "F17",
|
|
||||||
"Description" : "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "32" },
|
|
||||||
"m1.small" : { "Arch" : "32" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "32" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"F18" : { "32" : "F18-i386-gold", "64" : "F18-x86_64-gold" },
|
|
||||||
"F17" : { "32" : "F17-i386-gold", "64" : "F17-x86_64-gold" },
|
|
||||||
"U10" : { "32" : "U10-i386-gold", "64" : "U10-x86_64-gold" },
|
|
||||||
"RHEL-6.1" : { "32" : "rhel61-i386-gold", "64" : "rhel61-x86_64-gold" },
|
|
||||||
"RHEL-6.2" : { "32" : "rhel62-i386-gold", "64" : "rhel62-x86_64-gold" },
|
|
||||||
"RHEL-6.3" : { "32" : "rhel63-i386-gold", "64" : "rhel63-x86_64-gold" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
|
|
||||||
"WebServer": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"httpd" : [],
|
|
||||||
"mysql" : [],
|
|
||||||
"mysql-server" : [],
|
|
||||||
"wordpress" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services" : {
|
|
||||||
"systemd" : {
|
|
||||||
"httpd" : { "enabled" : "true", "ensureRunning" : "true" },
|
|
||||||
"mysqld" : { "enabled" : "true", "ensureRunning" : "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"# Setup MySQL root password and create a user\n",
|
|
||||||
"mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "'\n",
|
|
||||||
"cat >> /tmp/mysql-wordpress-config << EOF\n",
|
|
||||||
"CREATE DATABASE ", { "Ref" : "DBName" }, ";\n",
|
|
||||||
"GRANT ALL PRIVILEGES ON ", { "Ref" : "DBName" }, ".* TO \"", { "Ref" : "DBUsername" }, "\"@\"localhost\"\n",
|
|
||||||
"IDENTIFIED BY \"", { "Ref" : "DBPassword" }, "\";\n",
|
|
||||||
"FLUSH PRIVILEGES;\n",
|
|
||||||
"EXIT\n",
|
|
||||||
"EOF\n",
|
|
||||||
"cat /tmp/mysql-wordpress-config | mysql -u root --password='", { "Ref" : "DBRootPassword" }, "' < /tmp/mysql-wordpress-config\n",
|
|
||||||
"sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed -i \"s/Require local/Require all granted/\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed --in-place --e s/database_name_here/", { "Ref" : "DBName" }, "/ --e s/username_here/", { "Ref" : "DBUsername" }, "/ --e s/password_here/", { "Ref" : "DBPassword" }, "/ /usr/share/wordpress/wp-config.php\n",
|
|
||||||
"cp /usr/share/wordpress/wp-config.php /usr/share/wordpress/wp-config.orig\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"WebsiteURL" : {
|
|
||||||
"Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "WebServer", "PublicIp" ]}, "/wordpress"]] },
|
|
||||||
"Description" : "URL for Wordpress wiki"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,234 +0,0 @@
|
|||||||
{
|
|
||||||
"TemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description": "Sample template to bring up WordPress using the Puppet client to install server roles. A WaitCondition is used to hold up the stack creation until the application is deployed. **WARNING** This template creates one or more Amazon EC2 instances and CloudWatch alarms. You will be billed for the AWS resources used if you create a stack from this template.",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
"KeyName": {
|
|
||||||
"Type": "String",
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the web server"
|
|
||||||
},
|
|
||||||
"PuppetClientSecurityGroup": {
|
|
||||||
"Description" : "The EC2 security group for the instances",
|
|
||||||
"Type": "String"
|
|
||||||
},
|
|
||||||
"PuppetMasterDNSName": {
|
|
||||||
"Description" : "The PuppetMaster DNS name",
|
|
||||||
"Type": "String"
|
|
||||||
},
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "WebServer EC2 instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "m1.small",
|
|
||||||
"AllowedValues" : [ "t1.micro","m1.small","m1.medium","m1.large","m1.xlarge","m2.xlarge","m2.2xlarge","m2.4xlarge","c1.medium","c1.xlarge","cc1.4xlarge","cc2.8xlarge","cg1.4xlarge"],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
"DatabaseType": {
|
|
||||||
"Default": "db.m1.small",
|
|
||||||
"Description" : "The database instance type",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues" : [ "db.m1.small", "db.m1.large", "db.m1.xlarge", "db.m2.xlarge", "db.m2.2xlarge", "db.m2.4xlarge" ],
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
"DatabaseUser": {
|
|
||||||
"Default" : "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Type": "String",
|
|
||||||
"Description" : "Test database admin account name",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "16",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
"DatabasePassword": {
|
|
||||||
"Default" : "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Type": "String",
|
|
||||||
"Description" : "Test database admin account password",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "64" },
|
|
||||||
"m1.small" : { "Arch" : "64" },
|
|
||||||
"m1.medium" : { "Arch" : "64" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "64" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64HVM" },
|
|
||||||
"cc2.8xlarge" : { "Arch" : "64HVM" },
|
|
||||||
"cg1.4xlarge" : { "Arch" : "64HVM" }
|
|
||||||
},
|
|
||||||
|
|
||||||
"AWSRegionArch2AMI" : {
|
|
||||||
"us-east-1" : { "32" : "ami-31814f58", "64" : "ami-1b814f72", "64HVM" : "ami-0da96764" },
|
|
||||||
"us-west-2" : { "32" : "ami-38fe7308", "64" : "ami-30fe7300", "64HVM" : "NOT_YET_SUPPORTED" },
|
|
||||||
"us-west-1" : { "32" : "ami-11d68a54", "64" : "ami-1bd68a5e", "64HVM" : "NOT_YET_SUPPORTED" },
|
|
||||||
"eu-west-1" : { "32" : "ami-973b06e3", "64" : "ami-953b06e1", "64HVM" : "NOT_YET_SUPPORTED" },
|
|
||||||
"ap-southeast-1" : { "32" : "ami-b4b0cae6", "64" : "ami-beb0caec", "64HVM" : "NOT_YET_SUPPORTED" },
|
|
||||||
"ap-northeast-1" : { "32" : "ami-0644f007", "64" : "ami-0a44f00b", "64HVM" : "NOT_YET_SUPPORTED" },
|
|
||||||
"sa-east-1" : { "32" : "ami-3e3be423", "64" : "ami-3c3be421", "64HVM" : "NOT_YET_SUPPORTED" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
|
|
||||||
"CFNInitUser" : {
|
|
||||||
"Type" : "AWS::IAM::User"
|
|
||||||
},
|
|
||||||
|
|
||||||
"CFNKeys" : {
|
|
||||||
"Type" : "AWS::IAM::AccessKey",
|
|
||||||
"Properties" : {
|
|
||||||
"UserName" : { "Ref": "CFNInitUser" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"WebServer": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"puppet" : [],
|
|
||||||
"ruby-devel" : [],
|
|
||||||
"gcc" : [],
|
|
||||||
"make" : [],
|
|
||||||
"rubygems" : []
|
|
||||||
},
|
|
||||||
"rubygems" : {
|
|
||||||
"json" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"files" : {
|
|
||||||
"/etc/yum.repos.d/epel.repo" : {
|
|
||||||
"source" : "https://s3.amazonaws.com/cloudformation-examples/enable-epel-on-amazon-linux-ami",
|
|
||||||
"mode" : "000644",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
},
|
|
||||||
"/etc/puppet/puppet.conf" : {
|
|
||||||
"content" : { "Fn::Join" : ["", [
|
|
||||||
"[main]\n",
|
|
||||||
" logdir=/var/log/puppet\n",
|
|
||||||
" rundir=/var/run/puppet\n",
|
|
||||||
" ssldir=$vardir/ssl\n",
|
|
||||||
" pluginsync=true\n",
|
|
||||||
"[agent]\n",
|
|
||||||
" classfile=$vardir/classes.txt\n",
|
|
||||||
" localconfig=$vardir/localconfig\n",
|
|
||||||
" server=",{ "Ref" : "PuppetMasterDNSName" },"\n"
|
|
||||||
]] },
|
|
||||||
"mode" : "000644",
|
|
||||||
"owner" : "root",
|
|
||||||
"group" : "root"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services" : {
|
|
||||||
"sysvinit" : {
|
|
||||||
"puppet" : {
|
|
||||||
"enabled" : "true",
|
|
||||||
"ensureRunning" : "true"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Puppet" : {
|
|
||||||
"roles" : [ "wordpress" ],
|
|
||||||
"host" : {"Fn::GetAtt" : ["WordPressDatabase", "Endpoint.Address"]},
|
|
||||||
"database" : "WordPressDB",
|
|
||||||
"user" : {"Ref" : "DatabaseUser"},
|
|
||||||
"password" : {"Ref" : "DatabasePassword" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"SecurityGroups": [ { "Ref": "PuppetClientSecurityGroup" }, { "Ref" : "EC2SecurityGroup" } ],
|
|
||||||
"ImageId": { "Fn::FindInMap": [ "AWSRegionArch2AMI", { "Ref": "AWS::Region" }, { "Fn::FindInMap": [ "AWSInstanceType2Arch", { "Ref": "InstanceType" }, "Arch" ] } ]
|
|
||||||
},
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash\n",
|
|
||||||
"yum update -y aws-cfn-bootstrap\n",
|
|
||||||
|
|
||||||
"/opt/aws/bin/cfn-init --region ", { "Ref" : "AWS::Region" },
|
|
||||||
" -s ", { "Ref" : "AWS::StackName" }, " -r WebServer ",
|
|
||||||
" --access-key ", { "Ref" : "CFNKeys" },
|
|
||||||
" --secret-key ", { "Fn::GetAtt" : ["CFNKeys", "SecretAccessKey"]}, "\n",
|
|
||||||
"/opt/aws/bin/cfn-signal -e $? '", { "Ref" : "ApplicationWaitHandle" }, "'\n"
|
|
||||||
]]}},
|
|
||||||
"KeyName": { "Ref": "KeyName" },
|
|
||||||
"InstanceType": { "Ref": "InstanceType" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
"EC2SecurityGroup" : {
|
|
||||||
"Type" : "AWS::EC2::SecurityGroup",
|
|
||||||
"Properties" : {
|
|
||||||
"GroupDescription" : "Enable HTTP access for Wordpress plus SSH access via port 22",
|
|
||||||
"SecurityGroupIngress" : [
|
|
||||||
{"IpProtocol" : "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : "0.0.0.0/0" },
|
|
||||||
{"IpProtocol" : "tcp", "FromPort" : "80", "ToPort" : "80", "CidrIp" : "0.0.0.0/0" }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"ApplicationWaitHandle" : {
|
|
||||||
"Type" : "AWS::CloudFormation::WaitConditionHandle"
|
|
||||||
},
|
|
||||||
|
|
||||||
"ApplicationWaitCondition" : {
|
|
||||||
"Type" : "AWS::CloudFormation::WaitCondition",
|
|
||||||
"DependsOn" : "WebServer",
|
|
||||||
"Properties" : {
|
|
||||||
"Handle" : { "Ref" : "ApplicationWaitHandle" },
|
|
||||||
"Timeout" : "600"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"WordPressDatabase" : {
|
|
||||||
"Type" : "AWS::RDS::DBInstance",
|
|
||||||
"Properties" : {
|
|
||||||
"AllocatedStorage" : "5",
|
|
||||||
"DBName" : "WordPressDB",
|
|
||||||
"Engine" : "MySQL",
|
|
||||||
"DBInstanceClass" : { "Ref" : "DatabaseType" },
|
|
||||||
"DBSecurityGroups" : [ { "Ref": "DBSecurityGroup" } ],
|
|
||||||
"MasterUsername" : { "Ref" : "DatabaseUser" },
|
|
||||||
"MasterUserPassword" : { "Ref" : "DatabasePassword" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBSecurityGroup": {
|
|
||||||
"Type": "AWS::RDS::DBSecurityGroup",
|
|
||||||
"Properties": {
|
|
||||||
"DBSecurityGroupIngress": {
|
|
||||||
"EC2SecurityGroupName": { "Ref": "EC2SecurityGroup" }
|
|
||||||
},
|
|
||||||
"GroupDescription": "database access"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs": {
|
|
||||||
"WebsiteURL": {
|
|
||||||
"Value": { "Fn::Join": [ "", [ "http://", { "Fn::GetAtt": [ "WebServer", "PublicDnsName" ] }, "/wordpress" ] ] },
|
|
||||||
"Description" : "URL of the WordPress website"
|
|
||||||
},
|
|
||||||
"InstallURL": {
|
|
||||||
"Value": { "Fn::Join": [ "", [ "http://", { "Fn::GetAtt": [ "WebServer", "PublicDnsName" ] }, "/wordpress/wp-admin/install.php" ] ] },
|
|
||||||
"Description" : "URL to install WordPress"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,171 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion": "2010-09-09",
|
|
||||||
|
|
||||||
"Description": "WordPress is web software you can use to create a beautiful website or blog. This template installs two instances: one running a WordPress deployment and the other, created within a separate stack embedded in this one with template composition, using a local MySQL database to store the data.",
|
|
||||||
|
|
||||||
"Parameters": {
|
|
||||||
|
|
||||||
"KeyName": {
|
|
||||||
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type": "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceType": {
|
|
||||||
"Description": "WebServer EC2 instance type",
|
|
||||||
"Type": "String",
|
|
||||||
"Default": "m1.large",
|
|
||||||
"AllowedValues": [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription": "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBName": {
|
|
||||||
"Default": "wordpress",
|
|
||||||
"Description": "The WordPress database name",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern": "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription": "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBUsername": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description": "The WordPress database admin account username",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "16",
|
|
||||||
"AllowedPattern": "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription": "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description": "The WordPress database admin account password",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern": "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription": "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBRootPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description": "Root password for MySQL",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern": "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription": "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Default": "F17",
|
|
||||||
"Description": "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues": [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings": {
|
|
||||||
"AWSInstanceType2Arch": {
|
|
||||||
"t1.micro" : { "Arch": "32" },
|
|
||||||
"m1.small" : { "Arch": "32" },
|
|
||||||
"m1.large" : { "Arch": "64" },
|
|
||||||
"m1.xlarge" : { "Arch": "64" },
|
|
||||||
"m2.xlarge" : { "Arch": "64" },
|
|
||||||
"m2.2xlarge" : { "Arch": "64" },
|
|
||||||
"m2.4xlarge" : { "Arch": "64" },
|
|
||||||
"c1.medium" : { "Arch": "32" },
|
|
||||||
"c1.xlarge" : { "Arch": "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch": "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"F18" : { "32": "F18-i386-cfntools", "64": "F18-x86_64-cfntools" },
|
|
||||||
"F17" : { "32": "F17-i386-cfntools", "64": "F17-x86_64-cfntools" },
|
|
||||||
"U10" : { "32": "U10-i386-cfntools", "64": "U10-x86_64-cfntools" },
|
|
||||||
"RHEL-6.1": { "32": "rhel61-i386-cfntools", "64": "rhel61-x86_64-cfntools" },
|
|
||||||
"RHEL-6.2": { "32": "rhel62-i386-cfntools", "64": "rhel62-x86_64-cfntools" },
|
|
||||||
"RHEL-6.3": { "32": "rhel63-i386-cfntools", "64": "rhel63-x86_64-cfntools" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources": {
|
|
||||||
"DatabaseServer": {
|
|
||||||
"Type": "AWS::CloudFormation::Stack",
|
|
||||||
"Properties": {
|
|
||||||
"TemplateURL": "https://raw.github.com/openstack/heat/master/templates/MySQL_Single_Instance.template",
|
|
||||||
"Parameters": {
|
|
||||||
"KeyName" : { "Ref": "KeyName" },
|
|
||||||
"InstanceType" : { "Ref": "InstanceType" },
|
|
||||||
"DBName" : { "Ref": "DBName" },
|
|
||||||
"DBUsername" : { "Ref": "DBUsername" },
|
|
||||||
"DBPassword" : { "Ref": "DBPassword" },
|
|
||||||
"DBRootPassword" : { "Ref": "DBRootPassword" },
|
|
||||||
"LinuxDistribution": { "Ref": "LinuxDistribution" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"WikiServerOne": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"DependsOn" : "DatabaseServer",
|
|
||||||
"Metadata": {
|
|
||||||
"AWS::CloudFormation::Init": {
|
|
||||||
"config": {
|
|
||||||
"packages": {
|
|
||||||
"yum": {
|
|
||||||
"httpd" : [],
|
|
||||||
"wordpress" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services": {
|
|
||||||
"systemd": {
|
|
||||||
"httpd" : { "enabled": "true", "ensureRunning": "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId": { "Fn::FindInMap": [ "DistroArch2AMI", { "Ref": "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap": [ "AWSInstanceType2Arch", { "Ref": "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref": "InstanceType" },
|
|
||||||
"KeyName" : { "Ref": "KeyName" },
|
|
||||||
"UserData" : { "Fn::Base64": { "Fn::Join": ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"/opt/aws/bin/cfn-init\n",
|
|
||||||
"sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed -i \"s/Require local/Require all granted/\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed --in-place --e s/database_name_here/", { "Ref": "DBName" },
|
|
||||||
"/ --e s/username_here/", { "Ref": "DBUsername" },
|
|
||||||
"/ --e s/password_here/", { "Ref": "DBPassword" },
|
|
||||||
"/ --e s/localhost/", { "Fn::GetAtt": [ "DatabaseServer", "Outputs.PublicIp" ]},
|
|
||||||
"/ /usr/share/wordpress/wp-config.php\n",
|
|
||||||
"systemctl restart httpd.service\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"LoadBalancer" : {
|
|
||||||
"Type" : "AWS::ElasticLoadBalancing::LoadBalancer",
|
|
||||||
"Properties" : {
|
|
||||||
"AvailabilityZones" : { "Fn::GetAZs" : "" },
|
|
||||||
"Instances" : [{"Ref": "WikiServerOne"}],
|
|
||||||
"Listeners" : [ {
|
|
||||||
"LoadBalancerPort" : "80",
|
|
||||||
"InstancePort" : "80",
|
|
||||||
"Protocol" : "HTTP"
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs": {
|
|
||||||
"WebsiteURL": {
|
|
||||||
"Value": { "Fn::Join": ["", ["http://", { "Fn::GetAtt": [ "LoadBalancer", "DNSName" ]}, "/wordpress"]] },
|
|
||||||
"Description": "URL for Wordpress wiki"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,170 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
|
|
||||||
"Description" : "AWS CloudFormation Sample Template WordPress_With_RDS: WordPress is web software you can use to create a beautiful website or blog. This template installs two instances: one running a WordPress deployment and the other using RDS as a data storage.",
|
|
||||||
|
|
||||||
"Parameters" : {
|
|
||||||
|
|
||||||
"KeyName" : {
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
|
|
||||||
"Type" : "String"
|
|
||||||
},
|
|
||||||
|
|
||||||
"InstanceType" : {
|
|
||||||
"Description" : "WebServer EC2 instance type",
|
|
||||||
"Type" : "String",
|
|
||||||
"Default" : "m1.large",
|
|
||||||
"AllowedValues" : [ "t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "m2.2xlarge", "m2.4xlarge", "c1.medium", "c1.xlarge", "cc1.4xlarge" ],
|
|
||||||
"ConstraintDescription" : "must be a valid EC2 instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBClass" : {
|
|
||||||
"Default" : "db.m1.small",
|
|
||||||
"Description" : "Database instance class",
|
|
||||||
"Type" : "String",
|
|
||||||
"AllowedValues" : [ "db.m1.small", "db.m1.large", "db.m1.xlarge", "db.m2.xlarge", "db.m2.2xlarge", "db.m2.4xlarge" ],
|
|
||||||
"ConstraintDescription" : "must select a valid database instance type."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBName": {
|
|
||||||
"Default": "wordpress",
|
|
||||||
"Description" : "The WordPress database name",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "64",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBUsername": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account username",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "16",
|
|
||||||
"AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "The WordPress database admin account password",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBRootPassword": {
|
|
||||||
"Default": "admin",
|
|
||||||
"NoEcho": "true",
|
|
||||||
"Description" : "Root password for MySQL",
|
|
||||||
"Type": "String",
|
|
||||||
"MinLength": "1",
|
|
||||||
"MaxLength": "41",
|
|
||||||
"AllowedPattern" : "[a-zA-Z0-9]*",
|
|
||||||
"ConstraintDescription" : "must contain only alphanumeric characters."
|
|
||||||
},
|
|
||||||
|
|
||||||
"DBAllocatedStorage" : {
|
|
||||||
"Default": "5",
|
|
||||||
"Description" : "The size of the database (Gb)",
|
|
||||||
"Type": "Number",
|
|
||||||
"MinValue": "5",
|
|
||||||
"MaxValue": "1024",
|
|
||||||
"ConstraintDescription" : "must be between 5 and 1024Gb."
|
|
||||||
},
|
|
||||||
|
|
||||||
"LinuxDistribution": {
|
|
||||||
"Default": "F17",
|
|
||||||
"Description" : "Distribution of choice",
|
|
||||||
"Type": "String",
|
|
||||||
"AllowedValues" : [ "F18", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Mappings" : {
|
|
||||||
"AWSInstanceType2Arch" : {
|
|
||||||
"t1.micro" : { "Arch" : "32" },
|
|
||||||
"m1.small" : { "Arch" : "32" },
|
|
||||||
"m1.large" : { "Arch" : "64" },
|
|
||||||
"m1.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.2xlarge" : { "Arch" : "64" },
|
|
||||||
"m2.4xlarge" : { "Arch" : "64" },
|
|
||||||
"c1.medium" : { "Arch" : "32" },
|
|
||||||
"c1.xlarge" : { "Arch" : "64" },
|
|
||||||
"cc1.4xlarge" : { "Arch" : "64" }
|
|
||||||
},
|
|
||||||
"DistroArch2AMI": {
|
|
||||||
"F18" : { "32" : "F18-i386-cfntools", "64" : "F18-x86_64-cfntools" },
|
|
||||||
"F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
|
|
||||||
"U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
|
|
||||||
"RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
|
|
||||||
"RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
|
|
||||||
"RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
"DatabaseServer": {
|
|
||||||
"Type": "AWS::RDS::DBInstance",
|
|
||||||
"Properties": {
|
|
||||||
"DBName" : { "Ref" : "DBName" },
|
|
||||||
"Engine" : "MySQL",
|
|
||||||
"MasterUsername" : { "Ref" : "DBUsername" },
|
|
||||||
"DBInstanceClass" : { "Ref" : "DBClass" },
|
|
||||||
"DBSecurityGroups" : [],
|
|
||||||
"AllocatedStorage" : { "Ref" : "DBAllocatedStorage" },
|
|
||||||
"MasterUserPassword": { "Ref" : "DBPassword" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"WebServer": {
|
|
||||||
"Type": "AWS::EC2::Instance",
|
|
||||||
"DependsOn": "DatabaseServer",
|
|
||||||
"Metadata" : {
|
|
||||||
"AWS::CloudFormation::Init" : {
|
|
||||||
"config" : {
|
|
||||||
"packages" : {
|
|
||||||
"yum" : {
|
|
||||||
"httpd" : [],
|
|
||||||
"wordpress" : []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"services" : {
|
|
||||||
"systemd" : {
|
|
||||||
"httpd" : { "enabled" : "true", "ensureRunning" : "true" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Properties": {
|
|
||||||
"ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
|
|
||||||
{ "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
|
|
||||||
"InstanceType" : { "Ref" : "InstanceType" },
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
|
|
||||||
"#!/bin/bash -v\n",
|
|
||||||
"/opt/aws/bin/cfn-init\n",
|
|
||||||
"sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed -i \"s/Require local/Require all granted/\" /etc/httpd/conf.d/wordpress.conf\n",
|
|
||||||
"sed --in-place --e s/database_name_here/", { "Ref" : "DBName" }, "/ --e s/username_here/", { "Ref" : "DBUsername" }, "/ --e s/password_here/", { "Ref" : "DBPassword" }, "/ --e s/localhost/", { "Fn::GetAtt" : [ "DatabaseServer", "Endpoint.Address" ]}, "/ /usr/share/wordpress/wp-config.php\n",
|
|
||||||
"systemctl restart httpd.service\n"
|
|
||||||
]]}}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
"Outputs" : {
|
|
||||||
"WebsiteURL" : {
|
|
||||||
"Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "WebServer", "PublicIp" ]}, "/wordpress"]] },
|
|
||||||
"Description" : "URL for Wordpress wiki"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
{
|
|
||||||
"AWSTemplateFormatVersion" : "2010-09-09",
|
|
||||||
"Parameters" : {
|
|
||||||
"KeyName" : {
|
|
||||||
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instance",
|
|
||||||
"Type" : "String"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"Resources" : {
|
|
||||||
"MyInstance" : {
|
|
||||||
"Type" : "AWS::EC2::Instance",
|
|
||||||
"Properties" : {
|
|
||||||
"KeyName" : { "Ref" : "KeyName" },
|
|
||||||
"ImageId" : "F17-x86_64-cfntools",
|
|
||||||
"InstanceType": "m1.large",
|
|
||||||
"UserData" : { "Fn::Base64" : "80" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Outputs" : {
|
|
||||||
"InstanceIp" : {
|
|
||||||
"Value" : { "Fn::Join" : ["", ["ssh ec2-user@",
|
|
||||||
{"Fn::GetAtt": ["MyInstance",
|
|
||||||
"PublicIp"]}]]},
|
|
||||||
"Description" : "My ssh command"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user