With reference to the docs,
- http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/custom-platform-hooks.html
- http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
Consider I have .ebextension/03_hooks.config which has
commands:
create_app_deploy_post_dir:
command: "mkdir -p /opt/elasticbeanstalk/hooks/appdeploy/post"
ignoreErrors: true
files:
"/opt/elasticbeanstalk/hooks/appdeploy/post/99-post-deploy-test.sh":
mode: "000755"
owner: root
group: root
content: |
#!/usr/bin/env bash
eventHelper.py --msg "Successfully executing post deployment hook." --severity INFO
The file is not created and executed during the very first deploy, that is when an EC2 instance is added during env create or auto scaling. The new instance is almost useless and become useful only on the next force redeploying the app by eb deploy
or deploy zip from Application Versions.
Observation
- Checked if the files are created in the newly added EC2 instance, they are not.
- The commands given in the
commands
directive also not executed as I checked the eb logs. - Which gives me the feel like these two directives are ignored on first deploy in a newly added instance.
Real use case: I have hook scripts to write and start/restart the nginx and uwsgi on appdeploy enack and post. So without them executing on the new instances, there will be intermittent 502 returned till the next deployment.