title: Deploy a .NET Windows Service with Amazon Elastic Beanstalk with no Web Application
body: <p>I want to create an Elastic Beanstalk configuration that allows me to deploy a .NET Windows Service but without deploying a web application. </p>
  
  <p>I have just read <a href="http://blogs.aws.amazon.com/net/post/Tx1RLX98N5ERPSA/Customizing-Windows-Elastic-Beanstalk-Environments-Part-1">this blog post</a> which explains how to use .ebextensions to deploy a Windows Service alongside your web application, but is there a scenario for which the .ebextensions can be run without deploying a Web Deploy package for a web application?</p>
  
  <p>Is my only option to create an empty web application that contains the .ebextensions directory and then deploy the Web Deploy package?</p>
  
  <p>The Elastic Beanstalk FAQ mentions the ability to deploy non-web applications (<a href="http://aws.amazon.com/elasticbeanstalk/faqs/#supported-applications">here</a>) and I have found a similar (unanswered) question on the AWS developer forums (<a href="https://forums.aws.amazon.com/message.jspa?messageID=416932">here</a>).</p>
  
  <h3>Update</h3>
  
  <p>Due to the lack of activity on this question and my inability to find any other information on the internet, I just assumed that the answer to this question is "No" (at least for now). </p>
  
  <p>I ended up creating an empty web application and used that to deploy my Windows Service via the .ebextensions YAML config.</p>
  
  <p>As a side note, I'd like to highlight <a href="http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-windows-ec2.html">this page from Amazon's documentation</a> which I found to be a very helpful guide to creating those special config files.</p>
  
  <h3>Another Update</h3>
  
  <p>After implementing the approach mentioned above, I discovered that Elastic Beanstalk was not executing my <code>.ebextensions</code> scripts for new Beanstalk instances. As a result, the Windows Service failed to be installed when new instances were created. I had to jump through several more hoops to finally arrive at a scalable solution. Please let me know if you want the details of the final solution. <br><br>
  Ultimately, it just seems like Elastic Beanstalk wasn't meant for deploying scalable Windows Services.</p>
  
  <hr>
  
  <h3>Basic Solution</h3>
  
  <p>I'm not comfortable releasing the source code since it was not for a personal project, but here is the basic structure of my current deployment solution:</p>
  
  <ol>
  <li>A custom EC2 AMI contains a 'bootstrap' program that runs on startup. The program does the following:
  <br/>  1.1.  <a href="http://docs.aws.amazon.com/AmazonS3/latest/dev/RetrievingObjectUsingNetSDK.html">Download a 'zip' archive</a> from a (configurable) 'deployment' S3 bucket
  <br/>  1.2.  Extract the downloaded zip file to a temporary directory
  <br/>  1.3.  An "install.bat" script is located/executed  (the name of the script is also configurable). This script installs and starts the windows service.</li>
  <li>The Elastic Beanstalk "Instance AMI" is set to the custom AMI with the bootsrap program (see: <a href="http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.customenv.html">this article</a>)</li>
  </ol>
  
  <p>To deploy new code: upload the installation .zip archive (that contains the windows service and install.bat file) to the S3 bucket and terminate all EC2 instances for the Elastic Beanstalk application. As the instances are re-created the bootstrapping program will download/install the newly updated code.</p>
  
  <p>Of course, if I were starting over, I would just skip using Elastic Beanstalk and use the standard AWS auto-scaling along with a similar deployment scheme. <strong>The bottom line</strong> is that if you don't have a web application, don't use Elastic Beanstalk; you're better off with the standard AWS auto-scaling.</p>
  
  <h3>New AWS Deployment Tools</h3>
  
  <p>Amazon recently announced several new code deployment/management services that seem to address deployment issues: <a href="http://aws.amazon.com/blogs/aws/code-management-and-deployment/">http://aws.amazon.com/blogs/aws/code-management-and-deployment/</a></p>
  
  <p>I have yet to use these new services (I'm not even sure if they've been released yet), but they look promising.</p>