Fixing not working AWS ElasticBeanstalk cron job leader instance select

TLDR:

After doing all steps from docs, trying multiple solutions from stackoverflow and wasting countless hours, I found nothing was working for this basic EB env. Once again, AWS documentation failed me! I have decided to stick with solution from docs and debug actual reason why test_cron.sh was not detecting leader instance. The issue I found on test_cron.sh script was both INSTANCE_ID and REGION were not populated with metadata. It turned out that both requests to http://169.254.169.254/... were failing with 401 errors. Quickly found out here how to add authorization to that requests, and it worked. Look into TLDR for minimal test_cron.sh with proper authentication.

This bug would be left unseen for way longer without awesome healthchecks.io monitoring.

Happy coding!

#AWS #ElasticBeanstalk #bash