Skip to content

Instantly share code, notes, and snippets.

@adamalex
Created October 28, 2013 00:01
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save adamalex/7189405 to your computer and use it in GitHub Desktop.
Save adamalex/7189405 to your computer and use it in GitHub Desktop.
Config and CI script for automated Node.js 0.10.10 project deployment—including grunt—to Elastic Beanstalk
packages:
yum:
git: []
gcc: []
make: []
openssl-devel: []
commands:
00-add-home-variable:
command: sed -i 's/function error_exit/export HOME=\/root\n\nfunction error_exit/' /opt/elasticbeanstalk/hooks/appdeploy/pre/50npm.sh
container_commands:
00-install-grunt:
command: $NODE_HOME/bin/npm install -g grunt-cli
10-run-grunt:
command: $NODE_HOME/bin/node $NODE_HOME/bin/grunt build
[global]
ApplicationName=my-app-name
DevToolsEndpoint=git.elasticbeanstalk.us-east-1.amazonaws.com
EnvironmentName=my-environment-name
Region=us-east-1
#!/bin/bash
CREDENTIAL_FILE=~/.elasticbeanstalk/aws_credential_file
# Download the Elastic Beanstalk CLI
curl -o /tmp/aws.zip https://s3.amazonaws.com/elasticbeanstalk/cli/AWS-ElasticBeanstalk-CLI-2.5.1.zip
unzip /tmp/aws.zip -d /tmp/aws
# Configure the Git repository for Beanstalk
/tmp/aws/AWS-ElasticBeanstalk-CLI-2.5.1/AWSDevTools/Linux/AWSDevTools-RepositorySetup.sh
# Create the Beanstalk credential file
if [ ! -f $CREDENTIAL_FILE ]; then
mkdir -p ~/.elasticbeanstalk
echo AWSAccessKeyId=$AWS_ACCESS_KEY > $CREDENTIAL_FILE
echo AWSSecretKey=$AWS_SECRET_KEY >> $CREDENTIAL_FILE
fi
# Deploy
git aws.push
# Clean up
rm $CREDENTIAL_FILE
rm -rf /tmp/aws*
@dilipl
Copy link

dilipl commented Jan 10, 2014

Adam,
Was $NODE_HOME set when the container command (to install grunt in your case, I am trying to install some other npm package) was run? Did you have to set it some other way? I didn't find it set on that machine under elastic beanstalk. Any ideas?...thanks

@lwansbrough
Copy link

@dilipl (and anyone else passing by) I believe the purpose of the first command 00-add-home-variable is to add that $NODE_HOME variable for the commands that follow.

@pfried
Copy link

pfried commented May 3, 2014

I am getting a Fatal error: Unable to find local grunt, any idea why this is going wrong? I have a question on SO regarding this topic, help is appreciated! http://stackoverflow.com/questions/23444288/aws-elastic-beanstalk-run-grunt-task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment