enhanced-elastic-beanstalk 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 59b192f9dab3e85cadd651560fcb7f83567fd97e
4
+ data.tar.gz: 6911fa46009233c5533183550b9b3a6360c50164
5
+ SHA512:
6
+ metadata.gz: 46b012522dba696920aa6cfe48ae2ec4335b9870cc07929998cc639579e9e2b943e284c267ed9b6396f66b7c2b42261ba0906313f3dd68e92e109e6c3b886533
7
+ data.tar.gz: 76d99a8724d995b5e453ba6b0725ae09704e2e983b3b426703f17321689e53643d45e0a738cb4a7cd690e1bc06026d2d3d217e8a90a0217dca312b2020ffcc00
Binary file
@@ -0,0 +1,23 @@
1
+ Gemfile.lock
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+
20
+ .idea
21
+ bin/eb.yml
22
+
23
+ test-reports
data/.rspec ADDED
@@ -0,0 +1,4 @@
1
+ --color
2
+ --require spec_helper
3
+ --format RspecJunitFormatter
4
+ --out test-reports/rspec.xml
@@ -0,0 +1 @@
1
+ elastic_beanstalk
@@ -0,0 +1 @@
1
+ ruby-2.2.2
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014-2015 AlienFast, LLC
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,294 @@
1
+ # EnhancedElasticBeanstalk
2
+ Configure and deploy a rails app to Elastic Beanstalk via rake in 60 seconds. Maintain multiple environment DRY configurations and .ebextensions in one easy to use yaml configuration file.
3
+
4
+ This gem simplifies configuration, and passes the heavy lifting to the [eb_deployer](https://github.com/ThoughtWorksStudios/eb_deployer) from ThoughtWorksStudios.
5
+
6
+ *IMPORTANT!*
7
+ This fork of `elastic-beanstalk` has some enhancements that we felt weren't
8
+ worthy of a pull request to the original project, thus the forked version.
9
+ Unless you specifically need HipChat support and custom eb env names, it is
10
+ recommended you go use the latest version of the original gem. https://github.com/alienfast/elastic-beanstalk
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ gem 'enhanced-elastic-beanstalk'
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install enhanced-elastic-beanstalk
25
+
26
+ ## Features
27
+
28
+ ### The elastic-beanstalk gem provides:
29
+ * Rake tasks to simplify all interactions
30
+ * Multi-environment configuration inheritance for DRY yaml configs
31
+ * Keep all configurations including .ebextensions in one yaml file (they are inheritable and can be overridden too)
32
+ * Full access to the range of configuration options provided by AWS Elastic Beanstalk
33
+ * Provide access to helpers such as the SmokeTester to simplify configurations
34
+
35
+ ### Plus
36
+ Since [eb_deployer](https://github.com/ThoughtWorksStudios/eb_deployer) is doing the heavy lifting, by proxy you get access to great continuous delivery features such as:
37
+ * `blue-green` deployment strategy
38
+ * `inplace-update` deployment strategy
39
+ * Smoke Testing upon deployment before `blue-green` CNAME switching
40
+
41
+ ## Usage
42
+
43
+ Given an application named 'acme':
44
+
45
+ ### Step 1: Add ~/.aws/acme.yml
46
+ This should contain the access and secret keys generated from the selected IAM user. This is the only file that will need to reside outside the repository. Note that this location is configurable in the `config/eb.yml` file.
47
+
48
+ access_key_id: XXXXXX
49
+ secret_access_key: XXXXXX
50
+
51
+ ### Step 2. Add a config/eb.yml to your rails project
52
+ Something like this should get you started
53
+
54
+ ```ruby
55
+ app: acme
56
+ region: us-east-1
57
+ solution_stack_name: 64bit Amazon Linux 2015.03 v2.0.0 running Ruby 2.2 (Passenger Standalone)
58
+ strategy: inplace-update
59
+ keep_latest: 10
60
+ development:
61
+ options:
62
+ aws:autoscaling:launchconfiguration:
63
+ InstanceType: t1.micro
64
+
65
+ production:
66
+ strategy: blue-green
67
+ options:
68
+ aws:autoscaling:launchconfiguration:
69
+ InstanceType: t1.small
70
+ ```
71
+
72
+ ### Step 3. Package and deploy
73
+ The default is the 'development' environment, change this via command line arguments
74
+
75
+ $ rake eb:package eb:deploy
76
+
77
+ ### Step 4. Get some coffee
78
+ This will take a while. TODO: investigate methods to speed up deployment i.e. cache bundle. Feel free to post yours in the wiki.
79
+
80
+ ## Rake Tasks
81
+
82
+ ### EB
83
+
84
+ rake eb:clobber # Remove any generated package
85
+ rake eb:config[environment,version] # Setup AWS.config and merge/override environments into one resolved configuration
86
+ rake eb:deploy[environment,version] # Deploy to Elastic Beanstalk
87
+ rake eb:destroy[force] # ** Warning: Destroy Elastic Beanstalk application and *all* environments
88
+ rake eb:package[environment,version] # Package zip source bundle for Elastic Beanstalk
89
+ rake eb:show_config[environment,version] # Show resolved configuration without doing anything
90
+
91
+ ### EB:RDS Rake Tasks
92
+
93
+ The EB:RDS tasks are intended to make use of RDS tasks simple given existing configuration in the eb.yml.
94
+ i.e. create a snapshot before or after an `eb:deploy`. The following rake tasks exist:
95
+
96
+ rake eb:rds:create_snapshot[instance_id,snapshot_id] # Creates an RDS snapshot
97
+ rake eb:rds:instances # List RDS instances
98
+ rake eb:rds:snapshots # List RDS snapshots
99
+
100
+ For example, this would create a snapshot prior to the deployment (and migration) to version 1.1.0:
101
+
102
+ rake eb:rds:create_snapshot[acme, pre-1.1.0] eb:deploy[1.1.0]
103
+
104
+ ### Using RAILS_ENV vs :environment:
105
+ 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.
106
+ 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.
107
+
108
+ **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`
109
+ in `aws:elasticbeanstalk:application:environment` section of the `.ebextensions` file.
110
+
111
+ ### :version
112
+ 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`
113
+ environment variable, specified in the `aws:elasticbeanstalk:application:environment` section of the `.ebextensions` file.
114
+
115
+
116
+ ## A real-world example
117
+
118
+ Deploy version 1.1.3 of acme to production using the `:environment` parameter
119
+
120
+ $ rake eb:package[production,1.1.3] eb:deploy[production,1.1.3]
121
+
122
+ Deploy version 1.1.3 of acme to production using `RAILS_ENV`
123
+
124
+ $ RAILS_ENV=production rake eb:package[1.1.3] eb:deploy[1.1.3]
125
+
126
+ Deploy an MD5 hashed version of acme to production using the `:environment` parameter
127
+
128
+ $ rake eb:package[production] eb:deploy[production]
129
+
130
+ Deploy an MD5 hashed version of acme to production using `RAILS_ENV`
131
+
132
+ $ RAILS_ENV=production rake eb:package eb:deploy
133
+
134
+ Deploy an MD5 hashed version of acme to development
135
+
136
+ $ rake eb:package eb:deploy
137
+
138
+
139
+ config/eb.yml
140
+
141
+ ```ruby
142
+ # This is a sample that has not been executed so it may not be exactly 100%, but is intended to show
143
+ # that access to full options_settings and .ebextensions is intended.
144
+ #---
145
+ # http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options.html#command-options-ruby
146
+ #
147
+ # This is a sample that has not been executed so it may not be exactly 100%, but is intended to show
148
+ # that access to full options_settings and .ebextensions is intended.
149
+ #---
150
+ app: acme
151
+ region: us-east-1
152
+ # Choose a platform from http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/concepts.platforms.html
153
+ solution_stack_name: 64bit Amazon Linux 2015.03 v2.0.0 running Ruby 2.2 (Passenger Standalone)
154
+ strategy: inplace-update # default to inplace-update to avoid starting new environments
155
+ keep_latest: 10
156
+ package:
157
+ verbose: true
158
+ includes: ['public/assets/.sprockets-manifest-*.json'] # ensure '.' manifest is added when using assets:precompile
159
+ exclude_dirs: [features, spec, target, coverage, vcr, flows] # additional dirs that merge with default excludes
160
+ exclude_files: [.ruby-*, rspec.xml, README*, db/*.sqlite3, bower.json]
161
+ smoke_test: |
162
+ lambda { |host|
163
+ EbSmokeTester.test_url("http://#{host}/health", 600, 5, 'All good! Everything is up and checks out.')
164
+ }
165
+ #--
166
+ ebextensions:
167
+ # General settings for the server environment
168
+ 01-environment.config:
169
+ commands:
170
+ 01timezone:
171
+ command: "ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime"
172
+
173
+ # These are things that make sense for any Ruby application
174
+ 02-ruby.config:
175
+ # Install git in order to be able to bundle gems from git
176
+ packages:
177
+ yum:
178
+ git: []
179
+ patch: []
180
+
181
+ # Run rake tasks before an application deployment
182
+ 03-rake.config:
183
+ container_commands:
184
+ 01seed:
185
+ command: rake db:seed
186
+ leader_only: true
187
+
188
+ #---
189
+ options:
190
+
191
+ # Any environment variables - will be available in ENV
192
+ aws:elasticbeanstalk:application:environment:
193
+ FOO: 'bar'
194
+ RAILS_SKIP_ASSET_COMPILATION: true # Use if doing asset compilation before packaging (recommended)
195
+
196
+ aws:autoscaling:launchconfiguration:
197
+ EC2KeyName: eb-ssh
198
+ SecurityGroups: 'acme-production-control'
199
+
200
+ aws:autoscaling:asg:
201
+ MinSize: 1
202
+ MaxSize: 5
203
+ # Restrict to Reserved Instance zone: http://stackoverflow.com/a/33131364/2363935
204
+ 'Custom Availability Zones': us-east-1c
205
+ 'Availability Zones': Any 1
206
+
207
+
208
+ aws:elb:loadbalancer:
209
+ SSLCertificateId: 'arn:aws:iam::XXXXXXX:server-certificate/acme'
210
+ LoadBalancerHTTPSPort: 443
211
+
212
+ aws:elb:policies:
213
+ Stickiness Policy: true
214
+
215
+ aws:elasticbeanstalk:sns:topics:
216
+ Notification Endpoint: 'alerts@acme.com'
217
+
218
+ aws:elasticbeanstalk:application:
219
+ Application Healthcheck URL: '/health'
220
+
221
+ #---
222
+ # Set "inactive_settings" for saving cost on blue green deployment
223
+ # https://github.com/ThoughtWorksStudios/eb_deployer/wiki/Elastic-Beanstalk-Tips-and-Tricks#set-inactive_settings-for-saving-cost-on-blue-green-deployment
224
+ inactive:
225
+ aws:autoscaling:asg:
226
+ MinSize: 0
227
+ Cooldown: 900
228
+
229
+ #---
230
+ development:
231
+ options:
232
+ aws:autoscaling:launchconfiguration:
233
+ InstanceType: t1.micro
234
+ aws:elasticbeanstalk:application:environment:
235
+ RAILS_SKIP_ASSET_COMPILATION: true
236
+ #---
237
+ production:
238
+ strategy: blue-green # always fire up a new environment and healthcheck before transitioning cname
239
+ options:
240
+ aws:autoscaling:launchconfiguration:
241
+ InstanceType: t1.small
242
+ ```
243
+
244
+ ## ENV interpolation
245
+
246
+ 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.
247
+
248
+ The following formats are acceptable:
249
+
250
+ ```yaml
251
+ - ~/foo
252
+ - $HOME/foo
253
+ - ${HOME}/foo
254
+ - #{HOME}/foo
255
+ ```
256
+
257
+ ## Additional options
258
+ Most of the configurations are defaulted. The following are less obvious but may be useful:
259
+
260
+ ```ruby
261
+ secrets_dir: (default: '~/.aws')
262
+ package:
263
+ verbose: (default: false)
264
+ dir: (default: 'pkg')
265
+ ```
266
+
267
+ ### eb_deployer additional options
268
+ The following are passed if not nil, otherwise eb_deployer assigns an appropriate default.
269
+
270
+ ```ruby
271
+ inactive_settings: (nil if unspecified)
272
+ package_bucket:
273
+ keep_latest: (if unspecified, it will keep all past versions in the S3 bucket)
274
+ version_prefix:
275
+ tier:
276
+ ```
277
+
278
+ ## Still to come
279
+ 1. Speedier deployments - investigate caching of bundle and asset pre-compilation to see if there is a common setting to be found
280
+
281
+ ## Contributing
282
+
283
+ Please contribute! While this is working great, a greater scope of functionality is certainly easily attainable with this foundation in place.
284
+
285
+ 1. Fork it
286
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
287
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
288
+ 4. Push to the branch (`git push origin my-new-feature`)
289
+ 5. Create new Pull Request
290
+
291
+
292
+ ## Copyright and License
293
+
294
+ MIT License, see LICENSE.txt for further details.
@@ -0,0 +1,8 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ # add rspec task
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new('spec')
6
+ task :default => :spec
7
+ task :test => :spec
8
+
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rake'
3
+ require 'bundler'
4
+
5
+ raise "Bundler is required. Please install bundler with 'gem install bundler'" unless defined?(Bundler)
6
+
7
+ #
8
+ # Example:
9
+ #
10
+ # elastic-beanstalk eb:show_config
11
+ # elastic-beanstalk eb:show_config[1.1.1]
12
+ #
13
+
14
+ # init dependencies
15
+ Bundler.setup
16
+
17
+ # init rake
18
+ Rake.application.init
19
+
20
+ # load the rake tasks
21
+ gem_dir = File.expand_path('..',File.dirname(__FILE__))
22
+ load "#{gem_dir}/lib/elastic/beanstalk/tasks/eb.rake"
23
+
24
+ # invoke the given task
25
+ Rake.application.invoke_task(ARGV[0])
@@ -0,0 +1,48 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'elastic/beanstalk/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'enhanced-elastic-beanstalk'
8
+ s.version = Elastic::Beanstalk::VERSION
9
+ s.authors = ['Matt E. Patterson', 'Kevin Ross']
10
+ s.email = ['mepatterson@skillsengine.com', 'kevin.ross@alienfast.com']
11
+ s.description = <<-TEXT
12
+ The simplest way to configure and deploy an Elastic Beanstalk application via rake.
13
+
14
+ This fork of `elastic-beanstalk` has some enhancements that we felt weren't
15
+ worthy of a pull request to the original project, thus the forked version.
16
+ Unless you specifically need HipChat support and custom eb env names, it is
17
+ recommended you go use the latest version of the original gem. https://github.com/alienfast/elastic-beanstalk
18
+ TEXT
19
+ s.summary = <<-TEXT
20
+ Configure and deploy a rails app to Elastic Beanstalk via rake in 60 seconds.
21
+ Maintain multiple environment DRY configurations and .ebextensions in one easy
22
+ to use configuration file.
23
+ TEXT
24
+ s.homepage = 'https://github.com/mepatterson/enhanced-elastic-beanstalk'
25
+ s.license = 'MIT'
26
+
27
+ s.files = `git ls-files`.split($/).reject { |f| f =~ /^samples\// }
28
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
29
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
30
+ s.require_paths = ['lib']
31
+
32
+ # development
33
+ s.add_development_dependency 'bundler'
34
+ s.add_development_dependency 'rake'
35
+ s.add_development_dependency 'rspec'
36
+ s.add_development_dependency 'rspec_junit_formatter'
37
+
38
+ # runtime
39
+ s.add_runtime_dependency 'railties', '>= 3.2'
40
+ s.add_runtime_dependency 'eb_deployer', '>= 0.6.1'
41
+ s.add_runtime_dependency 'awesome_print'
42
+ s.add_runtime_dependency 'time_diff'
43
+ s.add_runtime_dependency 'rubyzip'
44
+ s.add_runtime_dependency 'table_print'
45
+ s.add_runtime_dependency 'nokogiri'
46
+ s.add_runtime_dependency 'dry-config', '>=1.2.0'
47
+ s.add_runtime_dependency 'hipchat'
48
+ end