Created
December 11, 2013 15:46
-
-
Save davehewy/7912730 to your computer and use it in GitHub Desktop.
Userdata Drupal example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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 Apache Web Server, MySQL and Drupal\n", | |
"/opt/aws/bin/cfn-init -s ", { "Ref" : "AWS::StackId" }, " -r WebServer ", | |
" --region ", { "Ref" : "AWS::Region" }, " || error_exit 'Failed to run cfn-init'\n", | |
"# Make changes to Apache Web Server configuration\n", | |
"mv /var/www/html/drupal-7.8/* /var/www/html\n", | |
"mv /var/www/html/drupal-7.8/.* /var/www/html\n", | |
"rmdir /var/www/html/drupal-7.8\n", | |
"sed -i 's/AllowOverride None/AllowOverride All/g' /etc/httpd/conf/httpd.conf\n", | |
"service httpd restart\n", | |
"# Create the site in Drupal\n", | |
"cd /var/www/html\n", | |
"~ec2-user/drush/drush site-install standard --yes", | |
" --site-name='", { "Ref" : "SiteName" }, "' --site-mail=", { "Ref" : "SiteEMail" }, | |
" --account-name=", { "Ref" : "SiteAdmin" }, " --account-pass=", { "Ref" : "SitePassword" }, | |
" --db-url=mysql://", { "Ref" : "DBUsername" }, ":", { "Ref" : "DBPassword" }, "@", {"Fn::GetAtt" : ["DBInstance", "Endpoint.Address"]}, ":", {"Fn::GetAtt" : ["DBInstance", "Endpoint.Port"]}, "/", { "Ref" : "DBName" }, | |
" --db-prefix=drupal_\n", | |
"chown apache:apache sites/default/files\n", | |
"# All is well so signal success\n", | |
"/opt/aws/bin/cfn-signal -e 0 -r \"Drupal setup complete\" '", { "Ref" : "WaitHandle" }, "'\n" | |
]]}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment