elastic_beans 0.11.0.alpha7 → 0.11.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: ab4560c3622e7fe3d379e37a6691663abdafe52c
4
- data.tar.gz: 9ec0036df9f9df63f1687be7c668244acc231727
3
+ metadata.gz: 898ac7c02cc660301cfce8d699f23b0fd3c161b7
4
+ data.tar.gz: ee4f74a9d7d591faa9d3376451807e5dd619376c
5
5
  SHA512:
6
- metadata.gz: 71a71115042d5a7128f0803754ef5120b2a8aa96b85e6454b5e2c08f719877ba856574566281227a375dbbbd4788e33c2733b89f17dc416638c4e5f79fb3df2d
7
- data.tar.gz: 800d01320e7cf59f0d4ba8e654b643086094cfa103514b542af5aba7cce63908cfb4740039c5aa2c5eae7238c1fcb249f78536b9d4364deb107bd529e8eb2b40
6
+ metadata.gz: 144633191d7abad8a541fc518f9f6331c5b2e77019ae757aa5317f3854c2194804d4dec47c691afb2da357df19ef90057a979f586ee22e9151690570c879b6b5
7
+ data.tar.gz: 2c8dc693592e823cac5def085ed5a0405a78dfdb5b6050c19c6d2011d1065f8da868a2287dbc5d5e67284e221a768f4c87b881cd8b5426a5177f05fed4a8eea0
data/README.md CHANGED
@@ -24,11 +24,9 @@ As the SDK documentation suggests, using environment variables is recommended.
24
24
 
25
25
  # Pre-configure the application before creating environments
26
26
  beans configure -n myapp-networking -a myapp \
27
+ -b SECRET_KEY_BASE -d DATABASE_URL -k KEYPAIR \
27
28
  -p INTERNAL_PUBLIC_KEY -s SSL_CERTIFICATE_ARN \
28
- -k KEYPAIR [-i IMAGE_ID] [-t INSTANCE_TYPE]
29
- beans setenv -a myapp \
30
- DATABASE_URL=mysql2://db.example.com:3306/myapp \
31
- SECRET_KEY_BASE=abc123
29
+ [-i IMAGE_ID] [-t INSTANCE_TYPE]
32
30
 
33
31
  # Create a webserver environment with a pretty DNS name at myapp.TLD (managed by Route53)
34
32
  beans create -a myapp [-d myapp.TLD] [--tags=Environment:production Team:Unicorn] webserver
@@ -65,8 +63,9 @@ As the SDK documentation suggests, using environment variables is recommended.
65
63
 
66
64
  # Update all existing environments and configuration
67
65
  beans configure -n myapp-networking -a myapp \
66
+ [-b SECRET_KEY_BASE] [-d DATABASE_URL] [-k KEYPAIR] \
68
67
  [-p INTERNAL_PUBLIC_KEY] [-s SSL_CERTIFICATE_ARN] \
69
- [-k KEYPAIR] [-i IMAGE_ID] [-t INSTANCE_TYPE]
68
+ [-i IMAGE_ID] [-t INSTANCE_TYPE]
70
69
 
71
70
  ### API
72
71
 
data/exe/beans CHANGED
@@ -2,18 +2,14 @@
2
2
 
3
3
  Signal.trap("INT") do
4
4
  puts "\nInterrupting beans -- if an operation was in progress, it will still be running."
5
- raise Interrupt
5
+ exit 130
6
6
  end
7
7
 
8
8
  Signal.trap("TERM") do
9
9
  puts "Terminating beans -- if an operation was in progress, it will still be running."
10
- raise SignalException.new("TERM")
10
+ exit 143
11
11
  end
12
12
 
13
13
  require "elastic_beans/cli"
14
14
 
15
- begin
16
- ElasticBeans::CLI.start(ARGV)
17
- rescue SignalException => e
18
- exit(128 + e.signo)
19
- end
15
+ ElasticBeans::CLI.start(ARGV)
@@ -16,20 +16,24 @@ class ElasticBeans::CLI < Thor
16
16
  long_desc ElasticBeans::Command::Configure::LONG_DESC
17
17
  option :application, aliases: %w(-a), required: true, desc: APPLICATION_DESC
18
18
  option :network, aliases: %w(-n), required: true, desc: "The name of the CloudFormation stack that contains networking settings"
19
+ option :database_url, aliases: %w(-d), desc: "The DATABASE_URL for the Rails application"
19
20
  option :image_id, aliases: %w(-i), desc: "A custom AMI to use instead of the default Ruby Elastic Beanstalk AMI"
20
21
  option :instance_type, aliases: %w(-t), desc: "A default instance type to use for all environments instead of c4.large"
21
22
  option :internal, type: :boolean, desc: "Configure the webserver to only be available for internal VPC access"
