elastic_beans 0.11.0.alpha5 → 0.11.0.alpha7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/exe/beans +7 -3
- data/lib/elastic_beans/aws/cloudformation_stack.rb +10 -8
- data/lib/elastic_beans/command/exec.rb +7 -3
- data/lib/elastic_beans/network.rb +24 -2
- data/lib/elastic_beans/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab4560c3622e7fe3d379e37a6691663abdafe52c
|
4
|
+
data.tar.gz: 9ec0036df9f9df63f1687be7c668244acc231727
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71a71115042d5a7128f0803754ef5120b2a8aa96b85e6454b5e2c08f719877ba856574566281227a375dbbbd4788e33c2733b89f17dc416638c4e5f79fb3df2d
|
7
|
+
data.tar.gz: 800d01320e7cf59f0d4ba8e654b643086094cfa103514b542af5aba7cce63908cfb4740039c5aa2c5eae7238c1fcb249f78536b9d4364deb107bd529e8eb2b40
|
data/README.md
CHANGED
@@ -194,9 +194,11 @@ It must have the following outputs, which will be used for the corresponding set
|
|
194
194
|
* `ApplicationSecurityGroup` - [`aws:autoscaling:launchconfiguration/SecurityGroups`][launchconfiguration]
|
195
195
|
* Allow TCP connections from the `ELBSecurityGroup` on ports 80 and 443
|
196
196
|
* `ApplicationSubnet` - [`aws:ec2:vpc/Subnets`][vpc]
|
197
|
+
* Use multiple subnets by appending digits to this name, e.g. `ApplicationSubnet` and `ApplicationSubnet2`
|
197
198
|
* `ELBSecurityGroup` - [`aws:elb:loadbalancer/SecurityGroups`][loadbalancer], [`aws:elb:loadbalancer/ManagedSecurityGroup`][loadbalancer]
|
198
199
|
* Allow TCP connections on ports 80 and 443 from `0.0.0.0/0`
|
199
200
|
* `ELBSubnet` - [`aws:ec2:vpc/ELBSubnets`][vpc]
|
201
|
+
* Use multiple subnets by appending digits to this name, e.g. `ELBSubnet` and `ELBSubnet2`
|
200
202
|
* `SSHSecurityGroup` - [`aws:ec2:vpc/Subnets`][vpc]
|
201
203
|
* Allow TCP connections from your VPC on ports 80 and 443
|
202
204
|
* `VpcId` - [`aws:ec2:vpc/VPCId`][vpc]
|
data/exe/beans
CHANGED
@@ -2,14 +2,18 @@
|
|
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
|
-
|
5
|
+
raise Interrupt
|
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
|
-
|
10
|
+
raise SignalException.new("TERM")
|
11
11
|
end
|
12
12
|
|
13
13
|
require "elastic_beans/cli"
|
14
14
|
|
15
|
-
|
15
|
+
begin
|
16
|
+
ElasticBeans::CLI.start(ARGV)
|
17
|
+
rescue SignalException => e
|
18
|
+
exit(128 + e.signo)
|
19
|
+
end
|
@@ -9,15 +9,17 @@ module ElasticBeans
|
|
9
9
|
class CloudformationStack
|
10
10
|
STACK_STATUSES = %w(CREATE_COMPLETE UPDATE_COMPLETE UPDATE_ROLLBACK_COMPLETE)
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
attr_reader :name
|
13
|
+
|
14
|
+
def initialize(name, cloudformation:)
|
15
|
+
@name = name
|
14
16
|
@cloudformation = cloudformation
|
15
17
|
end
|
16
18
|
|
17
19
|
def stack_output(output_key)
|
18
20
|
output = stack.outputs.find { |o| o.output_key == output_key }
|
19
21
|
unless output
|
20
|
-
raise MissingOutputError.new(stack_name:
|
22
|
+
raise MissingOutputError.new(stack_name: name, output_key: output_key)
|
21
23
|
end
|
22
24
|
output.output_value
|
23
25
|
end
|
@@ -28,20 +30,20 @@ module ElasticBeans
|
|
28
30
|
|
29
31
|
private
|
30
32
|
|
31
|
-
attr_reader :
|
33
|
+
attr_reader :cloudformation
|
32
34
|
|
33
35
|
def stack
|
34
|
-
s = cloudformation.describe_stacks(stack_name:
|
36
|
+
s = cloudformation.describe_stacks(stack_name: name).stacks.find { |stack|
|
35
37
|
STACK_STATUSES.include?(stack.stack_status)
|
36
38
|
}
|
37
39
|
unless s
|
38
|
-
raise MissingStackError.new(stack_name:
|
40
|
+
raise MissingStackError.new(stack_name: name)
|
39
41
|
end
|
40
42
|
s
|
41
43
|
rescue ::Aws::CloudFormation::Errors::ValidationError
|
42
|
-
raise MissingStackError.new(stack_name:
|
44
|
+
raise MissingStackError.new(stack_name: name)
|
43
45
|
rescue ::Aws::CloudFormation::Errors::AccessDenied
|
44
|
-
raise AccessDeniedCloudFormationError.new(stack_name:
|
46
|
+
raise AccessDeniedCloudFormationError.new(stack_name: name)
|
45
47
|
rescue ::Aws::CloudFormation::Errors::Throttling
|
46
48
|
sleep 5
|
47
49
|
retry
|
@@ -109,9 +109,13 @@ 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
|
-
|
113
|
-
|
114
|
-
|
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
|
115
119
|
end
|
116
120
|
else
|
117
121
|
application.enqueue_command(command)
|
@@ -5,8 +5,10 @@ module ElasticBeans
|
|
5
5
|
class Network
|
6
6
|
APPLICATION_SECURITY_GROUP_KEY = "ApplicationSecurityGroup"
|
7
7
|
APPLICATION_SUBNET_KEY = "ApplicationSubnet"
|
8
|
+
APPLICATION_SUBNET_KEY_PATTERN = /\AApplicationSubnet\d*\z/
|
8
9
|
ELB_SECURITY_GROUP_KEY = "ELBSecurityGroup"
|
9
10
|
ELB_SUBNET_KEY = "ELBSubnet"
|
11
|
+
ELB_SUBNET_KEY_PATTERN = /\AELBSubnet\d*\z/
|
10
12
|
SSH_SECURITY_GROUP_KEY = "SSHSecurityGroup"
|
11
13
|
VPC_KEY = "VpcId"
|
12
14
|
|
@@ -19,7 +21,11 @@ module ElasticBeans
|
|
19
21
|
end
|
20
22
|
|
21
23
|
def application_subnets
|
22
|
-
|
24
|
+
subnet_outputs = stack.stack_outputs.select { |key, value| key =~ APPLICATION_SUBNET_KEY_PATTERN }
|
25
|
+
if subnet_outputs.empty?
|
26
|
+
raise MissingNetworkingError.new(stack: stack, key: APPLICATION_SUBNET_KEY)
|
27
|
+
end
|
28
|
+
subnet_outputs.values
|
23
29
|
end
|
24
30
|
|
25
31
|
def elb_security_groups
|
@@ -27,7 +33,11 @@ module ElasticBeans
|
|
27
33
|
end
|
28
34
|
|
29
35
|
def elb_subnets
|
30
|
-
|
36
|
+
subnet_outputs = stack.stack_outputs.select { |key, value| key =~ ELB_SUBNET_KEY_PATTERN }
|
37
|
+
if subnet_outputs.empty?
|
38
|
+
raise MissingNetworkingError.new(stack: stack, key: ELB_SUBNET_KEY)
|
39
|
+
end
|
40
|
+
subnet_outputs.values
|
31
41
|
end
|
32
42
|
|
33
43
|
def ssh_security_group
|
@@ -41,5 +51,17 @@ module ElasticBeans
|
|
41
51
|
private
|
42
52
|
|
43
53
|
attr_reader :stack
|
54
|
+
|
55
|
+
class MissingNetworkingError < ElasticBeans::Error
|
56
|
+
def initialize(stack:, key:)
|
57
|
+
@stack = stack
|
58
|
+
@key = key
|
59
|
+
end
|
60
|
+
|
61
|
+
def message
|
62
|
+
"Networking stack '#{@stack.name}' is missing output '#{@key}'." \
|
63
|
+
" Make sure the stack matches the outputs required."
|
64
|
+
end
|
65
|
+
end
|
44
66
|
end
|
45
67
|
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.11.0.
|
4
|
+
version: 0.11.0.alpha7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Stegman
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|