eb_deployer 0.6.1 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a339b19fefcb73b8a72dc75be71acdd5c687e51d
4
- data.tar.gz: 20ab402493ce588c41f77193d65ff54bad160f05
3
+ metadata.gz: 737e66cde134b8ec8983b1dfc500adedab3cf526
4
+ data.tar.gz: 9e54bffac3fbd172d2f4d36a15aa4dc9502d6210
5
5
  SHA512:
6
- metadata.gz: 029d124d285bcf266aa87313399ad9eb6badcf08a4f305b89ae0811dbbe7ec9dc29c8896f8965108fca94aea22b028cba32f175c80f93f9b276f86a0fee38a50
7
- data.tar.gz: 75e13ca3c1f39f06a81b0db7be58b1d2da79852aeceb4d06af9ad5d5379d90696534c0168e6382cf2ecdd320ce00a210c7d5bd26876492a5ae27ea19b5bd941d
6
+ metadata.gz: 1efa091565e68ddee6a383bb6c9b343199a40aaf4f381a8bd96faac1b38c4a390aba3fce924e6e45b79d5fe165fbace47dea0d81246b96050de6123f4aff905a
7
+ data.tar.gz: 678ceb2f2fa5f752b133edabbb451c8a9fb5d459bf86e51e95c20065b985cd047aa85f6ac5008065ee84e52521778771f7bc6226ae51c26b52f9385e51c19972
data/README.md CHANGED
@@ -1,11 +1,9 @@
1
- # EbDeployer [![Build Status](https://snap-ci.com/ThoughtWorksStudios/eb_deployer/branch/master/build_image)](https://snap-ci.com/ThoughtWorksStudios/eb_deployer/branch/master) [![Build Status](https://travis-ci.org/ThoughtWorksStudios/eb_deployer.png?branch=master)](https://travis-ci.org/ThoughtWorksStudios/eb_deployer) [![Gem Version](https://badge.fury.io/rb/eb_deployer.svg)](http://badge.fury.io/rb/eb_deployer)
1
+ # EbDeployer [![Build Status](https://snap-ci.com/ThoughtWorksStudios/eb_deployer/branch/master/build_image)](https://snap-ci.com/ThoughtWorksStudios/eb_deployer/branch/master) [![Build Status](https://travis-ci.org/ThoughtWorksStudios/eb_deployer.png?branch=master)](https://travis-ci.org/ThoughtWorksStudios/eb_deployer) [![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
2
 
