elastic-beanstalk 1.1.11 → 1.1.12

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: d354c6756a2e698c5ca9e83c732a58715544ebef
4
- data.tar.gz: ba0cd850520daa047c87e9b7cce7c93909718d83
3
+ metadata.gz: a2f7ad000128a315ac2e977837675b9748b2a3c8
4
+ data.tar.gz: b9635f456392b73eb7fc0c7e006b84762e36a042
5
5
  SHA512:
6
- metadata.gz: d165b0319d7b084bb924638c818850ef6497a4a3b71f244a1e58a8ec2624884133d4a8d88c31ade14f674a1baeea36e6ed5cd20a5bbc90a93c6ddc45b08b2a1d
7
- data.tar.gz: 0289195957213234ebd3c3bda1a38a6d825f901f3e677012a544a88d7dbd27d57f38ce631ca5665f975dfd2a9cf91a240cd07c6c74a9bd5207280954749cf0ec
6
+ metadata.gz: 1193ddd38c373267a2d57c0fe1818311abe45a186acad424a70206d67151f98e0ea5d6280f526ca0706053540bfa5b15b7e71533d994daad26d9df90427c061d
7
+ data.tar.gz: e3ac2c58fb5d4b77eda3fa319736b3f181f39509439bea46a8d594299e76d6d056d6ed3938826aae4af85125f63a9c8bc2e20013ddd315fc91d7b4314719c425
data/README.md CHANGED
@@ -213,6 +213,15 @@ options:
213
213
 
214
214
  aws:elasticbeanstalk:application:
215
215
  Application Healthcheck URL: '/health'
216
+
217
+ #---
218
+ # Set "inactive_settings" for saving cost on blue green deployment
219
+ # https://github.com/ThoughtWorksStudios/eb_deployer/wiki/Elastic-Beanstalk-Tips-and-Tricks#set-inactive_settings-for-saving-cost-on-blue-green-deployment
220
+ inactive:
221
+ aws:autoscaling:asg:
222
+ MinSize: 0
223
+ Cooldown: 900
224
+
216
225
  #---
217
226
  development:
218
227
  options:
@@ -228,6 +237,19 @@ production:
228
237
  InstanceType: t1.small
229
238
  ```
230
239
 
240
+ ## ENV interpolation
241
+
242
+ ENV variable interpolation is provided by [dry-config](https://github.com/alienfast/dry-config/blob/master/README.md#env-interpolationsubstitutionexpansion). Any of the values in the `eb.yml` may contain interpolated values.
243
+
244
+ The following formats are acceptable:
245
+
246
+ ```yaml
247
+ - ~/foo
248
+ - $HOME/foo
249
+ - ${HOME}/foo
250
+ - #{HOME}/foo
251
+ ```
252
+
231
253
  ## Additional options
232
254
  Most of the configurations are defaulted. The following are less obvious but may be useful:
233
255
 
@@ -242,6 +264,7 @@ package:
242
264
  The following are passed if not nil, otherwise eb_deployer assigns an appropriate default.
243
265
 
244
266
  ```ruby
267
+ inactive_settings: (nil if unspecified)
245
268
  package_bucket:
246
269
  keep_latest: (if unspecified, it will keep all past versions in the S3 bucket)
247
270
  version_prefix:
@@ -22,7 +22,7 @@ module Elastic
22
22
  # seed the sensible defaults here
23
23
  options = {
24
24
  symbolize: true,
25
- interpolation: true,
25
+ interpolation: false,
26
26
  default_configuration: {
27
27
  environment: nil,
28
28
  secrets_dir: '~/.aws',
@@ -35,7 +35,8 @@ module Elastic
35
35
  exclude_files: [],
36
36
  exclude_dirs: %w(pkg tmp log test-reports)
37
37
  },
38
- options: {}
38
+ options: {},
39
+ inactive: {}
39
40
  }
40
41
  }.merge(options)
41
42
  super(options)
@@ -57,39 +58,58 @@ module Elastic
57
58
  end
58
59
  end
59
60
 
60
- # def options
61
- # @configuration[:options]
62
- # end
63
-
64
61
  # custom methods for the specifics of eb.yml settings
65
62
  def option_settings
66
- result = []
67
- options.each_key do |namespace|
68
- options[namespace].each do |option_name, value|
69
- result << to_option_setting(namespace, option_name, value)
70
- end
71
- end
63
+ generate_settings(options)
64
+ end
72
65
 
73
- #{"option_settings" => result}
74
- result
66
+ def inactive_settings
67
+ generate_settings(inactive)
75
68
  end
76
69
 
77
70
  def set_option(namespace, option_name, value)
78
- namespace = namespace.to_sym
79
-
80
- if options[namespace].nil?
81
- options[namespace] = {option_name.to_sym => value}
82
- else
83
- options[namespace][option_name.to_sym] = value
84
- end
71
+ current_options = to_option_setting(namespace, option_name, value)
72
+ namespace = current_options[:namespace].to_sym
73
+ option_name = current_options[:option_name].to_sym
85
74
 
86
- #puts '888888hello'
75
+ options[namespace] = {} if options[namespace].nil?
76
+ options[namespace][option_name] = value
87
77
  end
88
78
 
89
79
  def find_option_setting(name)
80
+ find_setting(name, options)
81
+ end
82
+
83
+ def find_option_setting_value(name)
84
+ find_setting_value(name, options)
85
+ end
86
+
87
+ def find_inactive_setting(name)
88
+ find_setting(name, inactive)
89
+ end
90
+
91
+ def find_inactive_setting_value(name)
92
+ find_setting_value(name, inactive)
93
+ end
94
+
95
+ def to_option_setting(namespace, option_name, value)
96
+ erb_value = "#{value}".scan(/<%=.*%>/).first
97
+ unless erb_value.nil?
98
+ value = ERB.new(erb_value).result
99
+ end
100
+ {
101
+ :'namespace' => "#{namespace}",
102
+ :'option_name' => "#{option_name}",
103
+ :'value' => "#{value}"
104
+ }
105
+ end
106
+
107
+ private
108
+
109
+ def find_setting(name, settings_root)
90
110
  name = name.to_sym
91
- options.each_key do |namespace|
92
- options[namespace].each do |option_name, value|
111
+ settings_root.each_key do |namespace|
112
+ settings_root[namespace].each do |option_name, value|
93
113
  if option_name.eql? name
94
114
  return to_option_setting(namespace, option_name, value)
95
115
  end
@@ -98,17 +118,21 @@ module Elastic
98
118
  return nil
99
119
  end
100
120
 
101
- def find_option_setting_value(name)
102
- o = find_option_setting(name)
121
+ def find_setting_value(name, settings_root)
122
+ o = find_setting(name, settings_root)
103
123
  o[:value] unless o.nil?
104
124
  end
105
125
 
106
- def to_option_setting(namespace, option_name, value)
107
- {
108
- :'namespace' => "#{namespace}",
109
- :'option_name' => "#{option_name}",
110
- :'value' => "#{value}"
111
- }
126
+ def generate_settings(settings_root)
127
+ result = []
128
+ settings_root.each_key do |namespace|
129
+ settings_root[namespace].each do |option_name, value|
130
+ result << to_option_setting(namespace, option_name, value)
131
+ end
132
+ end
133
+
134
+ #{"option_settings" => result}
135
+ result
112
136
  end
113
137
  end
114
138
  end
@@ -316,7 +316,8 @@ namespace :eb do
316
316
  environment: EbConfig.environment,
317
317
  version_label: find_option_app_version,
318
318
  solution_stack_name: EbConfig.solution_stack_name,
319
- settings: EbConfig.option_settings,
319
+ option_settings: EbConfig.option_settings,
320
+ inactive_settings: EbConfig.inactive_settings,
320
321
  strategy: EbConfig.strategy.to_sym,
321
322
  package: package
322
323
  }
@@ -1,5 +1,5 @@
1
1
  module Elastic
2
2
  module Beanstalk
3
- VERSION = '1.1.11'
3
+ VERSION = '1.1.12'
4
4
  end
5
5
  end
@@ -7,33 +7,49 @@ describe EbConfig do
7
7
  # puts 'clear'
8
8
  #end
9
9
 
10
+ before(:each) do
11
+ EbConfig.clear
12
+ end
13
+
10
14
  it '#set_option' do
11
- EbConfig.clear
12
15
  EbConfig.set_option('aws:elasticbeanstalk:application:environment', 'RACK_ENV', 'staging')
13
16
  expect(EbConfig.options[:'aws:elasticbeanstalk:application:environment'][:'RACK_ENV']).to eq 'staging'
14
17
  end
15
18
 
16
19
  it '#find_option_setting_value' do
17
- EbConfig.clear
18
20
  EbConfig.set_option(:'aws:elasticbeanstalk:application:environment', 'RACK_ENV', 'staging')
19
21
  expect(EbConfig.find_option_setting_value('RACK_ENV')).to eql 'staging'
20
22
  end
21
23
  it '#find_option_setting' do
22
- EbConfig.clear
23
24
  EbConfig.set_option(:'aws:elasticbeanstalk:application:environment', 'RACK_ENV', 'staging')
24
25
  expect(EbConfig.find_option_setting('RACK_ENV')).to eql ({:namespace => 'aws:elasticbeanstalk:application:environment', :option_name => 'RACK_ENV', :value => 'staging'})
25
26
  end
26
27
 
27
28
  it '#set_option should allow options to be overridden' do
28
- EbConfig.clear
29
29
  EbConfig.set_option(:'aws:elasticbeanstalk:application:environment', 'RACK_ENV', 'staging')
30
30
  assert_option 'RACK_ENV', 'staging'
31
31
  EbConfig.set_option(:'aws:elasticbeanstalk:application:environment', 'RACK_ENV', 'foo')
32
32
  assert_option 'RACK_ENV', 'foo'
33
33
  end
34
34
 
