simple_deploy 0.9.2 → 0.10.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/simple_deploy/aws/cloud_formation.rb +5 -5
- data/lib/simple_deploy/aws/helpers.rb +20 -0
- data/lib/simple_deploy/aws/instance_reader.rb +10 -13
- data/lib/simple_deploy/aws/simpledb.rb +5 -5
- data/lib/simple_deploy/aws.rb +1 -0
- data/lib/simple_deploy/cli/attributes.rb +4 -2
- data/lib/simple_deploy/cli/clone.rb +8 -3
- data/lib/simple_deploy/cli/create.rb +4 -2
- data/lib/simple_deploy/cli/deploy.rb +4 -2
- data/lib/simple_deploy/cli/destroy.rb +4 -2
- data/lib/simple_deploy/cli/events.rb +4 -2
- data/lib/simple_deploy/cli/execute.rb +4 -2
- data/lib/simple_deploy/cli/instances.rb +4 -2
- data/lib/simple_deploy/cli/list.rb +5 -2
- data/lib/simple_deploy/cli/outputs.rb +4 -2
- data/lib/simple_deploy/cli/parameters.rb +4 -2
- data/lib/simple_deploy/cli/protect.rb +4 -2
- data/lib/simple_deploy/cli/resources.rb +4 -2
- data/lib/simple_deploy/cli/shared.rb +34 -2
- data/lib/simple_deploy/cli/status.rb +4 -2
- data/lib/simple_deploy/cli/template.rb +4 -2
- data/lib/simple_deploy/cli/update.rb +4 -2
- data/lib/simple_deploy/configuration.rb +39 -4
- data/lib/simple_deploy/version.rb +1 -1
- data/spec/aws/cloud_formation_spec.rb +162 -135
- data/spec/aws/helpers_spec.rb +51 -0
- data/spec/aws/instance_reader_spec.rb +181 -167
- data/spec/aws/simpledb_spec.rb +78 -50
- data/spec/cli/attributes_spec.rb +22 -2
- data/spec/cli/clone_spec.rb +7 -8
- data/spec/cli/deploy_spec.rb +7 -10
- data/spec/cli/destroy_spec.rb +3 -4
- data/spec/cli/protect_spec.rb +7 -11
- data/spec/cli/shared_spec.rb +107 -17
- data/spec/cli/update_spec.rb +4 -7
- data/spec/config_spec.rb +50 -3
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 087c4e0c37329c2f21af41d9f923315eff58b30b
|
4
|
+
data.tar.gz: c2986b982379d6479e4c171dd45dd45dc7bac1f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c851300e97e2f000dcfcea67e0c1c270d48ef866cfda0c92d822c0c55c2a1cb1d4d4638f2e1f25e4e1e74f73d6a9db08bb8ca3e3ff342aa2e784e5a8bf0953f5
|
7
|
+
data.tar.gz: a838a2de6528b110e98318ccba7af8ca47fb3ae79509060bd2f5f1a3a333c869da2f772971d2045e6758a484803818e62e03ec06bc8e0a957d1432ffe2f0e970
|
data/CHANGELOG.md
CHANGED
@@ -4,12 +4,12 @@ module SimpleDeploy
|
|
4
4
|
class AWS
|
5
5
|
class CloudFormation
|
6
6
|
|
7
|
+
include Helpers
|
8
|
+
|
7
9
|
def initialize
|
8
|
-
@config
|
9
|
-
@logger
|
10
|
-
@connect = Fog::AWS::CloudFormation.new
|
11
|
-
:aws_secret_access_key => @config.secret_key,
|
12
|
-
:region => @config.region
|
10
|
+
@config = SimpleDeploy.config
|
11
|
+
@logger = SimpleDeploy.logger
|
12
|
+
@connect = Fog::AWS::CloudFormation.new connection_args
|
13
13
|
end
|
14
14
|
|
15
15
|
def create(args)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module SimpleDeploy
|
2
|
+
class AWS
|
3
|
+
module Helpers
|
4
|
+
|
5
|
+
def connection_args
|
6
|
+
{
|
7
|
+
aws_access_key_id: @config.access_key,
|
8
|
+
aws_secret_access_key: @config.secret_key,
|
9
|
+
region: @config.region
|
10
|
+
}.tap do |a|
|
11
|
+
|
12
|
+
if @config.temporary_credentials?
|
13
|
+
a.merge!({ aws_session_token: @config.security_token })
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -1,14 +1,19 @@
|
|
1
1
|
module SimpleDeploy
|
2
2
|
class AWS
|
3
3
|
class InstanceReader
|
4
|
+
|
5
|
+
include Helpers
|
6
|
+
|
4
7
|
def initialize
|
5
|
-
@config
|
8
|
+
@config = SimpleDeploy.config
|
9
|
+
@asg_connect = Fog::AWS::AutoScaling.new connection_args
|
10
|
+
@ec2_connect = Fog::Compute::AWS.new connection_args
|
6
11
|
end
|
7
12
|
|
8
13
|
def list_stack_instances(stack_name)
|
9
14
|
|
10
15
|
instances = []
|
11
|
-
|
16
|
+
|
12
17
|
#Nested stack
|
13
18
|
nested_stacks = nested_stacks_names(stack_name)
|
14
19
|
instances = nested_stacks.map {|stack| list_stack_instances stack }.flatten if nested_stacks.any?
|
@@ -28,11 +33,7 @@ module SimpleDeploy
|
|
28
33
|
private
|
29
34
|
|
30
35
|
def list_instances(asg_id)
|
31
|
-
|
32
|
-
:aws_secret_access_key => @config.secret_key,
|
33
|
-
:region => @config.region
|
34
|
-
|
35
|
-
body = @asg.describe_auto_scaling_groups('AutoScalingGroupNames' => [asg_id]).body
|
36
|
+
body = @asg_connect.describe_auto_scaling_groups('AutoScalingGroupNames' => [asg_id]).body
|
36
37
|
result = body['DescribeAutoScalingGroupsResult']['AutoScalingGroups'].last
|
37
38
|
return [] unless result
|
38
39
|
|
@@ -40,12 +41,8 @@ module SimpleDeploy
|
|
40
41
|
end
|
41
42
|
|
42
43
|
def describe_instances(instances)
|
43
|
-
@
|
44
|
-
|
45
|
-
:region => @config.region
|
46
|
-
|
47
|
-
@ec2.describe_instances('instance-state-name' => 'running',
|
48
|
-
'instance-id' => instances).body['reservationSet']
|
44
|
+
@ec2_connect.describe_instances('instance-state-name' => 'running',
|
45
|
+
'instance-id' => instances).body['reservationSet']
|
49
46
|
end
|
50
47
|
|
51
48
|
def cloud_formation
|
@@ -4,11 +4,11 @@ module SimpleDeploy
|
|
4
4
|
class AWS
|
5
5
|
class SimpleDB
|
6
6
|
|
7
|
+
include Helpers
|
8
|
+
|
7
9
|
def initialize
|
8
|
-
|
9
|
-
@connect = Fog::AWS::SimpleDB.new
|
10
|
-
:aws_secret_access_key => c.secret_key,
|
11
|
-
:region => c.region
|
10
|
+
@config = SimpleDeploy.config
|
11
|
+
@connect = Fog::AWS::SimpleDB.new connection_args
|
12
12
|
end
|
13
13
|
|
14
14
|
def domains
|
@@ -31,7 +31,7 @@ module SimpleDeploy
|
|
31
31
|
options = { 'ConsistentRead' => true }
|
32
32
|
data = {}
|
33
33
|
next_token = nil
|
34
|
-
|
34
|
+
|
35
35
|
while true
|
36
36
|
options.merge! 'NextToken' => next_token
|
37
37
|
chunk = @connect.select(query, options).body
|
data/lib/simple_deploy/aws.rb
CHANGED
@@ -23,12 +23,14 @@ EOS
|
|
23
23
|
opt :log_level, "Log level: debug, info, warn, error", :type => :string,
|
24
24
|
:default => 'info'
|
25
25
|
opt :name, "Stack name to manage", :type => :string
|
26
|
+
opt :read_from_env, "Read credentials and region from environment variables"
|
26
27
|
end
|
27
28
|
|
28
29
|
valid_options? :provided => @opts,
|
29
|
-
:required => [:environment, :name]
|
30
|
+
:required => [:environment, :name, :read_from_env]
|
30
31
|
|
31
|
-
|
32
|
+
config_arg = @opts[:read_from_env] ? :read_from_env : @opts[:environment]
|
33
|
+
SimpleDeploy.create_config config_arg
|
32
34
|
SimpleDeploy.logger @opts[:log_level]
|
33
35
|
@stack = Stack.new :name => @opts[:name],
|
34
36
|
:environment => @opts[:environment]
|
@@ -21,7 +21,7 @@ EOS
|
|
21
21
|
opt :environment, "Set the target environment", :type => :string
|
22
22
|
opt :input_stack, "Read outputs from given stack(s) and map them \
|
23
23
|
to parameter inputs in the new stack. These will be passed to inputs with \
|
24
|
-
matching or pluralized names. Can be specified multiple times.", :type => :string,
|
24
|
+
matching or pluralized names. Can be specified multiple times.", :type => :string,
|
25
25
|
:multi => true
|
26
26
|
opt :log_level, "Log level: debug, info, warn, error", :type => :string,
|
27
27
|
:default => 'info'
|
@@ -30,12 +30,17 @@ matching or pluralized names. Can be specified multiple times.", :type => :stri
|
|
30
30
|
opt :attributes, "= separated attribute and it's value", :type => :string,
|
31
31
|
:multi => true
|
32
32
|
opt :template, "Path to a new template file", :type => :string
|
33
|
+
opt :read_from_env, "Read credentials and region from environment variables"
|
33
34
|
end
|
34
35
|
|
35
36
|
valid_options? :provided => @opts,
|
36
|
-
:required => [:environment,
|
37
|
+
:required => [:environment,
|
38
|
+
:source_name,
|
39
|
+
:new_name,
|
40
|
+
:read_from_env]
|
37
41
|
|
38
|
-
|
42
|
+
config_arg = @opts[:read_from_env] ? :read_from_env : @opts[:environment]
|
43
|
+
SimpleDeploy.create_config config_arg
|
39
44
|
SimpleDeploy.logger @opts[:log_level]
|
40
45
|
|
41
46
|
override_attributes = parse_attributes :attributes => @opts[:attributes]
|
@@ -28,13 +28,15 @@ matching or pluralized names. Can be specified multiple times.", :type => :stri
|
|
28
28
|
opt :log_level, "Log level: debug, info, warn, error", :type => :string,
|
29
29
|
:default => 'info'
|
30
30
|
opt :name, "Stack name(s) of stack to deploy", :type => :string
|
31
|
+
opt :read_from_env, "Read credentials and region from environment variables"
|
31
32
|
opt :template, "Path to the template file", :type => :string
|
32
33
|
end
|
33
34
|
|
34
35
|
valid_options? :provided => @opts,
|
35
|
-
:required => [:environment, :name, :template]
|
36
|
+
:required => [:environment, :name, :read_from_env, :template]
|
36
37
|
|
37
|
-
|
38
|
+
config_arg = @opts[:read_from_env] ? :read_from_env : @opts[:environment]
|
39
|
+
SimpleDeploy.create_config config_arg
|
38
40
|
SimpleDeploy.logger @opts[:log_level]
|
39
41
|
stack = Stack.new :name => @opts[:name],
|
40
42
|
:environment => @opts[:environment]
|
@@ -49,14 +49,16 @@ EOS
|
|
49
49
|
opt :name, "Stack name(s) of stack to deploy", :type => :string,
|
50
50
|
:multi => true
|
51
51
|
opt :quiet, "Quiet, do not send notifications"
|
52
|
+
opt :read_from_env, "Read credentials and region from environment variables"
|
52
53
|
opt :external, "Use external IP for ssh commands"
|
53
54
|
opt :internal, "Use internal IP for ssh commands"
|
54
55
|
end
|
55
56
|
|
56
57
|
valid_options? :provided => @opts,
|
57
|
-
:required => [:environment, :name]
|
58
|
+
:required => [:environment, :name, :read_from_env]
|
58
59
|
|
59
|
-
|
60
|
+
config_arg = @opts[:read_from_env] ? :read_from_env : @opts[:environment]
|
61
|
+
SimpleDeploy.create_config config_arg
|
60
62
|
logger = SimpleDeploy.logger @opts[:log_level]
|
61
63
|
|
62
64
|
new_attributes = parse_attributes :attributes => @opts[:attributes]
|
@@ -21,12 +21,14 @@ EOS
|
|
21
21
|
opt :log_level, "Log level: debug, info, warn, error", :type => :string,
|
22
22
|
:default => 'info'
|
23
23
|
opt :name, "Stack name(s) of stack to deploy", :type => :string
|
24
|
+
opt :read_from_env, "Read credentials and region from environment variables"
|
24
25
|
end
|
25
26
|
|
26
27
|
valid_options? :provided => @opts,
|
27
|
-
:required => [:environment, :name]
|
28
|
+
:required => [:environment, :name, :read_from_env]
|
28
29
|
|
29
|
-
|
30
|
+
config_arg = @opts[:read_from_env] ? :read_from_env : @opts[:environment]
|
31
|
+
SimpleDeploy.create_config config_arg
|
30
32
|
SimpleDeploy.logger @opts[:log_level]
|
31
33
|
stack = Stack.new :name => @opts[:name],
|
32
34
|
:environment => @opts[:environment]
|
@@ -21,12 +21,14 @@ EOS
|
|
21
21
|
:default => 3
|
22
22
|
opt :environment, "Set the target environment", :type => :string
|
23
23
|
opt :name, "Stack name to manage", :type => :string
|
24
|
+
opt :read_from_env, "Read credentials and region from environment variables"
|
24
25
|
end
|
25
26
|
|
26
27
|
valid_options? :provided => @opts,
|
27
|
-
:required => [:environment, :name]
|
28
|
+
:required => [:environment, :name, :read_from_env]
|
28
29
|
|
29
|
-
|
30
|
+
config_arg = @opts[:read_from_env] ? :read_from_env : @opts[:environment]
|
31
|
+
SimpleDeploy.create_config config_arg
|
30
32
|
SimpleDeploy.logger @opts[:log_level]
|
31
33
|
stack = Stack.new :name => @opts[:name],
|
32
34
|
:environment => @opts[:environment]
|
@@ -36,13 +36,15 @@ EOS
|
|
36
36
|
opt :name, "Stack name(s) of stack to deploy", :type => :string,
|
37
37
|
:multi => true
|
38
38
|
opt :pty, "Set pty to true when executing commands."
|
39
|
+
opt :read_from_env, "Read credentials and region from environment variables"
|
39
40
|
opt :sudo, "Execute command with sudo"
|
40
41
|
end
|
41
42
|
|
42
43
|
valid_options? :provided => @opts,
|
43
|
-
:required => [:environment, :name]
|
44
|
+
:required => [:environment, :name, :read_from_env]
|
44
45
|
|
45
|
-
|
46
|
+
config_arg = @opts[:read_from_env] ? :read_from_env : @opts[:environment]
|
47
|
+
SimpleDeploy.create_config config_arg
|
46
48
|
logger = SimpleDeploy.logger @opts[:log_level]
|
47
49
|
|
48
50
|
@opts[:name].each do |name|
|
@@ -29,12 +29,14 @@ EOS
|
|
29
29
|
opt :name, "Stack name to manage", :type => :string
|
30
30
|
opt :external, "Return external IP for instances."
|
31
31
|
opt :internal, "Return internal IP for instances."
|
32
|
+
opt :read_from_env, "Read credentials and region from environment variables"
|
32
33
|
end
|
33
34
|
|
34
35
|
valid_options? :provided => @opts,
|
35
|
-
:required => [:environment, :name]
|
36
|
+
:required => [:environment, :name, :read_from_env]
|
36
37
|
|
37
|
-
|
38
|
+
config_arg = @opts[:read_from_env] ? :read_from_env : @opts[:environment]
|
39
|
+
SimpleDeploy.create_config config_arg
|
38
40
|
logger = SimpleDeploy.logger @opts[:log_level]
|
39
41
|
|
40
42
|
stack = Stack.new :name => @opts[:name],
|
@@ -21,13 +21,16 @@ EOS
|
|
21
21
|
opt :environment, "Set the target environment", :type => :string
|
22
22
|
opt :log_level, "Log level: debug, info, warn, error", :type => :string,
|
23
23
|
:default => 'info'
|
24
|
+
opt :read_from_env, "Read credentials and region from environment variables"
|
24
25
|
opt :help, "Display Help"
|
25
26
|
end
|
26
27
|
|
27
28
|
valid_options? :provided => @opts,
|
28
|
-
:required => [:environment]
|
29
|
+
:required => [:environment, :read_from_env]
|
30
|
+
|
31
|
+
config_arg = @opts[:read_from_env] ? :read_from_env : @opts[:environment]
|
32
|
+
SimpleDeploy.create_config config_arg
|
29
33
|
|
30
|
-
SimpleDeploy.create_config @opts[:environment]
|
31
34
|
SimpleDeploy.logger @opts[:log_level]
|
32
35
|
|
33
36
|
stacks = SimpleDeploy::StackLister.new.all.sort
|
@@ -23,12 +23,14 @@ EOS
|
|
23
23
|
opt :log_level, "Log level: debug, info, warn, error", :type => :string,
|
24
24
|
:default => 'warn'
|
25
25
|
opt :name, "Stack name to manage", :type => :string
|
26
|
+
opt :read_from_env, "Read credentials and region from environment variables"
|
26
27
|
end
|
27
28
|
|
28
29
|
valid_options? :provided => @opts,
|
29
|
-
:required => [:environment, :name]
|
30
|
+
:required => [:environment, :name, :read_from_env]
|
30
31
|
|
31
|
-
|
32
|
+
config_arg = @opts[:read_from_env] ? :read_from_env : @opts[:environment]
|
33
|
+
SimpleDeploy.create_config config_arg
|
32
34
|
logger = SimpleDeploy.logger @opts[:log_level]
|
33
35
|
stack = Stack.new :name => @opts[:name],
|
34
36
|
:environment => @opts[:environment]
|
@@ -21,12 +21,14 @@ EOS
|
|
21
21
|
opt :log_level, "Log level: debug, info, warn, error", :type => :string,
|
22
22
|
:default => 'warn'
|
23
23
|
opt :name, "Stack name to manage", :type => :string
|
24
|
+
opt :read_from_env, "Read credentials and region from environment variables"
|
24
25
|
end
|
25
26
|
|
26
27
|
valid_options? :provided => @opts,
|
27
|
-
:required => [:environment, :name]
|
28
|
+
:required => [:environment, :name, :read_from_env]
|
28
29
|
|
29
|
-
|
30
|
+
config_arg = @opts[:read_from_env] ? :read_from_env : @opts[:environment]
|
31
|
+
SimpleDeploy.create_config config_arg
|
30
32
|
SimpleDeploy.logger @opts[:log_level]
|
31
33
|
stack = Stack.new :name => @opts[:name],
|
32
34
|
:environment => @opts[:environment]
|
@@ -24,12 +24,14 @@ EOS
|
|
24
24
|
:default => 'info'
|
25
25
|
opt :name, "Stack name(s) of stacks to protect", :type => :string,
|
26
26
|
:multi => true
|
27
|
+
opt :read_from_env, "Read credentials and region from environment variables"
|
27
28
|
end
|
28
29
|
|
29
30
|
valid_options? :provided => @opts,
|
30
|
-
:required => [:environment, :name]
|
31
|
+
:required => [:environment, :name, :read_from_env]
|
31
32
|
|
32
|
-
|
33
|
+
config_arg = @opts[:read_from_env] ? :read_from_env : @opts[:environment]
|
34
|
+
SimpleDeploy.create_config config_arg
|
33
35
|
SimpleDeploy.logger @opts[:log_level]
|
34
36
|
|
35
37
|
@opts[:name].each do |name|
|
@@ -22,12 +22,14 @@ EOS
|
|
22
22
|
opt :log_level, "Log level: debug, info, warn, error", :type => :string,
|
23
23
|
:default => 'info'
|
24
24
|
opt :name, "Stack name to manage", :type => :string
|
25
|
+
opt :read_from_env, "Read credentials and region from environment variables"
|
25
26
|
end
|
26
27
|
|
27
28
|
valid_options? :provided => @opts,
|
28
|
-
:required => [:environment, :name]
|
29
|
+
:required => [:environment, :name, :read_from_env]
|
29
30
|
|
30
|
-
|
31
|
+
config_arg = @opts[:read_from_env] ? :read_from_env : @opts[:environment]
|
32
|
+
SimpleDeploy.create_config config_arg
|
31
33
|
SimpleDeploy.logger @opts[:log_level]
|
32
34
|
stack = Stack.new :name => @opts[:name],
|
33
35
|
:environment => @opts[:environment]
|
@@ -20,14 +20,29 @@ module SimpleDeploy
|
|
20
20
|
provided = args[:provided]
|
21
21
|
required = args[:required]
|
22
22
|
|
23
|
-
|
23
|
+
if provided[:environment] && provided[:read_from_env]
|
24
|
+
SimpleDeploy.logger.error "You cannot specify both --environment and --read-from-env"
|
25
|
+
exit 1
|
26
|
+
end
|
27
|
+
|
28
|
+
if required.include?(:environment) && required.include?(:read_from_env)
|
29
|
+
if !provided.include?(:environment) && !provided.include?(:read_from_env)
|
30
|
+
msg = "Either '--environment' or '--read-from-env' is required but not specified"
|
31
|
+
SimpleDeploy.logger.error msg
|
32
|
+
exit 1
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
required.reject { |i| [:environment, :read_from_env].include? i }.each do |opt|
|
24
37
|
unless provided[opt]
|
25
38
|
SimpleDeploy.logger.error "Option '#{opt} (-#{opt[0]})' required but not specified."
|
26
39
|
exit 1
|
27
40
|
end
|
28
41
|
end
|
29
42
|
|
30
|
-
if
|
43
|
+
validate_credential_env_vars if provided.has_key?(:read_from_env)
|
44
|
+
|
45
|
+
if provided[:environment]
|
31
46
|
unless SimpleDeploy.environments.keys.include? provided[:environment]
|
32
47
|
SimpleDeploy.logger.error "Environment '#{provided[:environment]}' does not exist."
|
33
48
|
exit 1
|
@@ -45,6 +60,23 @@ module SimpleDeploy
|
|
45
60
|
exit 1
|
46
61
|
end
|
47
62
|
|
63
|
+
private
|
64
|
+
|
65
|
+
def credential_env_vars_exist?
|
66
|
+
!!ENV['AWS_ACCESS_KEY_ID'] &&
|
67
|
+
!!ENV['AWS_SECRET_ACCESS_KEY'] &&
|
68
|
+
!!ENV['AWS_REGION']
|
69
|
+
end
|
70
|
+
|
71
|
+
def validate_credential_env_vars
|
72
|
+
unless credential_env_vars_exist?
|
73
|
+
msg = "The following environment variables must be set when using --read-from-env: "
|
74
|
+
msg << "AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION"
|
75
|
+
SimpleDeploy.logger.error msg
|
76
|
+
exit 1
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
48
80
|
end
|
49
81
|
|
50
82
|
end
|