AWS elasticbeanstalk hooks: postdeploy works, predeploy doesn't

Viewed 10

I am using an ebs app on linux 2 platforms, and I need to clone a directory during deployment to get configfiles for my app. I did a predeploy hook so that the files are there when the app starts after deployment: /.platform/hooks/predeploy/01_import

After deployment in a predeploy hook, the files are not there. When I run the exact same script in a postdeploy hook, the files are there.

So the command works, I see the predeploy hook is running (I see the echo text in the log), but the files are not present. Anyone knows why?

#!/bin/bash
mkdir /var/app/current/config
echo Adding github in known hosts
ssh-keyscan -H github.com >> /home/webapp/.ssh/known_hosts
echo Done Adding github in known hosts
echo deleting old flows
echo cloning 
git -c core.sshCommand="ssh -i /etc/pki/tls/certs/githubKey" clone -b dev --single-branch <mygithub> /var/app/current/config
echo done cloning 
1 Answers

In predeploy stage, the new code is deployed to /var/app/staging, not /var/app/current.

/var/app/current is actually overwritten by staging if the new staging deployment is successful.

So in predeploy, I've cloned to staging instead, and it works.

This is not well documented in AWS docs; this helped me.

Related