Elastic BeanStalk deployments #45

Open
FeodorFitsner opened this Issue Nov 1, 2014 · 23 comments

Projects

None yet

10 participants

@keremdemirer

Hi Feodor, when do you plan to depoloy this feature?

@FeodorFitsner
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.

@tbenade
tbenade commented Feb 26, 2015

+1

@mwhouser

+1

@danielmcormond

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.

@mwhouser

I'd like it as a deployment environment:

  1. So that I don't have to have credentials (encrypted or not) in my repo, and
  2. So that it can be done conditionally external to the build
@danielmcormond

Yeah that would be sweet. We would use that too!

@keremdemirer

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 :)

@NuclearFishin

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
@onuralp
onuralp commented Dec 11, 2015

If there is a solution, that using elastic beanstalk deployment as an environment, we will use Appveyor.

@onuralp
onuralp commented Dec 11, 2015

@NuclearFishin Can you explain how can I invoke deploy.ps1 from seperated EC2 machine after deployment.

@NuclearFishin

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:

  1. Build and package your source into a .zip file containing the files above
  2. Configure a separate EC2 machine as an AppVeyor deployment agent
  3. 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)

@onuralp
onuralp 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.

@keremdemirer

Lack of this feature breaks my ci flow. Hope to see a solution soon.

@FeodorFitsner
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
@keremdemirer

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.

@FeodorFitsner
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.

@keremdemirer

A simple script deployment environment support should cover this I think. We can implement our custom script to call awsdeploy.exe.

@FeodorFitsner
Member

Look at this guide for building kind of "script" environment: http://www.appveyor.com/blog/2015/11/04/deployment-projects

@deybhayden

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?

@FeodorFitsner
Member

Correct.

@mycreativity

+1

@IlyaFinkelshteyn
Member

Please check this blog post about how to implement Elastic BeanStalk deployments with custom script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment