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 CHANGED
@@ -1,8 +1,7 @@
1
- 0.5.2
2
- =====
1
+ 0.6.0.beta1
2
+ ===========
3
3
 
4
- * Fix issue: worker tier aws-sqsd using 1.0 version
5
- * Update multi_components example
4
+ * aws-sdk 2.0
6
5
 
7
6
  0.5.0
8
7
  =====
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-v1', '~> 1', '>= 1.61.0'
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=AWS::ElasticBeanstalk.new.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
- stack(name).exists?
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
- cloud_formation.stacks.create(name, template, opts)
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
- stack(name).update(opts.merge(:template => template))
16
- rescue AWS::CloudFormation::Errors::ValidationError => e
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
- stack(name).status.downcase.to_sym
35
+ describe_stack(name)[:stack_status].downcase.to_sym
27
36
  end
28
37
 
29
38
  def query_output(name, key)
30
- output = stack(name).outputs.find { |o| o.key == key }
31
- output && output.value
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 cloud_formation
37
- AWS::CloudFormation.new
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
- buckets.create(bucket_name)
5
+ s3.create_bucket(:bucket => bucket_name)
6
6
  end
7
7
 
8
8
  def bucket_exists?(bucket_name)
9
- buckets[bucket_name].exists?
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
- File.open(file, 'rb') { |f| o.write(f) }
18
+ o.upload_file(file)
19
19
  end
20
20
 
21
21
  private
22
22
  def s3
23
- AWS::S3.new
23
+ Aws::S3::Resource.new(client: Aws::S3::Client.new)
24
24
  end
25
25
 
26
26
  def obj(bucket_name, obj_name)
27
- buckets[bucket_name].objects[obj_name]
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 AWS::CloudFormation::Errors::ValidationError => e
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
 
@@ -44,6 +44,7 @@ module EbDeployer
44
44
 
45
45
  def digest(event)
46
46
  return nil unless event
47
+ event = event.to_h if event.respond_to?(:to_h)
47
48
  JSON.dump(event)
48
49
  end
49
50
 
@@ -1,3 +1,3 @@
1
1
  module EbDeployer
2
- VERSION = "0.5.2"
2
+ VERSION = "0.6.0.beta1"
3
3
  end
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-v1'
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
- AWS.config(:region => region)
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, AWS::ElasticBeanstalk::Errors::Throttling)
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/elastic_beanstalk'
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.client.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
@@ -290,7 +290,7 @@ class CFStub
290
290
  end
291
291
 
292
292
  def query_output(name, key)
293
- raise AWS::CloudFormation::Errors::ValidationError.new unless stack_exists?(name)
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 = AWS::ElasticBeanstalk::Errors::Throttling.new("bang!")
83
+ throttling_error = Aws::ElasticBeanstalk::Errors::Throttling.new(nil, "bang!")
84
84
  @eb.set_error(:fetch_events, throttling_error)
85
- assert_raises(AWS::ElasticBeanstalk::Errors::Throttling) do
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 = AWS::ElasticBeanstalk::Errors::Throttling.new("bang!")
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 = AWS::ElasticBeanstalk::Errors::Throttling.new("bang!")
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.2
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-v1
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: '1'
22
+ version: '2'
23
23
  - - ! '>='
24
24
  - !ruby/object:Gem::Version
25
- version: 1.61.0
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: '1'
33
+ version: '2'
34
34
  - - ! '>='
35
35
  - !ruby/object:Gem::Version
36
- version: 1.61.0
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: '0'
125
+ version: 1.3.1
126
126
  requirements: []
127
127
  rubyforge_project:
128
128
  rubygems_version: 1.8.23