# Elastic BeanStalk deployments #45

Open
opened this Issue Nov 1, 2014 · 23 comments

None yet

### 10 participants

Member
 Hi Feodor, when do you plan to depoloy this feature?
Member
 I think you can deploy to BeanStalk right away. Look at this guide: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/deploy_NET_standalone_tool.html AWS SDK is installed on build workers, so you just need a config file and few lines of code in your build scripts.
commented Feb 26, 2015
 +1
 +1
 Yes as @FeodorFitsner mentioned above, you can already deploy to Elastic Beanstalk using the awsdeploy.exe deployment tool. In your appveyor.yml deploy_script: just do: C:\Program Files (x86)\AWS Tools\Deployment Tool\awsdeploy.exe /redeploy /wait /DAWSAccessKey=%AWSAccessKey% /DAWSSecretKey=%AWSSecretKey% path\to\your\awsdeploy-options.txt  I'd suggest encrypting your AWS credentials with AppVeyor encrypt tool rather than including them directly in your repo. One thing that would still be really nice is the feature described in issue #128. That would allow us to more easily do conditional deployment and take advantage of the cool stuff AppVeyor provides via deployment providers.
 I'd like it as a deployment environment: So that I don't have to have credentials (encrypted or not) in my repo, and So that it can be done conditionally external to the build
 Yeah that would be sweet. We would use that too!
 We are deploying to elastic beanstalk succesfully but there is a problem that breaks continious integration. After running the scripts you've mentioned, the response from aws does not include if the application is deployed succesfully. It may take a while for the applicaiton be deployed to instances regarding to your configuration, or fail. So we cannot run acceptance tests for the deployments we make. There must be a better solution that confirms if the deployment was succesful. AWS SDK provides these informations, but I have no idea how to do this with powershell. It should be nice if appveyor provides this feature out of the box :)
 Agree with @mwhouser that it would be nice to have EB deploys external to the build. For anyone looking for a workaround, I was able to achieve this by installing the AppVeyor deploy agent on a separate EC2 machine (with AWS tools installed) packaging the web deploy package inside an additional .zip build artifact deploying the .zip artifact as a "Windows Application", with a deploy.ps1 script that invokes awsdeploy
commented Dec 11, 2015
 If there is a solution, that using elastic beanstalk deployment as an environment, we will use Appveyor.
commented Dec 11, 2015
 @NuclearFishin Can you explain how can I invoke deploy.ps1 from seperated EC2 machine after deployment.
 Sure, the deploy.ps1 file is invoked automatically after you deploy- see the docs here. Be sure the deploy.ps1 file is at the root of your .zip file when you deploy. So from your AppVeyor build, you want to create a .zip file that contains at least: deploy.ps1 your-elastic-beanstalk-deploy-config.txt YourWebDeployPackage.zip Then, from within deploy.ps1, you invoke awsdeploy.exe using a command similar to the one referenced above in this thread. (awsdeploy.exe is installed by default on Windows EC2 machines.) At a high level, the process goes a little something like this: Build and package your source into a .zip file containing the files above Configure a separate EC2 machine as an AppVeyor deployment agent Configure AppVeyor to deploy to this build agent as a Windows application Then, when you deploy, AppVeyor will push the .zip file to the agent, unzip it, and run deploy.ps1, which will invoke awsdeploy.exe and deploy your web package. Hope that helps, if you get really stuck, I can provide some sample scripts but please give me some time to clean them up for general use. (Might be best to do this as a wiki page so everyone can benefit)
commented Dec 12, 2015
 @NuclearFishin I'll try this as soon as possible. It'll be nice complete article about this issue, if you have time.
 Lack of this feature breaks my ci flow. Hope to see a solution soon.
Member
 Sample script for deployment: $packageweb =$artifacts.values | Where-Object { $_.path -like '*App.Web.zip' }$exe = "C:\Program Files (x86)\AWS Tools\Deployment Tool\awsdeploy.exe" &$exe -r "-DDeploymentPackage=$(\$packageweb.path)" "-DTemplate=ElasticBeanstalk" "-DEnvironment.Name=MyAppWeb-test" "-DApplication.Name= MyAppWeb" "-DRegion=eu-west-1" "-DKeyPair=BlaKeypair" "-DUploadBucket=elasticbeanstalk-bucket" "-DAWSAccessKey=XXXXXXXXXXXXXXXXX" "-DAWSSecretKey=XXXXXXXXXXXXXXXXXXXXXX" "C:\projects\app\app\App.Web\awsdeploy.txt" awsdeploy.txt : Template = ElasticBeanstalk Container.ApplicationHealthcheckPath = /healthcheck 
 Thanks Feodor. This is the script I use currently. But suppports only one deployment which is not suitable for me. We need environment support for aws.
Member
 Yeah, I've pasted it here for implementation. I'm looking at the guide here - as far as I understand the deployment of BeanStalk app is basically just calling awsdeploy.exe tool with configuration file on input. Plus we could add like two options to the provider: redeploy and update_stack.
 A simple script deployment environment support should cover this I think. We can implement our custom script to call awsdeploy.exe.
Member
 Look at this guide for building kind of "script" environment: http://www.appveyor.com/blog/2015/11/04/deployment-projects
 Going off of this comment - So, if I wanted to push to one ElasticBeanstalk environment for one branch (master -> dev), and another environment for another branch (live -> prod), is that something I'd need to do in PowerShell? Would I just rely on environment variables to figure out the branch I'm building?
Member
 Correct.
 +1
Member
 Please check this blog post about how to implement Elastic BeanStalk deployments with custom script.