Note that there are some explanatory texts on larger screens.

plurals
  1. POBeanstalk on Windows: How do I prevent commands running on re-deployment?
    primarykey
    data
    text
    <p>I'm trying to take advantage of AWS Elastic Beanstalk's facility to customize the EC2 instances it creates. This requires creating a <a href="http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-windows-ec2.html" rel="nofollow noreferrer">.config file in the .ebextensions directory</a>.</p> <p>You can specify a number of commands which should be executed when the application is deployed to an instance. I'm using that to install some msi files, and also to configure EC2 to assign the instance a unique name. This then requires a reboot.</p> <p>My problem is that I only want these commands to be run when an instance is first deployed. When I deploy a code-only change to existing instances they shouldn't be run.</p> <p>I've tried using the "test" parameter, which should prevent the command running. I create a file as the last command, and then I check for the presence of that file in the "test" parameter. But it doesn't seem to work.</p> <p>My config file is like this:</p> <pre><code># 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 # restart to enable EC2 to set the computer name waitAfterCompletion: forever init-06-mark-initialised: test: cmd /c "if exist C:\\Users\\Public\\initialised (exit 1) else (exit 0)" command: echo initialised &gt; C:\\Users\\Public\\initialised waitAfterCompletion: 0 </code></pre> <p>Is there an alternative way to accomplish this? Or am I doing something stupid?</p> <p>On Unix-based systems, there are the <code>touch</code> and <code>test</code> commands (referred to in <a href="https://stackoverflow.com/a/16846429/1727">this answer</a> asking the equivalent question for Unix systems). What's the equivalent in Windows which will work best in this situation?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload