elastic-beanstalk 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +35 -4
- data/elastic-beanstalk.gemspec +23 -23
- data/lib/elastic/beanstalk/tasks/eb.rake +62 -31
- data/lib/elastic/beanstalk/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmUxODBiMDgxNjY5MGY3YzUwN2IxMDcwM2U3NDYwMWU2NGMxNzg5MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NWNlNjFkZmJmM2UzNjkyZWNmYTIyOTIxZjk0MjFlMDQ1NTFhZmRlNQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTE2NGRhODY1OWI0YzVlNGMyYjlhNjczYzgzNzg2ZmY0ZDg1YWY5YjJmZDVi
|
10
|
+
YjZiOTkxZjExM2IxYmExNDJiYWI2N2EyMTYxZTU0OWIxZmQ2NzllYTBmZjY0
|
11
|
+
N2VhOTdhNWI0MDM2NmJkZDc1OGIzYzVkZjNkZjA4YzYzNGRkMDk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MWVjMmUyMmYwZDg4NzkxYjdlNDU5Y2EwODkyZGU5MGNlNjA2NzJkODRhNmMz
|
14
|
+
NmZlMzU1MjBkNDAwZmVmNzMwODU4ZWVmZGU2ZWZkN2VhMzRlN2ZhOGQzZDNj
|
15
|
+
MTA3MDI4M2UxYTY0MzdjZTljZWRlMWI4NjMxZDEwMWRlNjgwM2I=
|
data/README.md
CHANGED
@@ -63,7 +63,7 @@ Something like this should get you started
|
|
63
63
|
InstanceType: t1.small
|
64
64
|
|
65
65
|
### Step 3. Package and deploy
|
66
|
-
The default is the 'development' environment, change this via command line
|
66
|
+
The default is the 'development' environment, change this via command line arguments
|
67
67
|
|
68
68
|
$ rake eb:package eb:deploy
|
69
69
|
|
@@ -92,11 +92,42 @@ For example, this would create a snapshot prior to the deployment (and migration
|
|
92
92
|
|
93
93
|
rake eb:rds:create_snapshot[acme, pre-1.1.0] eb:deploy[1.1.0]
|
94
94
|
|
95
|
+
## Command line
|
96
|
+
|
97
|
+
### RAILS_ENV vs :environment:
|
98
|
+
Some people prefer to use `RAILS_ENV`, others prefer to use the `:environment` argument. Both are accepted. Depending on the use case, each one can be DRYer than the other.
|
99
|
+
Where the task specifies `[:environment, :version]`, consider the `:environment` optional if you want to use the default of `development` or utilize the `RAILS_ENV` instead.
|
100
|
+
|
101
|
+
**NOTE:** if using the argument `:environment`, you **must** specify it for **both** the `eb:package` and `eb:deploy`, as `eb:package` is responsible for injecting the `RACK_ENV` and `RAILS_ENV`
|
102
|
+
in `aws:elasticbeanstalk:application:environment` section of the `.ebextensions` file.
|
103
|
+
|
104
|
+
### :version
|
105
|
+
If not specified, version will be auto-generated via and MD5 hash of the package file. If specified to the `eb:package` task, the version will be available as the `APP_VERSION`
|
106
|
+
environment variable, specified in the `aws:elasticbeanstalk:application:environment` section of the `.ebextensions` file.
|
107
|
+
|
108
|
+
|
95
109
|
## A real-world example
|
96
110
|
|
97
|
-
Deploy version 1.1.3 of acme to production
|
111
|
+
Deploy version 1.1.3 of acme to production using the `:environment` parameter
|
112
|
+
|
113
|
+
$ rake eb:package[production,1.1.3] eb:deploy[production,1.1.3]
|
114
|
+
|
115
|
+
Deploy version 1.1.3 of acme to production using `RAILS_ENV`
|
98
116
|
|
99
|
-
$ RAILS_ENV=production rake eb:package eb:deploy[1.1.3]
|
117
|
+
$ RAILS_ENV=production rake eb:package[1.1.3] eb:deploy[1.1.3]
|
118
|
+
|
119
|
+
Deploy an MD5 hashed version of acme to production using the `:environment` parameter
|
120
|
+
|
121
|
+
$ rake eb:package[production] eb:deploy[production]
|
122
|
+
|
123
|
+
Deploy an MD5 hashed version of acme to production using `RAILS_ENV`
|
124
|
+
|
125
|
+
$ RAILS_ENV=production rake eb:package eb:deploy
|
126
|
+
|
127
|
+
Deploy an MD5 hashed version of acme to development
|
128
|
+
|
129
|
+
$ rake eb:package eb:deploy
|
130
|
+
|
100
131
|
|
101
132
|
config/eb.yml
|
102
133
|
|
@@ -237,4 +268,4 @@ Please contribute! While this is working great, a greater scope of functionality
|
|
237
268
|
|
238
269
|
## Copyright
|
239
270
|
|
240
|
-
Copyright (c) 2014 AlienFast. See LICENSE.txt for further details.
|
271
|
+
Copyright (c) 2014 AlienFast, LLC. See LICENSE.txt for further details.
|
data/elastic-beanstalk.gemspec
CHANGED
@@ -3,38 +3,38 @@ lib = File.expand_path('../lib', __FILE__)
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
require 'elastic/beanstalk/version'
|
5
5
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = 'elastic-beanstalk'
|
8
|
+
s.version = Elastic::Beanstalk::VERSION
|
9
|
+
s.authors = ['Kevin Ross']
|
10
|
+
s.email = ['kevin.ross@alienfast.com']
|
11
|
+
s.description = <<-TEXT
|
12
12
|
The simplest way to configure and deploy an Elastic Beanstalk application via rake.
|
13
13
|
TEXT
|
14
|
-
|
14
|
+
s.summary = <<-TEXT
|
15
15
|
Configure and deploy a rails app to Elastic Beanstalk via rake in 60 seconds.
|
16
16
|
Maintain multiple environment DRY configurations and .ebextensions in one easy
|
17
17
|
to use configuration file.
|
18
18
|
TEXT
|
19
|
-
|
20
|
-
|
19
|
+
s.homepage = 'https://github.com/alienfast/elastic-beanstalk'
|
20
|
+
s.license = 'MIT'
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
s.files = `git ls-files`.split($/).reject { |f| f =~ /^samples\// }
|
23
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
24
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
25
|
+
s.require_paths = ['lib']
|
26
26
|
|
27
27
|
# development
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
s.add_development_dependency 'bundler', '~> 1.3'
|
29
|
+
s.add_development_dependency 'rake'
|
30
|
+
s.add_development_dependency 'rspec', '>= 2.14.1'
|
31
31
|
|
32
32
|
# runtime
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
s.add_runtime_dependency 'railties', '>= 3.2'
|
34
|
+
s.add_runtime_dependency 'eb_deployer', '>= 0.4.4'
|
35
|
+
s.add_runtime_dependency 'awesome_print'
|
36
|
+
s.add_runtime_dependency 'time_diff'
|
37
|
+
s.add_runtime_dependency 'rubyzip'
|
38
|
+
s.add_runtime_dependency 'table_print'
|
39
|
+
s.add_runtime_dependency 'nokogiri'
|
40
40
|
end
|
@@ -126,27 +126,65 @@ namespace :eb do
|
|
126
126
|
desc 'Setup AWS.config and merge/override environments into one resolved configuration'
|
127
127
|
task :config do |t, args|
|
128
128
|
|
129
|
-
|
130
|
-
|
131
|
-
|
129
|
+
|
130
|
+
#-------------------------------------------------------------------------------
|
131
|
+
# Resolve arguments in a backwards compatibile way (see https://github.com/alienfast/elastic-beanstalk/issues/12)
|
132
|
+
# This allows both the use of RAILS_ENV or the :environment parameter
|
133
|
+
#
|
134
|
+
# Previously, we relied solely on the environment to be passed in as RAILS_ENV. It is _sometimes_ more convenient to allow it to be passed as the :environment parameter.
|
135
|
+
# Since :environment is first, and :version used to be first, check the :environment against a version number regex and adjust as necessary.
|
136
|
+
bc_arg_environment = args[:environment]
|
137
|
+
unless /^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/.match(bc_arg_environment).nil?
|
138
|
+
|
139
|
+
arg_version = args[:version]
|
140
|
+
raise "Found version[#{bc_arg_environment}] passed as :environment, but also found a value for :version[#{arg_version}]. Please adjust arguments to be [:environment, :version] or use RAILS_ENV with a single [:version] argument" unless arg_version.nil?
|
141
|
+
|
142
|
+
# version was passed as :environment, adjust it.
|
143
|
+
arg_version = bc_arg_environment
|
144
|
+
arg_environment = nil
|
145
|
+
|
146
|
+
# puts "NOTE: Manipulated :environment argument to :version[#{bc_arg_environment}]."
|
147
|
+
else
|
148
|
+
# normal resolution of argements
|
149
|
+
arg_environment = args[:environment]
|
150
|
+
arg_version = args[:version]
|
151
|
+
end
|
152
|
+
|
153
|
+
|
154
|
+
# set the default environment to be development if not otherwise resolved
|
155
|
+
environment = arg_environment || ENV['RAILS_ENV'] || 'development'
|
132
156
|
|
133
157
|
# load the configuration from same dir (for standalone CI purposes) or from the rails config dir if within the rails project
|
134
158
|
filename = EbConfig.resolve_path('eb.yml')
|
135
159
|
unless File.exists? filename
|
136
160
|
filename = EbConfig.resolve_path('config/eb.yml')
|
137
161
|
end
|
138
|
-
EbConfig.load!(
|
162
|
+
EbConfig.load!(environment, filename)
|
139
163
|
|
140
164
|
# Let's be explicit regardless of 'production' being the eb's default shall we? Set RACK_ENV and RAILS_ENV based on the given environment
|
141
165
|
EbConfig.set_option(:'aws:elasticbeanstalk:application:environment', 'RACK_ENV', "#{EbConfig.environment}")
|
142
166
|
EbConfig.set_option(:'aws:elasticbeanstalk:application:environment', 'RAILS_ENV', "#{EbConfig.environment}")
|
143
167
|
|
168
|
+
#-------------------------------------------------------------------------------
|
144
169
|
# resolve the version and set the APP_VERSION environment variable
|
145
|
-
resolve_version(args)
|
146
170
|
|
171
|
+
# try to use from task argument first
|
172
|
+
version = arg_version
|
173
|
+
file = resolve_absolute_package_file
|
174
|
+
if version.nil? && File.exists?(file)
|
175
|
+
# otherwise use the MD5 hash of the package file
|
176
|
+
version = Digest::MD5.file(file).hexdigest
|
177
|
+
end
|
178
|
+
|
179
|
+
# set the var, depending on the sequence of calls, this may be nil
|
180
|
+
# (i.e. :show_config with no :version argument) so omit it until we have something worthwhile.
|
181
|
+
EbConfig.set_option(:'aws:elasticbeanstalk:application:environment', 'APP_VERSION', "#{version}") unless version.nil?
|
182
|
+
|
183
|
+
#-------------------------------------------------------------------------------
|
147
184
|
# configure aws credentials. Depending on the called task, this may not be necessary parent task should call #credentials! for validation.
|
148
185
|
AWS.config(credentials) unless credentials.nil?
|
149
186
|
|
187
|
+
#-------------------------------------------------------------------------------
|
150
188
|
# configure aws region if specified in the eb.yml
|
151
189
|
AWS.config(region: EbConfig.region) unless EbConfig.region.nil?
|
152
190
|
end
|
@@ -156,12 +194,9 @@ namespace :eb do
|
|
156
194
|
#
|
157
195
|
#
|
158
196
|
desc 'Show resolved configuration without doing anything.'
|
159
|
-
task :show_config, [:version] => [:config] do |t, args|
|
160
|
-
|
197
|
+
task :show_config, [:environment, :version] => [:config] do |t, args|
|
161
198
|
|
162
199
|
puts "Working Directory: #{Rake.original_dir}"
|
163
|
-
|
164
|
-
resolve_version(args)
|
165
200
|
print_config
|
166
201
|
end
|
167
202
|
|
@@ -182,8 +217,8 @@ namespace :eb do
|
|
182
217
|
# root of the archive, not under a top level folder. Include this package task to make
|
183
218
|
# sure we don't need to learn about this again through long deploy cycles!
|
184
219
|
#
|
185
|
-
desc 'Package zip source bundle for Elastic Beanstalk and generate external Rakefile'
|
186
|
-
task :package => [:clobber, :config] do |t, args|
|
220
|
+
desc 'Package zip source bundle for Elastic Beanstalk and generate external Rakefile. (optional) specify the :version arg to make it available to the elastic beanstalk app dynamically via the APP_VERSION environment varable'
|
221
|
+
task :package, [:environment, :version] => [:clobber, :config] do |t, args|
|
187
222
|
|
188
223
|
begin
|
189
224
|
# write .ebextensions
|
@@ -240,7 +275,15 @@ namespace :eb do
|
|
240
275
|
#
|
241
276
|
#
|
242
277
|
desc 'Deploy to Elastic Beanstalk'
|
243
|
-
task :deploy, [:version] => [:config] do |t, args|
|
278
|
+
task :deploy, [:environment, :version] => [:config] do |t, args|
|
279
|
+
|
280
|
+
# If called individually, this is not necessary, but if called in succession to eb:package, we may need to re-resolve an MD5 hashed name.
|
281
|
+
# Since we allow variable use of arguments, it is easiest just to quickly re-enable and re-run the eb:config task since all the resolution
|
282
|
+
# of values is contained there.
|
283
|
+
Rake::Task['eb:config'].reenable
|
284
|
+
Rake::Task['eb:config'].invoke
|
285
|
+
|
286
|
+
|
244
287
|
# Leave off the dependency of :package, we need to package this in the build phase and save
|
245
288
|
# the artifact on bamboo. The deploy plan will handle this separately.
|
246
289
|
from_time = Time.now
|
@@ -256,8 +299,6 @@ namespace :eb do
|
|
256
299
|
# Don't deploy to test or cucumber (or whatever is specified by :disallow_environments)
|
257
300
|
raise "#{EbConfig.environment} is one of the #{EbConfig.disallow_environments} disallowed environments. Configure it by changing the :disallow_environments in the eb.yml" if EbConfig.disallow_environments.include? EbConfig.environment
|
258
301
|
|
259
|
-
# Use the version if given, otherwise use the MD5 hash. Make available via the eb environment variable
|
260
|
-
version = resolve_version(args)
|
261
302
|
print_config
|
262
303
|
|
263
304
|
# Avoid known problems
|
@@ -269,7 +310,7 @@ namespace :eb do
|
|
269
310
|
options = {
|
270
311
|
application: EbConfig.app,
|
271
312
|
environment: EbConfig.environment,
|
272
|
-
version_label:
|
313
|
+
version_label: find_option_app_version,
|
273
314
|
solution_stack_name: EbConfig.solution_stack_name,
|
274
315
|
settings: EbConfig.option_settings,
|
275
316
|
strategy: EbConfig.strategy.to_sym,
|
@@ -284,7 +325,7 @@ namespace :eb do
|
|
284
325
|
options[:smoke_test] = eval EbConfig.smoke_test
|
285
326
|
end
|
286
327
|
|
287
|
-
EbDeployer.deploy(options)
|
328
|
+
# EbDeployer.deploy(options)
|
288
329
|
|
289
330
|
puts "\nDeployment finished in #{Time.diff(from_time, Time.now, '%N %S')[:diff]}.\n"
|
290
331
|
end
|
@@ -313,30 +354,20 @@ namespace :eb do
|
|
313
354
|
private
|
314
355
|
|
315
356
|
# Use the version if given, otherwise use the MD5 hash. Make available via the eb APP_VERSION environment variable
|
316
|
-
def
|
357
|
+
def find_option_app_version
|
317
358
|
|
318
359
|
# if already set by a dependency call to :config, get out early
|
319
360
|
version = EbConfig.find_option_setting_value('APP_VERSION')
|
320
361
|
return version unless version.nil?
|
321
|
-
|
322
|
-
# try to grab from task argument first
|
323
|
-
version = args[:version]
|
324
|
-
file = resolve_absolute_package_file
|
325
|
-
if version.nil? && File.exists?(file)
|
326
|
-
# otherwise use the MD5 hash of the package file
|
327
|
-
version = Digest::MD5.file(file).hexdigest
|
328
|
-
end
|
329
|
-
|
330
|
-
# set the var, depending on the sequence of calls, this may be nil
|
331
|
-
# (i.e. :show_config with no :version argument) so omit it until we have something worthwhile.
|
332
|
-
EbConfig.set_option(:'aws:elasticbeanstalk:application:environment', 'APP_VERSION', "#{version}") unless version.nil?
|
333
362
|
end
|
334
363
|
|
335
364
|
def print_config
|
336
365
|
# display helpful for figuring out problems later in the deployment logs.
|
337
366
|
puts "\n----------------------------------------------------------------------------------"
|
338
367
|
puts 'Elastic Beanstalk configuration:'
|
339
|
-
puts "\
|
368
|
+
puts "\taccess_key_id: #{credentials['access_key_id']}"
|
369
|
+
puts "\tenvironment: #{EbConfig.environment}"
|
370
|
+
puts "\tversion: #{find_option_app_version}"
|
340
371
|
|
341
372
|
# pretty print things that will be useful to see in the deploy logs and omit clutter that usually doesn't cause us problems.
|
342
373
|
h = EbConfig.configuration.dup
|
@@ -399,4 +430,4 @@ namespace :eb do
|
|
399
430
|
def aws_secrets_file
|
400
431
|
File.expand_path("#{EbConfig.secrets_dir}/#{EbConfig.app}.yml")
|
401
432
|
end
|
402
|
-
end
|
433
|
+
end
|
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.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Ross
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|