3
3
  [Built with :yellow_heart: and :coffee: in San Francisco](http://www.thoughtworks.com/mingle/team/)
4
4
 
5
5
  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.
6
6
 
7
- EbDeployer thus allows you to do continuous delivery on AWS.
8
-
9
7
  [Deploy Service by EbDeployer](http://www.thoughtworks.com/mingle/infrastructure/2015/06/01/deploy-service-by-ebdeployer.html)
10
8
 
11
9
  ## Installation
@@ -93,18 +91,26 @@ Take a look at code if you can not wait for the documentation.
93
91
 
94
92
  ### eb_deploy.yml configuration file
95
93
 
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.
94
+ 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:
95
+
96
+ resources:
97
+ template: config/my_rds.json
98
+ inputs:
99
+ DBPassword: <%= ENV['MYDBPASSWORD'] %>
97
100
 
98
- By default, EbDeployer provides the following methods:
101
+
102
+ EbDeployer also provides the following help methods for convenience:
99
103
 
100
104
  1. random_hash: it basically is `SecureRandom.hex[0..9]`
101
105
  2. package_digest: it is your eb package file digest
102
- 3. environment: environment name you passed in when executing eb_deploy script.
106
+ 3. environment: environment name you passed in when executing eb_deploy script using -e option.
103
107
 
104
108
  ## More
105
109
 
106
110
  [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)
107
111
 
112
+ 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)
113
+
108
114
  [Deploy Service by EbDeployer](http://www.thoughtworks.com/mingle/infrastructure/2015/06/01/deploy-service-by-ebdeployer.html)
109
115
 
110
116
  [Rails 3/4 Support](https://github.com/ThoughtWorksStudios/eb_deployer/wiki/Rails-3-Support)
@@ -113,10 +119,11 @@ By default, EbDeployer provides the following methods:
113
119
 
114
120
  [Introduction to EbDeployer](http://getmingle.io/scaling/2014/06/13/introduction-to-eb-deployer.html)
115
121
 
116
- 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)
117
-
118
122
  [Papertrail Solution for Rails Applications on ElasticBeanstalk
119
123
  ](http://www.thoughtworks.com/mingle/infrastructure/2015/06/10/simple-solution-for-papertrail-on-elasticbeanstalk.html)
124
+
125
+ [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 )
126
+
120
127
  ## Contributing
121
128
 
122
129
  1. Fork it
@@ -68,9 +68,9 @@ module EbDeployer
68
68
  begin
69
69
  log("Removing #{version}")
70
70
  @eb_driver.delete_application_version(@name, version, delete_from_s3)
71
- rescue AWS::ElasticBeanstalk::Errors::SourceBundleDeletionFailure => e
71
+ rescue Aws::ElasticBeanstalk::Errors::SourceBundleDeletionFailure => e
72
72
  log(e.message)
73
- rescue AWS::ElasticBeanstalk::Errors::OperationInProgressFailure => e
73
+ rescue Aws::ElasticBeanstalk::Errors::OperationInProgressFailure => e
74
74
  log(e.message)
75
75
  end
76
76
  end
@@ -6,13 +6,16 @@ module EbDeployer
6
6
  end
7
7
 
8
8
  def test_compatibility(env_create_options)
9
+ @create_opts = env_create_options
9
10
  tier = env_create_options[:tier]
11
+
10
12
  if tier && tier.downcase == 'worker'
11
13
  raise "Blue green deployment is not supported for Worker tier"
12
14
  end
13
15
  end
14
16
 
15
17
  def deploy(version_label, env_settings, inactive_settings=[])
18
+
16
19
  if !ebenvs.any?(&method(:active_ebenv?))
17
20
  ebenv('a', @component.cname_prefix).
18
21
  deploy(version_label, env_settings)
@@ -24,7 +27,32 @@ module EbDeployer
24
27
 
25
28
  inactive_ebenv.deploy(version_label, env_settings)
26
29
  active_ebenv.swap_cname_with(inactive_ebenv)
27
- unless inactive_settings.empty?
30
+
31
+ blue_green_terminate_inactive = @create_opts[:blue_green_terminate_inactive]
32
+ blue_green_terminate_inactive_wait = @create_opts[:blue_green_terminate_inactive_wait]
33
+ blue_green_terminate_inactive_sleep = @create_opts[:blue_green_terminate_inactive_sleep]
34
+
35
+ if blue_green_terminate_inactive
36
+ active_ebenv.log("Waiting #{blue_green_terminate_inactive_wait}s before terminating environment...")
37
+
38
+ # Loop until timeout reached or environment becomes Red
39
+ count = 0
40
+ loop do
41
+ break if count >= blue_green_terminate_inactive_wait or inactive_ebenv.health_state != 'Green'
42
+ sleep blue_green_terminate_inactive_sleep
43
+ count += blue_green_terminate_inactive_sleep
44
+ end
45
+
46
+ if inactive_ebenv.health_state == 'Green'
47
+ active_ebenv.log("Active environment healthy, terminating inactive (black) environment")
48
+ active_ebenv.terminate
49
+ else
50
+ active_ebenv.log("Active environment changed state to unhealthy. Existing (black) environment will not be terminated")
51
+ end
52
+
53
+ end
54
+
55
+ unless inactive_settings.empty? || blue_green_terminate_inactive
28
56
  active_ebenv.log("applying inactive settings...")
29
57
  active_ebenv.apply_settings(inactive_settings)
30
58
  end
@@ -61,6 +61,10 @@ module EbDeployer
61
61
  end
62
62
  end
63
63
 
64
+ def health_state
65
+ @bs.environment_health_state(@app, @name)
66
+ end
67
+
64
68
  private
65
69
 
66
70
  def configured_tier
@@ -4,7 +4,7 @@ module EbDeployer
4
4
 
5
5
  # A util deal with throttling exceptions
6
6
  # example:
7
- # backoff(AWS::EC2::Errors::RequestLimitExceeded) do
7
+ # backoff(Aws::EC2::Errors::RequestLimitExceeded) do
8
8
  # ...
9
9
  # end
10
10
  def backoff(error_class, retry_limit=9, &block)
@@ -1,3 +1,3 @@
1
1
  module EbDeployer
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
data/lib/eb_deployer.rb CHANGED
@@ -95,7 +95,7 @@ module EbDeployer
95
95
  # will terminate the old elastic beanstalk environment and recreate on
96
96
  # deploy. For blue-green deployment it terminate the inactive environment
97
97
  # first then recreate it. This is useful to avoiding configuration drift and
98
- # accumulating state on the EC2 instances. Also it has the benifit of keeping
98
+ # accumulating state on the EC2 instances. Also it has the benefit of keeping
99
99
  # your EC2 instance system package upto date, because everytime EC2 instance
100
100
  # boot up from AMI it does a system update.
101
101
  #
@@ -204,6 +204,9 @@ module EbDeployer
204
204
  :cname_prefix => opts[:cname_prefix],
205
205
  :smoke_test => opts[:smoke_test],
206
206
  :phoenix_mode => opts[:phoenix_mode],
207
+ :blue_green_terminate_inactive => opts[:blue_green_terminate_inactive] || false,
208
+ :blue_green_terminate_inactive_wait => opts[:blue_green_terminate_inactive_wait] || 600,
209
+ :blue_green_terminate_inactive_sleep => opts[:blue_green_terminate_inactive_sleep] || 15,
207
210
  :tags => opts[:tags],
208
211
  :tier => opts[:tier]
209
212
  }
@@ -302,7 +305,7 @@ module EbDeployer
302
305
  require 'aws-sdk'
303
306
  logger = Logger.new($stdout)
304
307
  logger.level = Logger::DEBUG
305
- Aws.config[:logger] = logger
308
+ Aws.config.update(:logger => logger)
306
309
  end
307
310
 
308
311
  opts.on("-h", "--help", "help") do
@@ -59,7 +59,7 @@ YAML
59
59
  end
60
60
 
61
61
  def solution_stack_name
62
- AWS::ElasticBeanstalk.Client.new.list_available_solution_stacks[:solution_stacks].find do |s|
62
+ Aws::ElasticBeanstalk.Client.new.list_available_solution_stacks[:solution_stacks].find do |s|
63
63
  s =~ /Amazon Linux/ && s =~ /running Ruby 2.1 \(Passenger Standalone\)/
64
64
  end
65
65
  rescue
@@ -37,6 +37,21 @@ common:
37
37
  # you override it to 'on' for production environment.
38
38
  # phoenix_mode: false
39
39
 
40
+ # Terminates the inactive stack upon successful blue-green deployment.
41
+ # This is useful if you require HA deployment but don't want the cost of running
42
+ # a stack that is not in use. See https://github.com/ThoughtWorksStudios/eb_deployer/pull/44/
43
+ # for other strategies that can be employed.
44
+ # Note: As EB Deployer uses DNS to switch between stacks, this should be used only if you
45
+ # both put in a sufficient wait period and accept the risk that traffic may still be
46
+ # going to the inactive stack when it is terminated, due to client DNS caching, for example.
47
+ #blue_green_terminate_inactive: false
48
+
49
+ # How long to wait before terminating the inactive stack if 'blue_green_terminate_inactive' is set to true.
50
+ #blue_green_terminate_inactive_wait: 600
51
+
52
+ # How often to check for changes to the inactive stack during the 'blue_green_terminate_inactive_wait' period.
53
+ #blue_green_terminate_inactive_sleep: 15
54
+
40
55
  # Specifies the maximum number of versions to keep. Older versions are removed
41
56
  # and deleted from the S3 source bucket as well. If specified as zero or not
42
57
  # specified, all versions will be kept. If a version_prefix is given, only removes
@@ -39,6 +39,13 @@ class BlueGreenDeployTest < DeployTest
39
39
  'simple-production-inactive.elasticbeanstalk.com'], smoked_host
40
40
  end
41
41
 
42
+ def test_blue_green_deploy_should_blue_green_terminate_inactive_env_if_blue_green_terminate_inactive_is_enabled
43
+ do_deploy(42, :blue_green_terminate_inactive => true, :blue_green_terminate_inactive_wait => 1, :blue_green_terminate_inactive_sleep => 1)
44
+ do_deploy(43, :blue_green_terminate_inactive => true, :blue_green_terminate_inactive_wait => 0, :blue_green_terminate_inactive_sleep => 0)
45
+
46
+ inactive_env = t('production-a', 'simple')
47
+ assert_equal [inactive_env], @eb.environments_been_deleted('simple')
48
+ end
42
49
 
43
50
  def test_blue_green_deployment_should_delete_and_recreate_inactive_env_if_phoenix_mode_is_enabled
44
51
  do_deploy(42, :phoenix_mode => true)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eb_deployer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - wpc
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-27 00:00:00.000000000 Z
12
+ date: 2015-09-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk