eb_deployer 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e8d42e8522c7f436251552c366a5728fc18e296
4
- data.tar.gz: c1a3115f32a1af1e620f6459297ecc6e555352ed
3
+ metadata.gz: db0cf300a1d06c7b6ed063eef7ef69c7cab8d025
4
+ data.tar.gz: 5acf245e16a6c1ce4b4d35ad1d1544d5185b2329
5
5
  SHA512:
6
- metadata.gz: a6699965fc55694e54849017d63dfef003a30e122a98d3a58deff42ef4c22670d83e57f5cb4fb2b33362c9fe117b8c18e3e165809d58b7c2648195554399fc19
7
- data.tar.gz: c14d0f2152bebd7326fe1206ae9bb0b9208cd0c7ad317f10f6e2f117277ef578e7636043032fdc505f6bb77eec794c3efffa1abf2e3f6acd1aad96a05b353a7d
6
+ metadata.gz: 35071cab562e78eae3485b15b2d81d328c5ae5618ea5fdc56dd7b8d7335bca0aa5c8937547b3474fe9194175ab093f75b2bca139b58740bb737da23ad7ae37f9
7
+ data.tar.gz: 9a4f03e8d7a4a0a769e749d4d191b9feeec7def2ad598ffa41b36e72191dad9b46964efc8b9e5d8b37670678d322eaec57f46e640813dcafe5ad07065808e8e6
data/README.md CHANGED
@@ -73,8 +73,12 @@ Once this new stack is stable or has run for a while you can choose to delete th
73
73
  ### Destroying a stack
74
74
  So you are done with this application or environment, you can destroy it easily as well.
75
75
 
76
+ # destroy one environment
76
77
  $ eb_deployer -d -e <environment>
77
78
 
79
+ # alternatively, destroy all environments and the application along with it
80
+ $ eb_deployer -d --all
81
+
78
82
  and you are done!
79
83
 
80
84
  Later tutorials coming soon will cover
data/lib/eb_deployer.rb CHANGED
@@ -24,6 +24,15 @@ require 'fileutils'
24
24
 
25
25
  module EbDeployer
26
26
 
27
+ TIERS = [
28
+ {:name=>"Worker", :type=>"SQS/HTTP", :version=>"1.0"},
29
+ {:name=>"WebServer", :type=>"Standard", :version=>"1.0"}
30
+ ]
31
+
32
+ def environment_tier(name)
33
+ TIERS.find {|t| t[:name].downcase == name.downcase} || raise("No tier found with name #{name.inspect}")
34
+ end
35
+ module_function :environment_tier
27
36
  #
28
37
  # Query ouput value of the cloud formation stack
29
38
  #
@@ -140,9 +149,12 @@ module EbDeployer
140
149
  # inplace-update strategy will only keep one environment, and update the
141
150
  # version inplace on deploy. this will save resources but will have downtime.
142
151
  #
143
- # @option opts [Symbol] :solution_stack_name ("64bit Amazon Linux running Tomcat 7")
152
+ # @option opts [Symbol] :solution_stack_name ("64bit Amazon Linux 2013.09 running Tomcat 7 Java 7")
144
153
  # The elastic beanstalk solution stack you want to deploy on top of.
145
154
  #
155
+ # @option opts [Symbol] :tier ("WebServer")
156
+ # The environment tier. Either "WebServer" or "Worker"
157
+ #
146
158
  # @option opts [Symbol] :version_label *required*. Version label give the
147
159
  # package uploaded a unique identifier. Should use something related to
148
160
  # pipeline counter if you have build pipeline setup to build the installer.
@@ -168,7 +180,7 @@ module EbDeployer
168
180
  bs = opts[:bs_driver] || Beanstalk.new
169
181
  s3 = opts[:s3_driver] || S3Driver.new
170
182
  cf = opts[:cf_driver] || CloudFormationDriver.new
171
- stack_name = opts[:solution_stack_name] || "64bit Amazon Linux running Tomcat 7"
183
+ stack_name = opts[:solution_stack_name] || "64bit Amazon Linux 2013.09 running Tomcat 7 Java 7"
172
184
  app = opts[:application]
173
185
  env_name = opts[:environment]
174
186
  version_prefix = opts[:version_prefix].to_s.strip
@@ -182,16 +194,21 @@ module EbDeployer
182
194
  bucket = opts[:package_bucket] || app
183
195
  skip_resource = opts[:skip_resource_stack_update]
184
196
  keep_latest = opts[:keep_latest].to_i || 0
197
+ app_tier = self.environment_tier(opts[:tier] || 'WebServer')
185
198
 
186
199
  application = Application.new(app, bs, s3, bucket)
187
200
 
188
201
  cf = CloudFormationProvisioner.new("#{app}-#{env_name}", cf)
189
202
 
190
- strategy = DeploymentStrategy.create(strategy_name, app, env_name, bs,
191
- :solution_stack => stack_name,
192
- :cname_prefix => cname_prefix,
193
- :smoke_test => smoke_test,
194
- :phoenix_mode => phoenix_mode)
203
+ creation_opts = {
204
+ :solution_stack => stack_name,
205
+ :cname_prefix => cname_prefix,
206
+ :smoke_test => smoke_test,
207
+ :phoenix_mode => phoenix_mode,
208
+ :tier => app_tier
209
+ }
210
+
211
+ strategy = DeploymentStrategy.create(strategy_name, app, env_name, bs, creation_opts)
195
212
 
196
213
  cleaner = VersionCleaner.new(application, keep_latest)
197
214
 
@@ -1,6 +1,7 @@
1
1
  module EbDeployer
2
2
  class Beanstalk
3
3
  attr_reader :client
4
+
4
5
  def initialize(client=AWS::ElasticBeanstalk.new.client)
5
6
  @client = client
6
7
  end
@@ -17,11 +18,16 @@ module EbDeployer
17
18
  @client.describe_applications(:application_names => [app])[:applications].any?
18
19
  end
19
20
 
20
- def update_environment(app_name, env_name, version, settings)
21
+ def update_environment(app_name, env_name, version, tier, settings)
21
22
  env_id = convert_env_name_to_id(app_name, [env_name]).first
22
- @client.update_environment(:environment_id => env_id,
23
- :version_label => version,
24
- :option_settings => settings)
23
+ request = {
24
+ :environment_id => env_id,
25
+ :version_label => version,
26
+ :option_settings => settings,
27
+ :tier => tier
28
+ }
29
+
30
+ @client.update_environment(request)
25
31
  end
26
32
 
27
33
  def environment_exists?(app_name, env_name)
@@ -32,13 +38,17 @@ module EbDeployer
32
38
  alive_envs(app_name).collect { |env| env[:environment_name] }
33
39
  end
34
40
 
35
- def create_environment(app_name, env_name, stack_name, cname_prefix, version, settings)
36
- request = {:application_name => app_name,
41
+ def create_environment(app_name, env_name, stack_name, cname_prefix, version, tier, settings)
42
+ request = {
43
+ :application_name => app_name,
37
44
  :environment_name => env_name,
38
45
  :solution_stack_name => stack_name,
39
46
  :version_label => version,
40
- :option_settings => settings }
41
- request[:cname_prefix] = cname_prefix if cname_prefix
47
+ :option_settings => settings,
48
+ :tier => tier,
49
+ :cname_prefix => cname_prefix
50
+ }
51
+
42
52
  @client.create_environment(request)
43
53
  end
44
54
 
@@ -4,7 +4,10 @@ application: <%= app_name %>
4
4
  # common settings for all environments
5
5
  common:
6
6
  # Solution stack for elastic beanstalk, default is 64bit tomcat 7 for JAVA app
7
- # solution_stack_name: 64bit Amazon Linux running Tomcat 7
7
+ # solution_stack_name: 64bit Amazon Linux 2013.09 running Tomcat 7 Java 7
8
+
9
+ # Tier name for environments. Current supported values are WebServer and Worker
10
+ # tier: WebServer
8
11
 
9
12
  # AWS region to deploy. Default to us-east-1
10
13
  # region: us-west-1
@@ -54,11 +54,11 @@ module EbDeployer
54
54
  def create_or_update_env(version_label, settings)
55
55
  if @bs.environment_exists?(@app, @name)
56
56
  with_polling_events(/Environment update completed successfully/i) do
57
- @bs.update_environment(@app, @name, version_label, settings)
57
+ @bs.update_environment(@app, @name, version_label, @creation_opts[:tier], settings)
58
58
  end
59
59
  else
60
60
  with_polling_events(/Successfully launched environment/i) do
61
- @bs.create_environment(@app, @name, @creation_opts[:solution_stack], @creation_opts[:cname_prefix], version_label, settings)
61
+ @bs.create_environment(@app, @name, @creation_opts[:solution_stack], @creation_opts[:cname_prefix], version_label, @creation_opts[:tier], settings)
62
62
  end
63
63
  end
64
64
  end
@@ -1,3 +1,3 @@
1
1
  module EbDeployer
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
@@ -21,7 +21,7 @@ class EBStub
21
21
  @apps.include?(app)
22
22
  end
23
23
 
24
- def create_environment(app, env, solution_stack, cname_prefix, version, settings)
24
+ def create_environment(app, env, solution_stack, cname_prefix, version, tier, settings)
25
25
  raise 'cname prefix is not avaible' if @envs.values.detect { |env| env[:cname_prefix] == cname_prefix }
26
26
  raise "env name #{env} is longer than 23 chars" if env.size > 23
27
27
  raise "app not exists" unless application_exists?(app)
