awful 0.0.42 → 0.0.43
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/cf +7 -0
- data/lib/awful.rb +5 -0
- data/lib/awful/cloudformation.rb +91 -0
- data/lib/awful/version.rb +1 -1
- data/lib/awful/vpc.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f24f7ddb09a17ac333dcb869ad40e3a8471cafb4
|
4
|
+
data.tar.gz: 6a67572ec4b2c85c718b26112196c951b5c5fdce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a9b0dfdc1d550a137c59c2b72d1e813b6b5e2fb1a80f2311627b5ea29a4d4d1cdd07a7e8076a23c7134aea33b7b99bb1481e0e75c8084f7f9e3cd68bba125ba
|
7
|
+
data.tar.gz: 594e68b56b07cc02dbf371e0788016d40b4ba6f94faed84fa65711c5add64958c025105334c8f535c380a54e482ad2e48b19790bae39df1f0693957701cc5f8e
|
data/bin/cf
ADDED
data/lib/awful.rb
CHANGED
@@ -83,6 +83,11 @@ module Awful
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
+
## returns contents of named file, or stdin if file = nil
|
87
|
+
def file_or_stdin(file)
|
88
|
+
(file and File.read(file)) || ((not $stdin.tty?) and $stdin.read)
|
89
|
+
end
|
90
|
+
|
86
91
|
## merge options with config from erb-parsed yaml stdin or file
|
87
92
|
def load_cfg(options = {}, file = nil)
|
88
93
|
Dotenv.overload(options[:env]) if options[:env]
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module Awful
|
2
|
+
|
3
|
+
class CloudFormation < Cli
|
4
|
+
|
5
|
+
no_commands do
|
6
|
+
def cf
|
7
|
+
@cf ||= Aws::CloudFormation::Client.new
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
desc 'ls [PATTERN]', 'list cloudformation stacks matching PATTERN'
|
12
|
+
method_option :long, aliases: '-l', default: false, desc: 'Long listing'
|
13
|
+
method_option :all, aliases: '-a', default: false, desc: 'Show all, including stacks in DELETE_COMPLETE'
|
14
|
+
def ls(name = /./)
|
15
|
+
stacks = cf.list_stacks.stack_summaries.select do |stack|
|
16
|
+
stack.stack_name.match(name)
|
17
|
+
end
|
18
|
+
|
19
|
+
## skip deleted stacks unless -a given
|
20
|
+
unless options[:all]
|
21
|
+
stacks = stacks.select { |stack| stack.stack_status != 'DELETE_COMPLETE' }
|
22
|
+
end
|
23
|
+
|
24
|
+
stacks.tap do |stacks|
|
25
|
+
if options[:long]
|
26
|
+
print_table stacks.map { |s| [s.stack_name, s.creation_time, s.stack_status, s.template_description] }
|
27
|
+
else
|
28
|
+
puts stacks.map(&:stack_name)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
desc 'dump NAME', 'describe stack named NAME'
|
34
|
+
def dump(name)
|
35
|
+
cf.describe_stacks(stack_name: name).stacks.tap do |stacks|
|
36
|
+
stacks.each do |stack|
|
37
|
+
puts YAML.dump(stringify_keys(stack.to_hash))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
desc 'template NAME', 'get template for stack named NAME'
|
43
|
+
def template(name)
|
44
|
+
cf.get_template(stack_name: name).template_body.tap do |template|
|
45
|
+
puts template
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
desc 'validate FILE', 'validate given template in FILE or stdin'
|
50
|
+
def validate(file = nil)
|
51
|
+
begin
|
52
|
+
cf.validate_template(template_body: file_or_stdin(file)).tap do |response|
|
53
|
+
puts YAML.dump(stringify_keys(response.to_hash))
|
54
|
+
end
|
55
|
+
rescue Aws::CloudFormation::Errors::ValidationError => e
|
56
|
+
e.tap { |err| puts err.message }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
desc 'create NAME', 'create stack with name NAME'
|
61
|
+
def create(name, file = nil)
|
62
|
+
cf.create_stack(stack_name: name, template_body: file_or_stdin(file)).tap do |response|
|
63
|
+
puts response.stack_id
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
desc 'update NAME', 'update stack with name NAME'
|
68
|
+
def update(name, file = nil)
|
69
|
+
begin
|
70
|
+
cf.update_stack(stack_name: name, template_body: file_or_stdin(file)).tap do |response|
|
71
|
+
puts response.stack_id
|
72
|
+
end
|
73
|
+
rescue Aws::CloudFormation::Errors::ValidationError => e
|
74
|
+
e.tap { |err| puts err.message }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
desc 'delete NAME', 'deletes stack with name NAME'
|
79
|
+
def delete(name)
|
80
|
+
cf.delete_stack(stack_name: name)
|
81
|
+
end
|
82
|
+
|
83
|
+
desc 'events NAME', 'show events for stack with name NAME'
|
84
|
+
def events(name)
|
85
|
+
cf.describe_stack_events(stack_name: name).stack_events.tap do |events|
|
86
|
+
print_table events.map { |e| [e.timestamp, e.resource_status, e.resource_type, e.logical_resource_id, e.resource_status_reason] }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
data/lib/awful/version.rb
CHANGED
data/lib/awful/vpc.rb
CHANGED
@@ -6,7 +6,7 @@ module Awful
|
|
6
6
|
method_option :long, aliases: '-l', default: false, desc: 'Long listing'
|
7
7
|
def ls(name = /./)
|
8
8
|
fields = options[:long] ?
|
9
|
-
->(v) { [v
|
9
|
+
->(v) { [tag_name(v), v.vpc_id, v.state, v.cidr_block] } :
|
10
10
|
->(v) { [v.vpc_id] }
|
11
11
|
ec2.describe_vpcs.map(&:vpcs).flatten.select do |vpc|
|
12
12
|
vpc.tags.any? { |tag| tag.value.match(name) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.43
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ric Lister
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -87,6 +87,7 @@ executables:
|
|
87
87
|
- ami
|
88
88
|
- asg
|
89
89
|
- asgn
|
90
|
+
- cf
|
90
91
|
- dp
|
91
92
|
- dyn
|
92
93
|
- dynstr
|
@@ -114,6 +115,7 @@ files:
|
|
114
115
|
- bin/ami
|
115
116
|
- bin/asg
|
116
117
|
- bin/asgn
|
118
|
+
- bin/cf
|
117
119
|
- bin/dp
|
118
120
|
- bin/dyn
|
119
121
|
- bin/dynstr
|
@@ -133,6 +135,7 @@ files:
|
|
133
135
|
- lib/awful/ami.rb
|
134
136
|
- lib/awful/auto_scaling.rb
|
135
137
|
- lib/awful/auto_scaling_notifications.rb
|
138
|
+
- lib/awful/cloudformation.rb
|
136
139
|
- lib/awful/datapipeline.rb
|
137
140
|
- lib/awful/dynamodb.rb
|
138
141
|
- lib/awful/dynamodb_streams.rb
|