Beanstalk on Windows: How do I prevent commands running on re-deployment? Beanstalk on Windows: How do I prevent commands running on re-deployment? windows windows

Beanstalk on Windows: How do I prevent commands running on re-deployment?


I think the problem lies in the fact that you are rebooting the machine before you can write the initialized file. You should be able use a bat file which first writes the semaphore, then reboots the instance, and run that .bat file contingently on the existence of semaphore.

You can either download the .bat file with a files:source: directive or compose it in the .config with a files:content: directive.

Otherwise, your test: lines look good (I tested them locally, without a reboot).


Essentially, no. Elastic Beanstalk is an abstraction and looks after the underlying infrastructure for you. You give up a lot of environment control and gain easier deployment. If you research into CloudFormation - in particular the meta-data and cfn-init / cfn-hup, you'll see a very similar construct around the beanstalk files and commandshttp://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-init.html

If you need to do instance customization beyond application customization - then you're possibly using the wrong tool, and having to put clumsy workarounds (until touch/test arrive from AWS) Cloud Formation scripts would probably be a better fit.

I wrote about how to configure windows instances via cloudformation and there's also extensive documentation on Amazon itself.

Given you've done all the hard work around the commands, I think it would be pretty easy to shift to a Cloud Formation script, and plonk the one time startup code into userdata.

**edit - I think you could do it like this though if you went with elastic beanstalkcommand: dir initialised || powershell.exe -ExecutionPolicy Bypass -File "C:\\Users\\Public\\EnableEc2SetComputerName.ps1"


I recently ran into a very similiar problem, and utilized the answer from Jim Flanagan above and created a PowerShell script to do this.

#  restarts the server if this is not the first deployment param ( )$strFileName="C:\Users\Public\fwinitialised.txt"If (Test-Path $strFileName){  #This file was created on a previous deployment, reboot now.  Restart-Computer -Force}Else{  # this is a new instance, no need to reboot.  New-Item $strFileName -type file }

And in the .ebextensions file...

6-reboot-instance:    command: powershell.exe -ExecutionPolicy Bypass -File "C:\\PERQ\\Deployment\\RestartServerOnRedeployment.ps1"     waitAfterCompletion: forever