eb_deployer 0.5.2 → 0.6.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +3 -4
- data/eb_deployer.gemspec +1 -1
- data/lib/eb_deployer/aws_driver/beanstalk.rb +3 -3
- data/lib/eb_deployer/aws_driver/cloud_formation_driver.rb +18 -13
- data/lib/eb_deployer/aws_driver/s3_driver.rb +5 -5
- data/lib/eb_deployer/cloud_formation_provisioner.rb +1 -1
- data/lib/eb_deployer/event_poller.rb +1 -0
- data/lib/eb_deployer/version.rb +1 -1
- data/lib/eb_deployer.rb +3 -3
- data/lib/generators/eb_deployer/install/install_generator.rb +2 -2
- data/test/aws_driver_stubs.rb +1 -1
- data/test/inplace_update_deploy_test.rb +4 -4
- metadata +9 -9
data/CHANGELOG.md
CHANGED
data/eb_deployer.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |gem|
|
|
9
9
|
gem.homepage = "https://github.com/ThoughtWorksStudios/eb_deployer"
|
10
10
|
gem.license = 'MIT'
|
11
11
|
|
12
|
-
gem.add_runtime_dependency 'aws-sdk
|
12
|
+
gem.add_runtime_dependency 'aws-sdk', '~> 2', '>= 2.0.0'
|
13
13
|
|
14
14
|
gem.files = `git ls-files`.split($\).reject {|f| f =~ /^samples\// }
|
15
15
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -4,7 +4,7 @@ module EbDeployer
|
|
4
4
|
include Utils
|
5
5
|
attr_reader :client
|
6
6
|
|
7
|
-
def initialize(client=
|
7
|
+
def initialize(client=Aws::ElasticBeanstalk::Client.new)
|
8
8
|
@client = client
|
9
9
|
end
|
10
10
|
|
@@ -121,8 +121,8 @@ module EbDeployer
|
|
121
121
|
private
|
122
122
|
|
123
123
|
TIERS = [
|
124
|
-
{:name=>"Worker", :type=>"SQS/HTTP"},
|
125
|
-
{:name=>"WebServer", :type=>"Standard"}
|
124
|
+
{:name=>"Worker", :type=>"SQS/HTTP", :version=>"1.0"},
|
125
|
+
{:name=>"WebServer", :type=>"Standard", :version=>"1.0"}
|
126
126
|
]
|
127
127
|
|
128
128
|
def get_environment_attribute(app_name, env_name, attribute)
|
@@ -2,18 +2,27 @@ module EbDeployer
|
|
2
2
|
module AWSDriver
|
3
3
|
class CloudFormationDriver
|
4
4
|
|
5
|
+
def initialize
|
6
|
+
@client = Aws::CloudFormation::Client.new
|
7
|
+
end
|
8
|
+
|
5
9
|
def stack_exists?(name)
|
6
|
-
|
10
|
+
describe_stack(name)
|
11
|
+
true
|
12
|
+
rescue Aws::CloudFormation::Errors::ValidationError
|
13
|
+
false
|
7
14
|
end
|
8
15
|
|
9
16
|
def create_stack(name, template, opts)
|
10
|
-
|
17
|
+
@client.create_stack(opts.merge(:stack_name => name,
|
18
|
+
:template_body => template))
|
11
19
|
end
|
12
20
|
|
13
21
|
def update_stack(name, template, opts)
|
14
22
|
begin
|
15
|
-
|
16
|
-
|
23
|
+
@client.update_stack(opts.merge(:stack_name => name,
|
24
|
+
:template_body => template))
|
25
|
+
rescue Aws::CloudFormation::Errors::ValidationError => e
|
17
26
|
if e.message =~ /No updates are to be performed/
|
18
27
|
log(e.message)
|
19
28
|
else
|
@@ -23,22 +32,18 @@ module EbDeployer
|
|
23
32
|
end
|
24
33
|
|
25
34
|
def stack_status(name)
|
26
|
-
|
35
|
+
describe_stack(name)[:stack_status].downcase.to_sym
|
27
36
|
end
|
28
37
|
|
29
38
|
def query_output(name, key)
|
30
|
-
output =
|
31
|
-
output && output
|
39
|
+
output = describe_stack(name)[:outputs].find { |o| o[:output_key] == key }
|
40
|
+
output && output[:output_value]
|
32
41
|
end
|
33
42
|
|
34
43
|
private
|
35
44
|
|
36
|
-
def
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
def stack(name)
|
41
|
-
cloud_formation.stacks[name]
|
45
|
+
def describe_stack(name)
|
46
|
+
@client.describe_stacks(:stack_name => name)[:stacks].first
|
42
47
|
end
|
43
48
|
|
44
49
|
def log(msg)
|
@@ -2,11 +2,11 @@ module EbDeployer
|
|
2
2
|
module AWSDriver
|
3
3
|
class S3Driver
|
4
4
|
def create_bucket(bucket_name)
|
5
|
-
|
5
|
+
s3.create_bucket(:bucket => bucket_name)
|
6
6
|
end
|
7
7
|
|
8
8
|
def bucket_exists?(bucket_name)
|
9
|
-
|
9
|
+
s3.bucket(bucket_name).exists?
|
10
10
|
end
|
11
11
|
|
12
12
|
def object_length(bucket_name, obj_name)
|
@@ -15,16 +15,16 @@ module EbDeployer
|
|
15
15
|
|
16
16
|
def upload_file(bucket_name, obj_name, file)
|
17
17
|
o = obj(bucket_name, obj_name)
|
18
|
-
|
18
|
+
o.upload_file(file)
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
22
22
|
def s3
|
23
|
-
|
23
|
+
Aws::S3::Resource.new(client: Aws::S3::Client.new)
|
24
24
|
end
|
25
25
|
|
26
26
|
def obj(bucket_name, obj_name)
|
27
|
-
|
27
|
+
s3.bucket(bucket_name).object(obj_name)
|
28
28
|
end
|
29
29
|
|
30
30
|
def buckets
|
@@ -29,7 +29,7 @@ module EbDeployer
|
|
29
29
|
|
30
30
|
def output(key)
|
31
31
|
@cf_driver.query_output(@stack_name, key)
|
32
|
-
rescue
|
32
|
+
rescue Aws::CloudFormation::Errors::ValidationError
|
33
33
|
raise ResourceNotInReadyState.new("Resource stack not in ready state yet, perhaps you should provision it first?")
|
34
34
|
end
|
35
35
|
|
data/lib/eb_deployer/version.rb
CHANGED
data/lib/eb_deployer.rb
CHANGED
@@ -3,7 +3,7 @@ require 'set'
|
|
3
3
|
require 'time'
|
4
4
|
require 'json'
|
5
5
|
require 'timeout'
|
6
|
-
require 'aws-sdk
|
6
|
+
require 'aws-sdk'
|
7
7
|
require 'optparse'
|
8
8
|
require 'erb'
|
9
9
|
require 'fileutils'
|
@@ -171,11 +171,11 @@ module EbDeployer
|
|
171
171
|
# version_prefix is given, only removes version starting with the prefix.
|
172
172
|
def self.deploy(opts)
|
173
173
|
if region = opts[:region]
|
174
|
-
|
174
|
+
Aws.config.update(:region => region)
|
175
175
|
end
|
176
176
|
|
177
177
|
bs = opts[:bs_driver] || AWSDriver::Beanstalk.new
|
178
|
-
bs = ThrottlingHandling.new(bs,
|
178
|
+
bs = ThrottlingHandling.new(bs, Aws::ElasticBeanstalk::Errors::Throttling)
|
179
179
|
s3 = opts[:s3_driver] || AWSDriver::S3Driver.new
|
180
180
|
cf = opts[:cf_driver] || AWSDriver::CloudFormationDriver.new
|
181
181
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'rails/generators'
|
2
2
|
require 'eb_deployer/default_config'
|
3
|
-
require 'aws
|
3
|
+
require 'aws-sdk'
|
4
4
|
require 'securerandom'
|
5
5
|
|
6
6
|
module EbDeployer
|
@@ -59,7 +59,7 @@ YAML
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def solution_stack_name
|
62
|
-
AWS::ElasticBeanstalk.new.
|
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
|
data/test/aws_driver_stubs.rb
CHANGED
@@ -290,7 +290,7 @@ class CFStub
|
|
290
290
|
end
|
291
291
|
|
292
292
|
def query_output(name, key)
|
293
|
-
raise
|
293
|
+
raise Aws::CloudFormation::Errors::ValidationError.new(nil, nil) unless stack_exists?(name)
|
294
294
|
"value of #{key}"
|
295
295
|
end
|
296
296
|
|
@@ -80,15 +80,15 @@ class InplaceUpdateDeployTest < DeployTest
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def test_deploy_should_raise_error_when_constantly_hitting_throttling_error
|
83
|
-
throttling_error =
|
83
|
+
throttling_error = Aws::ElasticBeanstalk::Errors::Throttling.new(nil, "bang!")
|
84
84
|
@eb.set_error(:fetch_events, throttling_error)
|
85
|
-
assert_raises(
|
85
|
+
assert_raises(Aws::ElasticBeanstalk::Errors::Throttling) do
|
86
86
|
deploy(:application => 'simple', :environment => "production")
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
90
|
def test_deploy_should_retry_on_temporary_throttling_error_from_fetch_events
|
91
|
-
throttling_error =
|
91
|
+
throttling_error = Aws::ElasticBeanstalk::Errors::Throttling.new(nil, "bang!")
|
92
92
|
error_seq = [throttling_error] * 5
|
93
93
|
@eb.set_error_generator(:fetch_events) do
|
94
94
|
error_seq.pop
|
@@ -98,7 +98,7 @@ class InplaceUpdateDeployTest < DeployTest
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def test_deploy_should_retry_on_temporary_throttling_error_from_create_env
|
101
|
-
throttling_error =
|
101
|
+
throttling_error = Aws::ElasticBeanstalk::Errors::Throttling.new(nil, "bang!")
|
102
102
|
error_seq = [throttling_error] * 5
|
103
103
|
@eb.set_error_generator(:create_environment) do
|
104
104
|
error_seq.pop
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eb_deployer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.6.0.beta1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- wpc
|
@@ -13,16 +13,16 @@ cert_chain: []
|
|
13
13
|
date: 2015-05-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name: aws-sdk
|
16
|
+
name: aws-sdk
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '2'
|
23
23
|
- - ! '>='
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version:
|
25
|
+
version: 2.0.0
|
26
26
|
type: :runtime
|
27
27
|
prerelease: false
|
28
28
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -30,10 +30,10 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2'
|
34
34
|
- - ! '>='
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version:
|
36
|
+
version: 2.0.0
|
37
37
|
description: For automating Blue-Green deployment flows on Elastic Beanstalk.
|
38
38
|
email:
|
39
39
|
- alex.hal9000@gmail.com
|
@@ -120,9 +120,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
121
|
none: false
|
122
122
|
requirements:
|
123
|
-
- - ! '
|
123
|
+
- - ! '>'
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
125
|
+
version: 1.3.1
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project:
|
128
128
|
rubygems_version: 1.8.23
|