I've got a elasticbeanstalk environment that needs to run a powershell script and restart before the application is deployed. According to the documentation this is supported as per the documentation

If the system requires a reboot after the command completes, the system reboots after the specified number of seconds elapses. If the system reboots as a result of a command, Elastic Beanstalk will recover to the point after the command in the configuration file. The default value is 60 seconds. You can also specify forever, but the system must reboot before you can run another command.

However when I add a reboot command to a ebextensions .config file I get the following exception from elasticbeanstalk

Error occurred during build: [Errno 4] Interrupted function call

The logs on the server after it has rebooted show that the command was executed so I assume the error is caused by a restart during the app deploy stage.

If I remove the restart command, deploy, wait for it to be ready then trigger a restart manually it works fine. But this is obviously not acceptable.

I've looked into the deployment hooks file system approach but that doesn't work either, and seems unessesary given it sounds like it should support this requirement out of the box.

Does anybody have any ideas?