{
"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.",
+ "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" : {
},
"Resources" : {
-
- "WebServer": {
+ "WikiDatabase": {
"Type": "AWS::EC2::Instance",
"Metadata" : {
"AWS::CloudFormation::Init" : {
"config" : {
"packages" : {
"yum" : {
- "httpd" : [],
"mysql" : [],
"mysql-server" : [],
+ "httpd" : [],
"wordpress" : []
}
},
"services" : {
"systemd" : {
- "httpd" : { "enabled" : "true", "ensureRunning" : "true" },
- "mysqld" : { "enabled" : "true", "ensureRunning" : "true" }
+ "mysqld" : { "enabled" : "true", "ensureRunning" : "true" },
+ "httpd" : { "enabled" : "true", "ensureRunning" : "true" }
}
}
}
"/opt/aws/bin/cfn-init\n",
"# Setup MySQL root password and create a user\n",
"mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "'\n",
- "cat >> /tmp/mysql-wordpress-config << EOF\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",
- "cat /tmp/mysql-wordpress-config | mysql -u root --password='", { "Ref" : "DBRootPassword" }, "' < /tmp/mysql-wordpress-config\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"
+ "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"
]]}}
}
- }
+ },
},
"Outputs" : {