35
+ it '#set_option should work with strings or deep symbols' do
36
+ option_input = [ :'aws:elasticbeanstalk:application:environment', :'RACK_ENV', :TEST_VALUE ]
37
+ method_order = [:to_sym, :to_s, :to_sym]
38
+ method_order.each do |current_method|
39
+ option_input.map!(&current_method)
40
+ EbConfig.clear
41
+ EbConfig.set_option(*option_input)
42
+ assert_option option_input[1].to_s, option_input[2].to_s
43
+ end
44
+ end
45
+
46
+ it '#set_option should work with environment variable interpolation' do
47
+ ENV['test_value'] = 'foo'
48
+ EbConfig.set_option(:'aws:elasticbeanstalk:application:environment', 'TEST_VAR', '<%= ENV["test_value"] %>')
49
+ assert_option 'TEST_VAR', 'foo'
50
+ end
51
+
35
52
  it 'should read file with nil environment' do
36
- EbConfig.clear
37
53
  sleep 1
38
54
  #expect(EbConfig.strategy).to be_nil
39
55
 
@@ -44,20 +60,7 @@ describe EbConfig do
44
60
  expect(EbConfig.environment).to be_nil
45
61
  end
46
62
 
47
- it '#should read file with environment variable interpolation' do
48
- EbConfig.clear
49
- sleep 1
50
- EbConfig.load!(nil, config_file_path)
51
- assert_option 'TEST_VAR', ''
52
-
53
- ENV['TEST_VAR'] = 'TEST_VALUE'
54
- EbConfig.clear
55
- EbConfig.load!(nil, config_file_path)
56
- assert_option 'TEST_VAR', 'TEST_VALUE'
57
- end
58
-
59
63
  it 'should read file and override with development environment' do
60
- EbConfig.clear
61
64
  EbConfig.load!(:development, config_file_path)
62
65
  assert_option 'InstanceType', 't1.micro'
63
66
  expect(EbConfig.strategy).to eql 'inplace-update'
@@ -65,7 +68,6 @@ describe EbConfig do
65
68
  end
66
69
 
67
70
  it 'should read file and override with production environment' do
68
- EbConfig.clear
69
71
  EbConfig.load!(:production, config_file_path)
70
72
  assert_option 'InstanceType', 't1.small'
71
73
  expect(EbConfig.environment).to eql :production
@@ -76,6 +78,10 @@ describe EbConfig do
76
78
  expect(EbConfig.find_option_setting_value(name)).to eql value
77
79
  end
78
80
 
81
+ def assert_inactive(name, value)
82
+ expect(EbConfig.find_inactive_setting_value(name)).to eql value
83
+ end
84
+
79
85
  def assert_common_top_level_settings
80
86
  expect(EbConfig.app).to eql 'acme'
81
87
  expect(EbConfig.region).to eql 'us-east-1'
@@ -108,6 +114,9 @@ describe EbConfig do
108
114
  assert_option 'Stickiness Policy', 'true'
109
115
  assert_option 'Notification Endpoint', 'alerts@acme.com'
110
116
  assert_option 'Application Healthcheck URL', '/healthcheck'
117
+
118
+ assert_inactive 'MinSize', '0'
119
+ assert_inactive 'Cooldown', '900'
111
120
  end
112
121
 
113
122
  def config_file_path
@@ -15,11 +15,31 @@ ebextensions:
15
15
  01seed:
16
16
  command: rake db:seed
17
17
  leader_only: true
18
+
19
+ 05-start-faye-server.config:
20
+ files:
21
+ "/opt/elasticbeanstalk/hooks/appdeploy/post/05_start_faye_server.sh":
22
+ mode: "000755"
23
+ owner: root
24
+ group: root
25
+ content: |
26
+ #!/usr/bin/env bash
27
+ # Loading environment data
28
+ EB_APP_USER=$(/opt/elasticbeanstalk/bin/get-config container -k app_user)
29
+ EB_APP_DEPLOY_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir)
30
+ EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
31
+ EB_SUPPORT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_dir)
32
+ # Setting up correct environment and ruby version so that bundle can load all gems
33
+ . $EB_SUPPORT_DIR/envvars
34
+ . $EB_SCRIPT_DIR/use-app-ruby.sh
35
+ # Now we can do the actual restart of the worker. Make sure to have double quotes when using env vars in the command.
36
+ cd $EB_APP_DEPLOY_DIR
37
+ su -s /bin/bash -c "RAILS_ENV=production bundle exec thin -C config/private_pub_thin.yml --timeout 60 start -d" $EB_APP_USER
38
+
18
39
  #---
19
40
  options:
20
41
  aws:elasticbeanstalk:application:environment:
21
42
  RAILS_ENV: foobar
22
- TEST_VAR: #{TEST_VAR}
23
43
 
24
44
  aws:autoscaling:launchconfiguration:
25
45
  InstanceType: foo
@@ -42,6 +62,12 @@ options:
42
62
 
43
63
  aws:elasticbeanstalk:application:
44
64
  Application Healthcheck URL: '/healthcheck'
65
+
66
+ inactive:
67
+ aws:autoscaling:asg:
68
+ MinSize: 0
69
+ Cooldown: 900
70
+
45
71
  #---
46
72
  development:
47
73
  strategy: inplace-update
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic-beanstalk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.11
4
+ version: 1.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Ross
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-21 00:00:00.000000000 Z
11
+ date: 2016-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler