man_eb_deployer 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/release.yml +31 -0
- data/.github/workflows/test.yml +16 -0
- data/.gitignore +12 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +143 -0
- data/Gemfile +10 -0
- data/LICENSE +22 -0
- data/README.md +138 -0
- data/Rakefile +12 -0
- data/TODOS.md +11 -0
- data/bin/eb_deploy +13 -0
- data/eb_deployer.gemspec +22 -0
- data/lib/eb_deployer/application.rb +96 -0
- data/lib/eb_deployer/aws_driver/beanstalk.rb +158 -0
- data/lib/eb_deployer/aws_driver/cloud_formation_driver.rb +53 -0
- data/lib/eb_deployer/aws_driver/s3_driver.rb +35 -0
- data/lib/eb_deployer/aws_driver.rb +8 -0
- data/lib/eb_deployer/cf_event_source.rb +26 -0
- data/lib/eb_deployer/cloud_formation_provisioner.rb +120 -0
- data/lib/eb_deployer/component.rb +45 -0
- data/lib/eb_deployer/config_loader.rb +64 -0
- data/lib/eb_deployer/default_component.rb +32 -0
- data/lib/eb_deployer/default_config.rb +20 -0
- data/lib/eb_deployer/default_config.yml +159 -0
- data/lib/eb_deployer/deployment_strategy/blue_green.rb +79 -0
- data/lib/eb_deployer/deployment_strategy/blue_only.rb +45 -0
- data/lib/eb_deployer/deployment_strategy/inplace_update.rb +16 -0
- data/lib/eb_deployer/deployment_strategy.rb +20 -0
- data/lib/eb_deployer/eb_environment.rb +204 -0
- data/lib/eb_deployer/eb_event_source.rb +35 -0
- data/lib/eb_deployer/environment.rb +60 -0
- data/lib/eb_deployer/event_poller.rb +51 -0
- data/lib/eb_deployer/package.rb +39 -0
- data/lib/eb_deployer/resource_stacks.rb +20 -0
- data/lib/eb_deployer/smoke_test.rb +23 -0
- data/lib/eb_deployer/tasks.rb +45 -0
- data/lib/eb_deployer/throttling_handling.rb +17 -0
- data/lib/eb_deployer/utils.rb +33 -0
- data/lib/eb_deployer/version.rb +3 -0
- data/lib/eb_deployer/version_cleaner.rb +30 -0
- data/lib/eb_deployer.rb +339 -0
- data/lib/generators/eb_deployer/install/install_generator.rb +82 -0
- data/lib/generators/eb_deployer/install/templates/eb_deployer.rake +1 -0
- data/lib/generators/eb_deployer/install/templates/eb_deployer.yml.erb +181 -0
- data/lib/generators/eb_deployer/install/templates/ebextensions/01_postgres_packages.config +5 -0
- data/lib/generators/eb_deployer/install/templates/postgres_rds.json +88 -0
- data/test/aws_driver_stubs.rb +350 -0
- data/test/beanstalk_test.rb +23 -0
- data/test/blue_green_deploy_test.rb +114 -0
- data/test/blue_only_deploy_test.rb +78 -0
- data/test/cf_event_poller_test.rb +32 -0
- data/test/cloud_formation_provisioner_test.rb +47 -0
- data/test/config_loader_test.rb +205 -0
- data/test/deploy_test.rb +42 -0
- data/test/eb_environment_test.rb +120 -0
- data/test/eb_event_poller_test.rb +32 -0
- data/test/inplace_update_deploy_test.rb +110 -0
- data/test/multi_components_deploy_test.rb +164 -0
- data/test/rails_generators_test.rb +67 -0
- data/test/resources_deploy_test.rb +191 -0
- data/test/smoke_test_test.rb +23 -0
- data/test/template_deploy_test.rb +13 -0
- data/test/test_helper.rb +68 -0
- data/test/tier_setting_deploy_test.rb +24 -0
- data/test/versions_deploy_test.rb +120 -0
- metadata +176 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d74b569ff1c09801c0da3f0ab3208623b3835a8ac4c832cb636f1b159e1188d3
|
4
|
+
data.tar.gz: 78ec8df9ad3a55664347c4611d6aebf051538a974e5298450c934d9b452ca0a7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3b246aa4f92ca105e2f2c70328148a47171deffe3cedf3d260e1776d54c349774f7ded4ee7d050a4f06c8ea7713058a022bffea0e0151cd54768ddd346f5c307
|
7
|
+
data.tar.gz: 9c8631e9a8ad3b9fb12af285986896961ca1ace2ce7ac54878c9d5f69eb992b76e1e3bda51db94cf87c9023b9c105f9134a27d7be8dde72b7a34a785cf71fd47
|
@@ -0,0 +1,31 @@
|
|
1
|
+
name: Release
|
2
|
+
on:
|
3
|
+
workflow_dispatch: {}
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
permissions:
|
8
|
+
contents: write
|
9
|
+
pull-requests: write
|
10
|
+
jobs:
|
11
|
+
release:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
steps:
|
14
|
+
- uses: google-github-actions/release-please-action@v3
|
15
|
+
id: release
|
16
|
+
with:
|
17
|
+
release-type: ruby
|
18
|
+
package-name: man_eb_deployer
|
19
|
+
version-file: lib/eb_deployer/version.rb
|
20
|
+
- uses: actions/checkout@v4
|
21
|
+
- name: publish to rubygems
|
22
|
+
if: ${{ steps.release.outputs.release_created }}
|
23
|
+
run: |
|
24
|
+
mkdir -p $HOME/.gem
|
25
|
+
touch $HOME/.gem/credentials
|
26
|
+
chmod 0600 $HOME/.gem/credentials
|
27
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
28
|
+
gem build eb_deployer.gemspec
|
29
|
+
gem push man_eb_deployer-*.gem
|
30
|
+
env:
|
31
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
name: Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request: {}
|
5
|
+
workflow_dispatch: {}
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
test:
|
9
|
+
name: Unit Tests
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v4
|
13
|
+
- uses: ruby/setup-ruby@52b8784594ec115fd17094752708121dc5dabb47
|
14
|
+
with:
|
15
|
+
bundler-cache: true
|
16
|
+
- run: bundle exec rake test
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
eb_deployer
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.2.2
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## [0.8.0](https://github.com/manheim/eb_deployer/compare/v0.7.0...v0.8.0) (2023-10-17)
|
4
|
+
|
5
|
+
|
6
|
+
### Features
|
7
|
+
|
8
|
+
* explain fork transition in readme ([0ce9bbe](https://github.com/manheim/eb_deployer/commit/0ce9bbe1b905d3fadb749365b5e7fd7042f09fe7))
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* correct default branch ([f262778](https://github.com/manheim/eb_deployer/commit/f262778163b30f3e896af250561e80c96316404b))
|
14
|
+
* update gitignore file ([15cabbb](https://github.com/manheim/eb_deployer/commit/15cabbb7d1bb64cc7d3e98e66ff245b3d0626e10))
|
15
|
+
* update ruby version and simplify dependency management ([5b69e7e](https://github.com/manheim/eb_deployer/commit/5b69e7ede3b436df75e9ab94bae3d7f5308ea204))
|
16
|
+
|
17
|
+
0.7.0
|
18
|
+
=====
|
19
|
+
|
20
|
+
* Add service specific AWS sdk gems
|
21
|
+
* [#79](https://github.com/ThoughtWorksStudios/eb_deployer/pull/79): Environment updates can complete with errors
|
22
|
+
* [#82](https://github.com/ThoughtWorksStudios/eb_deployer/pull/82): Added a line to force STDOUT output every line
|
23
|
+
* [#85](https://github.com/ThoughtWorksStudios/eb_deployer/pull/85): Improve package not found error message
|
24
|
+
* [#86](https://github.com/ThoughtWorksStudios/eb_deployer/pull/86): Fix to for inactive stack updates when instances are 0
|
25
|
+
|
26
|
+
0.6.6
|
27
|
+
=====
|
28
|
+
|
29
|
+
* Add support for specifying (and overriding) a [stack policy](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/protect-stack-resources.html) for the CloudFormation resource stack. (contributed by @jlabrecque)
|
30
|
+
* Fix issue where deployment hangs if resource stack update fails and stack is rolled back, deployment will now fail when the resource stack update fails. (contributed by @jlabrecque)
|
31
|
+
* Add support for creating environment base on a elasticbeanstalk template. (contributed by @djpate)
|
32
|
+
|
33
|
+
0.6.5
|
34
|
+
=====
|
35
|
+
|
36
|
+
* #66: Making it possible to specify other accepted health states when deploying (@dziemid)
|
37
|
+
|
38
|
+
0.6.4
|
39
|
+
=====
|
40
|
+
|
41
|
+
* fixes #65 - aws driver should be able to detect CNAME prefixes from both regionalized and legacy EB domains
|
42
|
+
|
43
|
+
0.6.3
|
44
|
+
=====
|
45
|
+
|
46
|
+
* Wait until inactive environment status is ready before applying settings.
|
47
|
+
|
48
|
+
0.6.0
|
49
|
+
=====
|
50
|
+
|
51
|
+
* Use aws-sdk 2.0
|
52
|
+
* Ruby 2.2 support
|
53
|
+
* Robust error handling on CloudFormation resource stack provisioning
|
54
|
+
|
55
|
+
0.5.1
|
56
|
+
=====
|
57
|
+
|
58
|
+
* Fix issue: worker tier is picking up old version of aws-sqsd
|
59
|
+
|
60
|
+
0.5.0
|
61
|
+
=====
|
62
|
+
|
63
|
+
* Worker tier support
|
64
|
+
|
65
|
+
0.4.12
|
66
|
+
======
|
67
|
+
|
68
|
+
* Update default solution stacks.
|
69
|
+
* Rails generator generates SECRET_KEY_BASE for rails 4 app.
|
70
|
+
|
71
|
+
0.4.11
|
72
|
+
======
|
73
|
+
|
74
|
+
* Make gem depend on aws-sdk-v1 until we put in support for both v1 and v2
|
75
|
+
|
76
|
+
0.4.10
|
77
|
+
======
|
78
|
+
|
79
|
+
* Fix #33
|
80
|
+
|
81
|
+
0.4.9
|
82
|
+
====
|
83
|
+
|
84
|
+
* Ignore AWS::ElasticBeanstalk::Errors::OperationInProgressFailure error when delete application version
|
85
|
+
|
86
|
+
0.4.8
|
87
|
+
====
|
88
|
+
* Raise an error if the environment launched with problems (contributed by kmanning)
|
89
|
+
* Add --stack-name option that let's use choose the name of the cloud
|
90
|
+
formation stack to operate on (contributed by NET-A-PORTER)
|
91
|
+
* Document typo/grammar fix (contributed by stig)
|
92
|
+
* Retry on AWS API throttling error when operating on versions
|
93
|
+
|
94
|
+
0.4.7
|
95
|
+
====
|
96
|
+
* Added blue-only deployment strategy (a variant of blue-green) that
|
97
|
+
skips the cname swap so that the newly deployed code remains on the
|
98
|
+
inactive "blue" instance. (contributed by jlabrecque)
|
99
|
+
|
100
|
+
0.4.6
|
101
|
+
====
|
102
|
+
* Make elasticbeanstalk event polling robust against clock shifting problem.
|
103
|
+
|
104
|
+
0.4.5
|
105
|
+
====
|
106
|
+
* Rails 3+ support: Rails Generator to install default configurations with
|
107
|
+
Postgres RDS resource and everything need for blue-green
|
108
|
+
deployment
|
109
|
+
* Add ability to tag beanstalk environment (from @pmcfadden)
|
110
|
+
|
111
|
+
0.4.4
|
112
|
+
=====
|
113
|
+
* Fix S3 upload on Windows.
|
114
|
+
* Experimental support for "inactve_settings" options, which can be used to automatically scale down the inactive environment.
|
115
|
+
* Update default solution stack name to latest supported JAVA stack.
|
116
|
+
* Validate solution_stack option before creating environment and list available solution_stacks if not valid.
|
117
|
+
|
118
|
+
0.4.3
|
119
|
+
=====
|
120
|
+
* Backoff and retry when AWS::ElasticBeanstalk::Errors::Throttling happens during polling events
|
121
|
+
|
122
|
+
0.4.2
|
123
|
+
=====
|
124
|
+
* Allow provding different deploy strategy for different components.
|
125
|
+
|
126
|
+
0.4.1
|
127
|
+
=====
|
128
|
+
* Remove options for delete all environments ("-d --all"), because it is too destructive and not recoverable.
|
129
|
+
* Experimental support for multiple components deployment.
|
130
|
+
|
131
|
+
0.4.0
|
132
|
+
====
|
133
|
+
* revert back all changes from 0.3.8 to 0.3.9. Elasticbeanstalk haven't relex the real unique constain. The actually contrain is you can not have environment name cross different application
|
134
|
+
|
135
|
+
0.3.9
|
136
|
+
====
|
137
|
+
* Fix hang problem introduced in 0.3.8 when migrating old ElasticBeanstalk environment.
|
138
|
+
* Fix issue #13 (Deployment via S3 object broken since 0.3.7)
|
139
|
+
|
140
|
+
0.3.8
|
141
|
+
=====
|
142
|
+
* Change ElasticBeanstalk environment name pattern. Stop using sufix hash to make eb environment global unique. (Because ElasticBeanstalk does not require environment has globally uniqe name any more.)
|
143
|
+
* Add migration logic so that if a ElasticBeanstalk environment with legcy name exists, eb_deployer will automaticly terminate it and replace it with ElasticBeanstalk environment has new name pattern.
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Thoughtworks Inc.
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,138 @@
|
|
1
|
+
# EbDeployer ![Tests](https://github.com/manheim/eb_deployer/actions/workflows/test.yml/badge.svg) [![Gem Version](https://badge.fury.io/rb/eb_deployer.svg)](http://badge.fury.io/rb/eb_deployer) [![Dependency Status](https://www.versioneye.com/ruby/eb_deployer/0.6.1/badge.svg)](https://www.versioneye.com/ruby/eb_deployer/0.6.1)
|
2
|
+
|
3
|
+
Fork maintained by Manheim to upgrade Ruby version and dependencies.
|
4
|
+
|
5
|
+
[Built with :yellow_heart: and :coffee: in San Francisco](http://www.thoughtworks.com/mingle/team/)
|
6
|
+
|
7
|
+
Low friction deployments should be a breeze. Elastic Beanstalk provides a great foundation for performing Blue-Green deployments, and EbDeployer add a missing link to automate the whole flow out of box.
|
8
|
+
|
9
|
+
[Deploy Service by EbDeployer](http://www.thoughtworks.com/mingle/infrastructure/2015/06/01/deploy-service-by-ebdeployer.html)
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
$ gem install eb_deployer
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
### Step One: AWS Account Setup
|
18
|
+
|
19
|
+
Create an AWS IAM user for deploy and give it privilege to operate Elastic Beanstalk. Download the access keys for executing the deployment tasks later. Ensure your command line is primed with appropriate access_keys using one of techniques mentioned on [aws blog](http://ruby.awsblog.com/blog/tag/config). For example using environment variable:
|
20
|
+
|
21
|
+
$ export AWS_ACCESS_KEY_ID=xxx
|
22
|
+
$ export AWS_SECRET_ACCESS_KEY=xxx
|
23
|
+
|
24
|
+
|
25
|
+
### Step Two: Packaging
|
26
|
+
|
27
|
+
You need to package your application for Elastic Beanstalk stack first. For Java app a warball is appropriate. For Ruby on Rails app a tar.gz file is good. You can also package a Rails/Sinatra app as a war ball using warbler and deploy to Java stack. (Please remember to run rake assets:precompile first for a rails app.)
|
28
|
+
|
29
|
+
If you were deploying to Elastic Beanstalk Ruby stack, simply zip your codebase is good enough, for example:
|
30
|
+
|
31
|
+
$ git ls-files | zip your-app-name.zip -@
|
32
|
+
|
33
|
+
### Step Three: Generate configuration and Configure deployment process
|
34
|
+
|
35
|
+
$ eb_deploy
|
36
|
+
|
37
|
+
This will generate a default configuration at location 'config/eb_deployer.yml'. It is almost empty but working one. And it will generate settings for two environments 'development' and 'production'. Some options can be tweaked. The yml files includes documentation on how you can best suit it to your purpose.
|
38
|
+
|
39
|
+
|
40
|
+
### Step Four: Fasten your seat belt
|
41
|
+
run deploy
|
42
|
+
|
43
|
+
$ eb_deploy -p <package built> -e <environment>
|
44
|
+
|
45
|
+
Then open aws console for Elastic Beanstalk to see the result of this deployment.
|
46
|
+
|
47
|
+
|
48
|
+
### Configure Smoke Testing your stack
|
49
|
+
|
50
|
+
EB_Deployer allows you to automate your deployment and then some. You can also add smoke tests to your deployment - thus ensuring that the app you deployed is also working correctly.
|
51
|
+
Adding a smoke test suite is also simple. Check "smoke_test" section in your eb_deployer.yml. We show a simple curl based smoke test that helps you test if your app is up and responding to http.
|
52
|
+
|
53
|
+
smoke_test: |
|
54
|
+
curl_http_code = "curl -s -o /dev/null -w \"%{http_code}\" http://#{host_name}"
|
55
|
+
Timeout.timeout(600) do
|
56
|
+
until ['200', '302'].include?(`#{curl_http_code}`.strip)
|
57
|
+
sleep 5
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
Any rakeable test suite can be run as part of the smoke test(selenium, cucumber, capybara, and so on.)
|
63
|
+
You can add more smoke tests by calling arbitrary rake tasks (Please make sure check return status):
|
64
|
+
|
65
|
+
smoke_test: |
|
66
|
+
`rake test:smoke HOST_NAME=#{host_name}`
|
67
|
+
raise("Smoke failed!") unless $?.success?
|
68
|
+
|
69
|
+
Smoke testing gets you one step closer to continuous delivery.
|
70
|
+
|
71
|
+
### Blue-Green deployment
|
72
|
+
Since every deployment now runs smoke test, you now have a better safety net around your deployments. This allows us to trigger automatic blue-green deployments.
|
73
|
+
|
74
|
+
To do this you need not do anything special. So far we have deployed the application only once. Let's call this the 'green' stack. Any subsequent calls to deployment will deployment a copy of this application to a new stack - the 'blue' stack. Smoke tests will be run on it and once everything passes the 'blue'(new) stack will be switched to the 'green' stack. Thus your new code will now be on the active stack and the user will experience no downtime.
|
75
|
+
|
76
|
+
Once this new stack is stable or has run for a while you can choose to delete the old stack. Or if you are doing continuous delivery you may be ready to another 'blue' deployment. You could just trigger another deployment and repeat this every hour/day/week... you get the idea.
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
### Destroying a stack
|
81
|
+
So you are done with this environment, you can destroy it easily as well.
|
82
|
+
|
83
|
+
# destroy one environment
|
84
|
+
$ eb_deployer -d -e <environment>
|
85
|
+
|
86
|
+
|
87
|
+
and you are done!
|
88
|
+
|
89
|
+
Later tutorials coming soon will cover
|
90
|
+
* how to setup RDS or other AWS resource and share them between blue green environments
|
91
|
+
|
92
|
+
Take a look at code if you can not wait for the documentation.
|
93
|
+
|
94
|
+
### eb_deploy.yml configuration file
|
95
|
+
|
96
|
+
Like Rails database.yml file, EbDeployer will read eb_deploy.yml file as ERB template file. So you can trade it as standard ERB template file, and substitute Ruby script. For example, the following eb_deployer.yml file partial configures DBPassword parameter for your CloudFormation template from an environment variable:
|
97
|
+
|
98
|
+
resources:
|
99
|
+
template: config/my_rds.json
|
100
|
+
inputs:
|
101
|
+
DBPassword: <%= ENV['MYDBPASSWORD'] %>
|
102
|
+
|
103
|
+
|
104
|
+
EbDeployer also provides the following help methods for convenience:
|
105
|
+
|
106
|
+
1. random_hash: it basically is `SecureRandom.hex[0..9]`
|
107
|
+
2. package_digest: it is your eb package file digest
|
108
|
+
3. environment: environment name you passed in when executing eb_deploy script using -e option.
|
109
|
+
|
110
|
+
## More
|
111
|
+
|
112
|
+
[Automated zero downtime deployment to AWS Elastic Beanstalk for Rails with EbDeployer](http://helabs.com/blog/2015/05/19/automated-zero-downtime-deployment-to-aws-elastic-beanstalk-for-rails-with-eb-deployer/?utm_content=buffer12098&utm_medium=social&utm_source=twitter.com&utm_campaign=buffer)
|
113
|
+
|
114
|
+
Co-presented session with Amazon ElasticBeanstalk team at AWS re:Invent 2013: [slideshare](http://www.slideshare.net/AmazonWebServices/aws-elastic-beanstalk-under-the-hood-dmg301-aws-reinvent-2013-28428616) and [video (starting at 27:46)](http://www.youtube.com/watch?v=U06-QLd4FL4)
|
115
|
+
|
116
|
+
[Deploy Service by EbDeployer](http://www.thoughtworks.com/mingle/infrastructure/2015/06/01/deploy-service-by-ebdeployer.html)
|
117
|
+
|
118
|
+
[Rails 3/4 Support](https://github.com/ThoughtWorksStudios/eb_deployer/wiki/Rails-3-Support)
|
119
|
+
|
120
|
+
[EbDeployer environment](https://github.com/ThoughtWorksStudios/eb_deployer/wiki/EbDeployer-environment)
|
121
|
+
|
122
|
+
[Introduction to EbDeployer](https://www.thoughtworks.com/mingle/scaling/2014/06/13/introduction-to-eb-deployer.html)
|
123
|
+
|
124
|
+
[Papertrail Solution for Rails Applications on ElasticBeanstalk
|
125
|
+
](http://www.thoughtworks.com/mingle/infrastructure/2015/06/10/simple-solution-for-papertrail-on-elasticbeanstalk.html)
|
126
|
+
|
127
|
+
[Elastic Beanstalk Tips and Tricks](https://github.com/ThoughtWorksStudios/eb_deployer/wiki/Elastic-Beanstalk-Tips-and-Tricks) (* recommended to read for new Elastic Beanstalk users )
|
128
|
+
|
129
|
+
## Contributing
|
130
|
+
|
131
|
+
1. Fork it
|
132
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
133
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
134
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
135
|
+
5. Create new Pull Request
|
136
|
+
|
137
|
+
|
138
|
+
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/ThoughtWorksStudios/eb_deployer/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
data/Rakefile
ADDED
data/TODOS.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
* Support warmup_script option, which runs after smoke test to enhance smoothness of DNS switching in Blue Green deployment.
|
2
|
+
* Wait for all auto scaling group to reach MIN size before running smoke tests in Blue Green deployment. This will make sure DNS switching not generating 50x error under big load, even without warmup steps.
|
3
|
+
* Refactoring: extract Config class wrapping config defaut and merging logic.
|
4
|
+
* Make clear solution_stack is a creation only option in document
|
5
|
+
* Updating an EB environment with a different solution_stack should give warning
|
6
|
+
* Remove all old environment settings to keep settings always sync up
|
7
|
+
* Make it possible to provide an environment specific components settings
|
8
|
+
* Support smoke_test_script option
|
9
|
+
* Document for how to use components
|
10
|
+
* Document for how to use inactive-settings
|
11
|
+
* Support bucket folders for different environments (e.g. tworker/dev,tworker/ci)
|
data/bin/eb_deploy
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
git_path = File.join(File.expand_path('../..', __FILE__), '.git')
|
4
|
+
|
5
|
+
if File.exist?(git_path)
|
6
|
+
lib_path = File.expand_path('../../lib', __FILE__)
|
7
|
+
$:.unshift(lib_path)
|
8
|
+
end
|
9
|
+
|
10
|
+
STDOUT.sync = true # Forces output after every line.
|
11
|
+
|
12
|
+
require 'eb_deployer'
|
13
|
+
EbDeployer.cli
|
data/eb_deployer.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/eb_deployer/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["wpc", "betarelease", "xli", "manheim"]
|
6
|
+
gem.email = ["tooling@manheim.com "]
|
7
|
+
gem.description = %q{For automating Blue-Green deployment flows on Elastic Beanstalk.}
|
8
|
+
gem.summary = %q{Low friction deployments should be a breeze. Elastic Beanstalk provides a great foundation for performing Blue-Green deployments, and EbDeployer add a missing top to automate the whole flow out of the box.}
|
9
|
+
gem.homepage = "https://github.com/manheim/eb_deployer"
|
10
|
+
gem.license = 'MIT'
|
11
|
+
|
12
|
+
gem.add_runtime_dependency 'aws-sdk-cloudformation', '~> 1.0'
|
13
|
+
gem.add_runtime_dependency 'aws-sdk-elasticbeanstalk', '~> 1.0'
|
14
|
+
gem.add_runtime_dependency 'aws-sdk-s3', '~> 1.0'
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($\).reject {|f| f =~ /^samples\// }
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.name = "man_eb_deployer"
|
20
|
+
gem.require_paths = ["lib"]
|
21
|
+
gem.version = EbDeployer::VERSION
|
22
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
module EbDeployer
|
3
|
+
class Application
|
4
|
+
attr_reader :name
|
5
|
+
|
6
|
+
def initialize(name, eb_driver, s3_driver, bucket = nil)
|
7
|
+
@name = name
|
8
|
+
@eb_driver = eb_driver
|
9
|
+
@s3_driver = s3_driver
|
10
|
+
@bucket = bucket || @name
|
11
|
+
raise "application name can only contain any combination of uppercase letters, lowercase letters, numbers, dashes (-)" unless @name =~ /^[a-zA-Z0-9.-]+$/
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_version(version_label, package)
|
15
|
+
create_application_if_not_exists
|
16
|
+
|
17
|
+
source_bundle = if File.exist?(package)
|
18
|
+
if File.extname(package) == '.yml'
|
19
|
+
YAML.load(File.read(package))
|
20
|
+
else
|
21
|
+
package = Package.new(package, @bucket + ".packages", @s3_driver)
|
22
|
+
package.upload
|
23
|
+
package.source_bundle
|
24
|
+
end
|
25
|
+
elsif package =~ /:/
|
26
|
+
bucket, obj_key = package.split(':')
|
27
|
+
{'s3_bucket' => bucket, 's3_key' => obj_key}
|
28
|
+
else
|
29
|
+
raise "Neither the file exists nor it is a valid s3 url: #{package.inspect}"
|
30
|
+
end
|
31
|
+
|
32
|
+
unless @eb_driver.application_version_labels(@name).include?(version_label)
|
33
|
+
log("Create application version with label #{version_label}")
|
34
|
+
@eb_driver.create_application_version(@name, version_label, source_bundle)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def delete(env_name_prefix)
|
39
|
+
if @eb_driver.application_exists?(@name)
|
40
|
+
available_envs = @eb_driver.environment_names_for_application(@name).select do |name|
|
41
|
+
name =~ /^#{env_name_prefix}-/
|
42
|
+
end
|
43
|
+
|
44
|
+
if available_envs.empty?
|
45
|
+
log("Environment #{env_name_prefix.inspect} does not exist in application #{@name.inspect}. Skipping delete.")
|
46
|
+
return
|
47
|
+
end
|
48
|
+
|
49
|
+
available_envs.each do |env|
|
50
|
+
log("Terminating environment #{env}")
|
51
|
+
@eb_driver.delete_environment(@name, env)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def versions
|
57
|
+
@eb_driver.application_versions(@name).map do |apv|
|
58
|
+
{
|
59
|
+
:version => apv[:version_label],
|
60
|
+
:date_created => apv[:date_created],
|
61
|
+
:date_updated => apv[:date_updated]
|
62
|
+
}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def remove(versions, delete_from_s3)
|
67
|
+
versions.each do |version|
|
68
|
+
begin
|
69
|
+
log("Removing #{version}")
|
70
|
+
@eb_driver.delete_application_version(@name, version, delete_from_s3)
|
71
|
+
rescue Aws::ElasticBeanstalk::Errors::SourceBundleDeletionFailure => e
|
72
|
+
log(e.message)
|
73
|
+
rescue Aws::ElasticBeanstalk::Errors::OperationInProgressFailure => e
|
74
|
+
log(e.message)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def clean_versions(version_prefix, retentions)
|
80
|
+
VersionCleaner.new(self, retentions).clean(version_prefix)
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def create_application_if_not_exists
|
86
|
+
unless @eb_driver.application_exists?(@name)
|
87
|
+
log("Creating application")
|
88
|
+
@eb_driver.create_application(@name)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def log(msg)
|
93
|
+
puts "[#{Time.now.utc}][application:#{@name}] #{msg}"
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|