Skip to content

Instantly share code, notes, and snippets.

@klappradla
Created November 27, 2015 12:12
Show Gist options
  • Save klappradla/950e29af4c595ad8c68c to your computer and use it in GitHub Desktop.
Save klappradla/950e29af4c595ad8c68c to your computer and use it in GitHub Desktop.
Rake tasks as post deploy hooks for AWS Elastic Beanstalk Puma-Rails applications
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/01_do_stuff.sh" :
mode: "000755"
owner: ec2-user
group: ec2-user
content: |
#! /usr/bin/env bash
# Using similar syntax as the appdeploy pre hooks that is managed by AWS
set -xe
EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
EB_SUPPORT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_dir)
EB_DEPLOY_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir)
. $EB_SUPPORT_DIR/envvars
. $EB_SCRIPT_DIR/use-app-ruby.sh
cd $EB_DEPLOY_DIR
su -c "bundle exec rake do_stuff"
@josephecombs
Copy link

josephecombs commented May 31, 2017

Thanks for posting this man - ElasticBeanstalk is a HELL of a tool to configure. Shame on you AWS engineers who read this! This product should be EASIER and BETTER than Heroku!

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