"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash -v\n",
"/opt/aws/bin/cfn-init\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"
+ "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" }, "/ --e s/localhost/", { "Fn::GetAtt" : [ "DatabaseServer", "PublicIp" ]}, "/ /usr/share/wordpress/wp-config.php\n",
+ "systemctl restart httpd.service\n"
]]}}
}
}
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash -v\n",
"/opt/aws/bin/cfn-init\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"
+ "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" }, "/ --e s/localhost/", { "Fn::GetAtt" : [ "WikiDatabase", "PublicIp" ]}, "/ /usr/share/wordpress/wp-config.php\n",
+ "systemctl restart httpd.service\n"
]]}}
}
},
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash -v\n",
"/opt/aws/bin/cfn-init\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"
+ "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" }, "/ --e s/localhost/", { "Ref" : "DatabaseIPAddress" }, "/ /usr/share/wordpress/wp-config.php\n",
+ "systemctl restart httpd.service\n"
]]}}
}
},
"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 --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"
+ "/ /usr/share/wordpress/wp-config.php\n",
+ "systemctl restart httpd.service\n"
]]}}
}
}
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash -v\n",
"/opt/aws/bin/cfn-init\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"
+ "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" }, "/ --e s/localhost/", { "Fn::GetAtt" : [ "DatabaseTemplate", "Outputs.PublicIp" ]}, "/ /usr/share/wordpress/wp-config.php\n",
+ "systemctl restart httpd.service\n"
]]}}
}
}
"FLUSH PRIVILEGES;\n",
"EXIT\n",
"EOF\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"
+ "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"
]]}}
}
}
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
+ 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
Fn::Base64:
Fn::Join:
- ''
- - - |-
- #!/bin/bash -v
- /opt/aws/bin/cfn-init
- # Setup MySQL root password and create a user
- mysqladmin -u root password '
+ - - '#!/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='
+ - '''
+
+ '
+ - cat << EOF | mysql -u root --password='
- {Ref: DBRootPassword}
- - |-
- '
- CREATE DATABASE
+ - '''
+
+ '
+ - 'CREATE DATABASE '
- {Ref: DBName}
- - |-
- ;
- GRANT ALL PRIVILEGES ON
+ - ';
+
+ '
+ - 'GRANT ALL PRIVILEGES ON '
- {Ref: DBName}
- .* TO "
- {Ref: DBUsername}
- - |-
- "@"localhost"
- IDENTIFIED BY "
+ - '"@"localhost"
+
+ '
+ - IDENTIFIED BY "
- {Ref: DBPassword}
- - |-
- ";
- FLUSH PRIVILEGES;
- EXIT
- EOF
- sed --in-place --e s/database_name_here/
+ - '";
+
+ '
+ - 'FLUSH PRIVILEGES;
+
+ '
+ - 'EXIT
+
+ '
+ - 'EOF
+
+ '
+ - 'sed -i "/Deny from All/d" /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
+ - '/ /usr/share/wordpress/wp-config.php
+
+ '
+ - 'systemctl restart httpd.service
+
+ '
Outputs:
WebsiteURL:
Value:
- Fn::GetAtt: [WikiDatabase, PublicIp]
- /wordpress
Description: URL for Wordpress wiki
+
"FLUSH PRIVILEGES;\n",
"EXIT\n",
"EOF\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"
]]}}
"FLUSH PRIVILEGES;\n",
"EXIT\n",
"EOF\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"
]]}}
"FLUSH PRIVILEGES;\n",
"EXIT\n",
"EOF\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"
+ "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"
]]}}
}
}
"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 --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",
"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 --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",
"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 --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",
"FLUSH PRIVILEGES;\n",
"EXIT\n",
"EOF\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"
+ "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"
]]}}
}
}
"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 --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"
]]}}
"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 --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"
+ "/ /usr/share/wordpress/wp-config.php\n",
+ "systemctl restart httpd.service\n"
]]}}
}
},
"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
"#!/bin/bash -v\n",
"/opt/aws/bin/cfn-init\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"
+ "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" }, "/ --e s/localhost/", { "Fn::GetAtt" : [ "DatabaseServer", "Endpoint.Address" ]}, "/ /usr/share/wordpress/wp-config.php\n",
+ "systemctl restart httpd.service\n"
]]}}
}
}