22
23
  option :keypair, aliases: %w(-k), desc: "Required on first run. The EC2 keypair to use for Elastic Beanstalk instances"
23
24
  option :public_key, aliases: %w(-p), desc: "For end-to-end encryption. The public key of the SSL certificate the ELB will verify to communicate with your Rails app"
25
+ option :secret_key_base, aliases: %w(-b), desc: "The SECRET_KEY_BASE for the Rails application"
24
26
  option :ssl_certificate_arn, aliases: %w(-s), desc: "The ARN of the SSL server certificate stored in IAM to attach to the ELB"
25
27
  def configure
26
28
  @verbose = options[:verbose]
27
29
  ElasticBeans::Command::Configure.new(
30
+ database_url: options[:database_url],
28
31
  image_id: options[:image_id],
29
32
  instance_type: options[:instance_type],
30
33
  internal: options[:internal],
31
34
  keypair: options[:keypair],
32
35
  public_key: options[:public_key],
36
+ secret_key_base: options[:secret_key_base],
33
37
  ssl_certificate_arn: options[:ssl_certificate_arn],
34
38
  application: application(name: options[:application]),
35
39
  network: network(stack_name: options[:network]),
@@ -16,11 +16,13 @@ Requires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID an
16
16
  LONG_DESC
17
17
 
18
18
  def initialize(
19
+ database_url:,
19
20
  image_id:,
20
21
  instance_type:,
21
22
  internal:,
22
23
  keypair:,
23
24
  public_key:,
25
+ secret_key_base:,
24
26
  ssl_certificate_arn:,
25
27
  application:,
26
28
  network:,
@@ -28,11 +30,13 @@ Requires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID an
28
30
  iam:,
29
31
  ui:
30
32
  )
33
+ @database_url = database_url
31
34
  @image_id = image_id
32
35
  @instance_type = instance_type
33
36
  @internal = internal
34
37
  @keypair = keypair
35
38
  @public_key = public_key
39
+ @secret_key_base = secret_key_base
36
40
  @ssl_certificate_arn = ssl_certificate_arn
37
41
  @application = application
38
42
  @network = network
@@ -60,6 +64,8 @@ Requires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID an
60
64
  )
61
65
  base_config.upsert(
62
66
  network: network,
67
+ database_url: database_url,
68
+ secret_key_base: secret_key_base,
63
69
  image_id: image_id,
64
70
  instance_type: instance_type,
65
71
  keypair: keypair,
@@ -74,6 +80,8 @@ Requires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID an
74
80
  )
75
81
  webserver_config.upsert(
76
82
  network: network,
83
+ database_url: database_url,
84
+ secret_key_base: secret_key_base,
77
85
  image_id: image_id,
78
86
  instance_type: instance_type,
79
87
  internal: internal,
@@ -98,6 +106,8 @@ Requires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID an
98
106
  )
99
107
  exec_config.upsert(
100
108
  network: network,
109
+ database_url: database_url,
110
+ secret_key_base: secret_key_base,
101
111
  image_id: image_id,
102
112
  instance_type: instance_type,
103
113
  keypair: keypair,
@@ -119,6 +129,8 @@ Requires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID an
119
129
  )
120
130
  scheduler_config.upsert(
121
131
  network: network,
132
+ database_url: database_url,
133
+ secret_key_base: secret_key_base,
122
134
  image_id: image_id,
123
135
  instance_type: instance_type,
124
136
  keypair: keypair,
@@ -142,6 +154,8 @@ Requires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID an
142
154
  )
143
155
  worker_config.upsert(
144
156
  network: network,
157
+ database_url: database_url,
158
+ secret_key_base: secret_key_base,
145
159
  image_id: image_id,
146
160
  instance_type: instance_type,
147
161
  keypair: keypair,
@@ -164,12 +178,14 @@ Requires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID an
164
178
 
165
179
  attr_reader(
166
180
  :application,
181
+ :database_url,
167
182
  :image_id,
168
183
  :instance_type,
169
184
  :internal,
170
185
  :keypair,
171
186
  :network,
172
187
  :public_key,
188
+ :secret_key_base,
173
189
  :ssl_certificate_arn,
174
190
  :elastic_beanstalk,
175
191
  :iam,
@@ -109,13 +109,9 @@ Requires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID an
109
109
  rescue ElasticBeans::SSH::BastionAuthenticationError => e
110
110
  raise BastionAuthenticationError.new(cause: e)
111
111
  ensure
112
- begin
113
- ui.info("Cleaning up, please do not interrupt!")
114
- application.kill_command(freeze_command)
115
- application.deregister_command(command)
116
- rescue Interrupt
117
- retry
118
- end
112
+ ui.info("Cleaning up, please do not interrupt!")
113
+ application.kill_command(freeze_command)
114
+ application.deregister_command(command)
119
115
  end
120
116
  else
121
117
  application.enqueue_command(command)
@@ -11,7 +11,7 @@ module ElasticBeans
11
11
  # namespace) directly.
12
12
  class ConfigurationTemplate
13
13
  # The solution stack used for a new application. Should not be hardcoded, but here we are.
14
- SOLUTION_STACK_NAME = "64bit Amazon Linux 2016.09 v2.3.3 running Ruby 2.3 (Puma)"
14
+ SOLUTION_STACK_NAME = "64bit Amazon Linux 2016.09 v2.2.0 running Ruby 2.3 (Puma)"
15
15
  # :category: Internal
16
16
  WORKER_TEMPLATE_NAME_PATTERN = /\Aworker-(?<queue>\w+)\z/
17
17
 
@@ -13,9 +13,11 @@ module ElasticBeans
13
13
  protected
14
14
 
15
15
  # Constructs the common configuration for all environments.
16
- # +network+, +keypair+, and +iam+ are all required on first run.
16
+ # +network+, +database_url+, +secret_key_base+, +keypair+, and +iam+ are all required on first run.
17
17
  def build_option_settings(
18
18
  network: nil,
19
+ database_url: nil,
20
+ secret_key_base: nil,
19
21
  keypair: nil,
20
22
  iam: nil,
21
23
  image_id: nil,
@@ -32,8 +34,12 @@ module ElasticBeans
32
34
  end
33
35
 
34
36
  keypair_setting = template_option_setting(template: template, namespace: "aws:autoscaling:launchconfiguration", option_name: "EC2KeyName", override: keypair)
35
- if keypair_setting[:value].nil?
37
+ database_url_setting = template_option_setting(template: template, namespace: "aws:elasticbeanstalk:application:environment", option_name: "DATABASE_URL", override: database_url)
38
+ secret_key_base_setting = template_option_setting(template: template, namespace: "aws:elasticbeanstalk:application:environment", option_name: "SECRET_KEY_BASE", override: secret_key_base)
39
+ if database_url_setting[:value].nil? || secret_key_base_setting[:value].nil? || keypair_setting[:value].nil?
36
40
  raise MissingOptionsError.new(
41
+ database_url: database_url_setting[:value],
42
+ secret_key_base: secret_key_base_setting[:value],
37
43
  keypair: keypair_setting[:value],
38
44
  )
39
45
  end
@@ -60,6 +66,8 @@ module ElasticBeans
60
66
  template_option_setting(template: template, namespace: "aws:ec2:vpc", option_name: "VPCId", override: vpc_id(network)),
61
67
  instance_profile_setting,
62
68
  keypair_setting,
69
+ database_url_setting,
70
+ secret_key_base_setting,
63
71
  ]
64
72
  if image_id
65
73
  settings << template_option_setting(template: template, namespace: "aws:autoscaling:launchconfiguration", option_name: "ImageId", override: image_id)
@@ -119,7 +127,9 @@ module ElasticBeans
119
127
  # :nodoc: all
120
128
  # @!visibility private
121
129
  class MissingOptionsError < ElasticBeans::Error
122
- def initialize(keypair:)
130
+ def initialize(database_url:, secret_key_base:, keypair:)
131
+ @database_url = database_url
132
+ @secret_key_base = secret_key_base
123
133
  @keypair = keypair
124
134
  end
125
135
 
@@ -127,9 +137,15 @@ module ElasticBeans
127
137
  require "elastic_beans/cli"
128
138
  require "elastic_beans/cli/string_shell"
129
139
  msg = "Some required options are missing and must be set when configuring an application:\n\n"
140
+ if @database_url.nil?
141
+ msg << "--database-url DATABASE_URL must point to a valid database, and is required for running a Rails application\n"
142
+ end
130
143
  if @keypair.nil?
131
144
  msg << "--keypair KEYPAIR must be a valid EC2 key pair, and will be used on Elastic Beanstalk instances\n"
132
145
  end
146
+ if @secret_key_base.nil?
147
+ msg << "--secret-key-base SECRET_KEY_BASE can be any value, and is required for running a Rails application\n"
148
+ end
133
149
  msg << <<-MESSAGE
134
150
 
135
151
  Please re-run `#{command_as_string "configure"}` with these options.
@@ -1,3 +1,3 @@
1
1
  module ElasticBeans
2
- VERSION = "0.11.0.alpha7"
2
+ VERSION = "0.11.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic_beans
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0.alpha7
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Stegman
@@ -250,9 +250,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
250
250
  version: '0'
251
251
  required_rubygems_version: !ruby/object:Gem::Requirement
252
252
  requirements:
253
- - - ">"
253
+ - - ">="
254
254
  - !ruby/object:Gem::Version
255
- version: 1.3.1
255
+ version: '0'
256
256
  requirements: []
257
257
  rubyforge_project:
258
258
  rubygems_version: 2.6.11