I am trying to use the AWS Elastic Beanstalk tool to configure the EC2 instances that it creates. To do this, create a configuration file . Config in the .ebextensions directory .
You can specify several commands that should be executed when deploying the application to an instance. I use this to install some msi files, and also configure EC2 to give the instance a unique name. This requires a reboot.
My problem is that I want these commands to be run only when I first deploy the instance. When I deploy code-only changes to existing instances, they should not be triggered.
I tried using the "test" parameter, which should prevent the command from starting. I create the file as the last command, and then check for the presence of this file in the "test" parameter. But it doesn't seem to work.
My configuration file looks like this:
# File structure documented at http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-windows-ec2.html files: "C:\\Users\\Public\\EnableEc2SetComputerName.ps1": source: "[File Source]" commands: init-01-ec2setcomputername-enable: test: cmd /c "if exist C:\\Users\\Public\\initialised (exit 1) else (exit 0)" command: powershell.exe -ExecutionPolicy Bypass -File "C:\\Users\\Public\\EnableEc2SetComputerName.ps1" waitAfterCompletion: 0 init-05-reboot-instance: test: cmd /c "if exist C:\\Users\\Public\\initialised (exit 1) else (exit 0)" command: shutdown -r
Is there an alternative way to do this? Or am I doing something stupid?
On Unix-based systems, there are touch and test commands (mentioned in this answer asking an equivalent question for Unix systems). Which Windows equivalent works best in this situation?
source share