Is there a supported way to run post-deploy scripts on AWS Elastic Beanstalk?

Solution 1:

It's 2019 and I still couldn't find any documentation for Beanstalk Platform Hooks regarding .NET apps. I ended up doing something similar to your solution.

  1. Create a config file in .ebextensions folder.
  2. Create a script file that I want to run (either save it in the code, or define/retrieve it as part of the config file in Step 1)
  3. Inside this config file, under container_commands section, run a command to copy the script from Step 2 into C:\Program Files\Amazon\ElasticBeanstalk\hooks\appdeploy\post\ (or whichever hook you want). More info here

When Beanstalk deploys the application, the command under container_commands will run after the server has been set up, but before the code has been deployed 1. After that, your hook script should be in place and will trigger according to the folder it's in.

Unfortunately I don't know if this is the official way to do it for .NET apps.