@@ -31,6 +31,7 @@ class EBStub
31
31
  :solution_stack => solution_stack,
32
32
  :version => version,
33
33
  :cname_prefix => cname_prefix,
34
+ :tier => tier,
34
35
  :settings => settings}
35
36
  end
36
37
 
@@ -40,8 +41,8 @@ class EBStub
40
41
  @envs_been_deleted[app] << env
41
42
  end
42
43
 
43
- def update_environment(app, env, version, settings)
44
- @envs[env_key(app, env)].merge!(:version => version, :settings => settings)
44
+ def update_environment(app, env, version, tier, settings)
45
+ @envs[env_key(app, env)].merge!(:version => version, :settings => settings, :tier => tier)
45
46
  end
46
47
 
47
48
  def environment_exists?(app_name, env_name)
@@ -114,6 +115,11 @@ class EBStub
114
115
  @envs[env_key(app_name, env_name)][:version]
115
116
  end
116
117
 
118
+ def environment_tier(app_name, env_name)
119
+ @envs[env_key(app_name, env_name)][:tier]
120
+ end
121
+
122
+
117
123
  def environment_settings(app_name, env_name)
118
124
  @envs[env_key(app_name, env_name)][:settings]
119
125
  end
data/test/deploy_test.rb CHANGED
@@ -403,6 +403,23 @@ class DeployTest < MiniTest::Unit::TestCase
403
403
  assert_equal @sample_package, s3_objects.values.first.to_s
404
404
  end
405
405
 
406
+ def test_sets_default_tier_as_webserver
407
+ deploy(:application => 'simple', :environment => "production")
408
+ assert_equal EbDeployer.environment_tier('WebServer'), @eb_driver.environment_tier('simple', eb_envname('simple', 'production'))
409
+ end
410
+
411
+ def test_can_change_tier
412
+ deploy(:application => 'simple', :environment => "production", :tier => 'Worker')
413
+ assert_equal EbDeployer.environment_tier('Worker'), @eb_driver.environment_tier('simple', eb_envname('simple', 'production'))
414
+ end
415
+
416
+ def test_should_raise_error_when_tier_setting_is_not_recognized
417
+ assert_raises(RuntimeError) do
418
+ deploy(:application => 'simple', :environment => "production", :tier => 'Gum')
419
+ end
420
+ end
421
+
422
+
406
423
  private
407
424
 
408
425
  def temp_file(content)
metadata CHANGED
@@ -1,30 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eb_deployer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - wpc
8
8
  - betarelease
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-05 00:00:00.000000000 Z
12
+ date: 2014-03-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
16
- version_requirements: !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0'
21
- requirement: !ruby/object:Gem::Requirement
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
22
24
  requirements:
23
- - - '>='
25
+ - - ">="
24
26
  - !ruby/object:Gem::Version
25
27
  version: '0'
26
- prerelease: false
27
- type: :runtime
28
28
  description: For automating Blue-Green deployment flows on Elastic Beanstalk.
29
29
  email:
30
30
  - alex.hal9000@gmail.com
@@ -34,9 +34,9 @@ executables:
34
34
  extensions: []
35
35
  extra_rdoc_files: []
36
36
  files:
37
- - .gitignore
38
- - .ruby-gemset
39
- - .ruby-version
37
+ - ".gitignore"
38
+ - ".ruby-gemset"
39
+ - ".ruby-version"
40
40
  - Gemfile
41
41
  - LICENSE
42
42
  - README.md
@@ -70,26 +70,28 @@ homepage: https://github.com/ThoughtWorksStudios/eb_deployer
70
70
  licenses:
71
71
  - MIT
72
72
  metadata: {}
73
- post_install_message:
73
+ post_install_message:
74
74
  rdoc_options: []
75
75
  require_paths:
76
76
  - lib
77
77
  required_ruby_version: !ruby/object:Gem::Requirement
78
78
  requirements:
79
- - - '>='
79
+ - - ">="
80
80
  - !ruby/object:Gem::Version
81
81
  version: '0'
82
82
  required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  requirements:
84
- - - '>='
84
+ - - ">="
85
85
  - !ruby/object:Gem::Version
86
86
  version: '0'
87
87
  requirements: []
88
- rubyforge_project:
89
- rubygems_version: 2.2.1
90
- signing_key:
88
+ rubyforge_project:
89
+ rubygems_version: 2.2.2
90
+ signing_key:
91
91
  specification_version: 4
92
- summary: 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.
92
+ summary: Low friction deployments should be a breeze. Elastic Beanstalk provides a
93
+ great foundation for performing Blue-Green deployments, and EbDeployer add a missing
94
+ top to automate the whole flow out of the box.
93
95
  test_files:
94
96
  - test/aws_driver_stubs.rb
95
97
  - test/cloud_formation_provisioner_test.rb