elastic_beans 0.4.1 → 0.5.0

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: 70a69de3c656c7d828c6b47684f3806a8bfb54dc
4
- data.tar.gz: 5e257058d7649f152d69964d6ff9c5cfcfe5c3e4
3
+ metadata.gz: df2c92db9341aafe114e311aa9513e262980075b
4
+ data.tar.gz: e0d1656e123cc87594923df2a454692c6a5f24cb
5
5
  SHA512:
6
- metadata.gz: c7f8b3ed1abc7fc073ca31cd1fa876c30081ac3365f3318e3add6631ef5740389b6a22a60ac6fa73cad3cfb2c85c28977350e7772a05484338983c06c5f28608
7
- data.tar.gz: e0a78ebe606867f4dd9845f3bf5bbb476588ff2571d99f2aa7cf9f5ff6c82a1f536b10adb7ee03a15718cb907745cf4379b7d914aed7cd621e298c25fabee595
6
+ metadata.gz: c71f8da1510349c373e03fa299d6106bd7b932168cfd166c797f21311442b5e34431bc817ef39063f1969d1f22b56b8865ed919a9de7968ef1190e8bebe86003
7
+ data.tar.gz: 2834984b88ad858571e1f01681c5b2bc41d388635c096a84bff9bdf3ba380551dbf00b7bc00072029c98f137911704f985c285ddb4eaf169311a2293c5826769
data/README.md CHANGED
@@ -5,18 +5,22 @@ It is a CLI that replaces the [Elastic Beanstalk CLI][eb], which looks great on
5
5
 
6
6
  * The VPC support in `eb create` is great, but it ends there. Connecting to instances inside a VPC requires manual SSH gateway setup.
7
7
  * The CLI [supports multiple environments][eb-compose], but only in a rigid fashion that isn't usable when those environments share the same codebase.
8
+ * Upgrading running applications to a new version of the platform should be easy with `eb upgrade`, but using a custom AMI to support on-disk encryption means that command can't be used.
8
9
 
9
10
  [eb]: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3.html
10
11
  [eb-compose]: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/ebcli-compose.html
11
12
 
12
13
  ## Usage
13
14
 
15
+ See [the Getting Started guide][getting-started] for a complete tutorial on setting up your AWS account.
16
+
14
17
  Elastic Beans makes heavy use of the [AWS SDK][aws-sdk].
15
18
  Configuration of AWS credentials and region should be completed before using this gem, according to [the SDK configuration instructions][configuration].
16
19
  As the SDK documentation suggests, using environment variables is recommended.
17
20
 
18
21
  [aws-sdk]: https://aws.amazon.com/sdk-for-ruby/
19
22
  [configuration]: http://docs.aws.amazon.com/sdk-for-ruby/latest/DeveloperGuide/aws-ruby-sdk-getting-started.html#aws-ruby-sdk-configuration
23
+ [getting-started]: https://github.com/onemedical/elastic_beans/wiki/Getting-started
20
24
 
21
25
  # Pre-configure the application before creating environments
22
26
  beans configure -n myapp-networking -a myapp \
@@ -295,6 +299,14 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
295
299
 
296
300
  ### Philosophy
297
301
 
302
+ beans is an opinionated but flexible tool.
303
+ It is written for Rails applications and can make assumptions based on that.
304
+ Additionally, it assumes your application was set up by beans and will not handle one set up by hand very well.
305
+ During setup it will configure your application to meet the best-practice criteria for a HIPAA-compliant Rails application.
306
+ However, it will assume future customization is permanent and attempt not to override your choices.
307
+
308
+ Whenever possible, operations are idempotent.
309
+
298
310
  Elastic Beanstalk is an evolving platform, albeit slowly.
299
311
  It has many gaps and surprises in functionality that beans addresses.
300
312
  Whenever possible, beans adds behavior using publicized and approved methods, such as `commands` in an ebextension.
@@ -101,6 +101,21 @@ class ElasticBeans::CLI < Thor
101
101
  error(e)
102
102
  end
103
103
 
104
+ desc ElasticBeans::Command::GetEnv::USAGE, ElasticBeans::Command::GetEnv::DESC
105
+ long_desc ElasticBeans::Command::GetEnv::LONG_DESC
106
+ option :application, aliases: %w(-a), required: true, desc: APPLICATION_DESC
107
+ def getenv(*env_vars)
108
+ @verbose = options[:verbose]
109
+ ElasticBeans::Command::GetEnv.new(
110
+ application: application(
111
+ name: options[:application],
112
+ ),
113
+ ui: ui,
114
+ ).run(*env_vars)
115
+ rescue StandardError => e
116
+ error(e)
117
+ end
118
+
104
119
  desc ElasticBeans::Command::Scale::USAGE, ElasticBeans::Command::Scale::DESC
105
120
  long_desc ElasticBeans::Command::Scale::LONG_DESC
106
121
  option :application, aliases: %w(-a), required: true, desc: APPLICATION_DESC
@@ -0,0 +1,35 @@
1
+ module ElasticBeans
2
+ module Command
3
+ # :nodoc: all
4
+ class GetEnv
5
+ USAGE = "getenv [KEY]..."
6
+ DESC = "Fetch environment variables from the Elastic Beanstalk application"
7
+ LONG_DESC = <<-LONG_DESC
8
+ Fetch environment variables from the Elastic Beanstalk application.
9
+ These are stored in S3 to avoid the 4096-byte limit on environment variables in Elastic Beanstalk.
10
+
11
+ Requires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
12
+ LONG_DESC
13
+
14
+ def initialize(application:, ui:)
15
+ @application = application
16
+ @ui = ui
17
+ end
18
+
19
+ def run(*env_vars)
20
+ outputs = application.env_vars.to_h.each_with_object([]) do |(key, value), acc|
21
+ if env_vars.empty? || env_vars.include?(key)
22
+ acc << "#{key}=#{value}"
23
+ end
24
+ end
25
+ outputs.sort.each do |output|
26
+ ui.info(output)
27
+ end
28
+ end
29
+
30
+ private
31
+
32
+ attr_reader :application, :ui
33
+ end
34
+ end
35
+ end
@@ -2,6 +2,7 @@ require "elastic_beans/command/configure"
2
2
  require "elastic_beans/command/create"
3
3
  require "elastic_beans/command/deploy"
4
4
  require "elastic_beans/command/exec"
5
+ require "elastic_beans/command/get_env"
5
6
  require "elastic_beans/command/scale"
6
7
  require "elastic_beans/command/set_env"
7
8
  require "elastic_beans/command/talk"
@@ -16,9 +16,20 @@ module ElasticBeans
16
16
  @s3_key ||= "#{application.name}/env_vars.json"
17
17
  end
18
18
 
19
+ def to_h
20
+ s3.head_object(bucket: application.bucket_name, key: s3_key)
21
+ response = s3.get_object(bucket: application.bucket_name, key: s3_key)
22
+ existing_script = response.body.read
23
+ JSON.parse(existing_script)
24
+ rescue ::Aws::S3::Errors::NotFound
25
+ {}
26
+ rescue ::Aws::S3::Errors::Forbidden
27
+ raise CannotAccessConfigError.new(bucket_name: application.bucket_name, key: s3_key)
28
+ end
29
+
19
30
  # Updates the environment variables stored in S3 by merging it with the given +env_hash+.
20
31
  def update(env_hash)
21
- body = env_script(existing_env_hash.merge(env_hash))
32
+ body = env_script(to_h.merge(env_hash))
22
33
  s3.put_object(bucket: application.bucket_name, key: s3_key, body: body)
23
34
  end
24
35
 
@@ -30,17 +41,6 @@ module ElasticBeans
30
41
  JSON.dump(env_hash)
31
42
  end
32
43
 
33
- def existing_env_hash
34
- s3.head_object(bucket: application.bucket_name, key: s3_key)
35
- response = s3.get_object(bucket: application.bucket_name, key: s3_key)
36
- existing_script = response.body.read
37
- JSON.parse(existing_script)
38
- rescue ::Aws::S3::Errors::NotFound
39
- {}
40
- rescue ::Aws::S3::Errors::Forbidden
41
- raise CannotAccessConfigError.new(bucket_name: application.bucket_name, key: s3_key)
42
- end
43
-
44
44
  # :nodoc: all
45
45
  # @!visibility private
46
46
  class CannotAccessConfigError < ElasticBeans::Error
@@ -1,3 +1,3 @@
1
1
  module ElasticBeans
2
- VERSION = "0.4.1"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic_beans
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Stegman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-16 00:00:00.000000000 Z
11
+ date: 2016-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -167,6 +167,7 @@ files:
167
167
  - lib/elastic_beans/command/create.rb
168
168
  - lib/elastic_beans/command/deploy.rb
169
169
  - lib/elastic_beans/command/exec.rb
170
+ - lib/elastic_beans/command/get_env.rb
170
171
  - lib/elastic_beans/command/scale.rb
171
172
  - lib/elastic_beans/command/set_env.rb
172
173
  - lib/elastic_beans/command/talk.rb
@@ -216,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
216
217
  version: '0'
217
218
  requirements: []
218
219
  rubyforge_project:
219
- rubygems_version: 2.5.1
220
+ rubygems_version: 2.5.2
220
221
  signing_key:
221
222
  specification_version: 4
222
223
  summary: Elastic Beanstalk environment orchestration for a Rails app