awful 0.0.26 → 0.0.27

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: 4eb18297260b483c8bb4a52b095befe53321588f
4
- data.tar.gz: 6e05e371996156f1773ec936b171a8a56de18a46
3
+ metadata.gz: 90734ed93f491b0260e20574e85270ede9a29983
4
+ data.tar.gz: 854a595c1d2d1bfe2be6ad69f169ebfe412060dc
5
5
  SHA512:
6
- metadata.gz: e1848acf9ddfe9c8ea93ed2dcd88354b7d08bb747499d458fa74b29b177ad5a2b26c1e935a9a9c7ea4738df98c0fe0d23005b78e35f61c71b68e1990f3b008b1
7
- data.tar.gz: b81e4c98aac0b753a8ad08166510d5514a61828bd1169116bc89606c49eb160c634bd0a3b970b1fc9c75387bb24ca4bde4b8cc94b3cb7c8539b3e2c302d9822d
6
+ metadata.gz: 796edf706246b369a0e0dcfb114e1cc938a458f7f58ae29f077336fd72229b98fba142d843e8096c6698502a6db8c58fb3dc6973da825345b5bf9ec999c38b05
7
+ data.tar.gz: 48d838269959f07d7e37fc348f04b989c2efe5bf01faaed7d84875a2ef6b5bef03c739be78afcd7224575e004d8421adfdb9bd3eb3acd7dd471a6b87fe4a980f
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Awful
2
2
 
3
- TODO: Write a gem description
3
+ The worst AWS command-line tool in the world.
4
4
 
5
5
  ## Installation
6
6
 
@@ -20,12 +20,119 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- TODO: Write usage instructions here
23
+ ```
24
+ $ for x in `ls bin`; do bin/$x help; done
25
+
26
+ Commands:
27
+ ami delete NAME # delete AMI
28
+ ami help [COMMAND] # Describe available commands or one specific command
29
+ ami last NAME # get last AMI matching NAME
30
+ ami ls [PATTERN] # list AMIs
31
+ ami tags ID [KEY=VALUE] # tag an image, or print tags
32
+
33
+ Options:
34
+ -e, [--env=ENV] # Load environment variables from file
35
+ -o, [--owners=OWNERS] # List images with this owner
36
+ # Default: self
37
+
38
+ Commands:
39
+ asg create [FILE] # create a new auto-scaling group
40
+ asg delete NAME # delete autoscaling group
41
+ asg dump NAME # dump existing autoscaling group as yaml
42
+ asg help [COMMAND] # Describe available commands or one specific command
43
+ asg instances # list instance IDs for instances in groups matching NAME
44
+ asg ips NAME # list IPs for instances in groups matching NAME
45
+ asg ls [PATTERN] # list autoscaling groups with name matching PATTERN
46
+ asg ssh NAME [ARGS] # ssh to an instance for this autoscaling group
47
+ asg stop NAME [NUMBER] # stop NUMBER instances in group NAME
48
+ asg terminate NAME [NUMBER] # terminate NUMBER instances in group NAME
49
+ asg update NAME [FILE] # update existing auto-scaling group
50
+
51
+ Options:
52
+ -e, [--env=ENV] # Load environment variables from file
53
+
54
+ Commands:
55
+ ec2 addresses # list elastic IP addresses
56
+ ec2 allocate # allocate a new elastic IP address
57
+ ec2 associate NAME IP # associate a public ip with an instance
58
+ ec2 create NAME # run new EC2 instance
59
+ ec2 delete NAME # terminate a running instance
60
+ ec2 dns NAME # get public DNS for named instance
61
+ ec2 dump NAME # dump EC2 instance with id or tag NAME as yaml
62
+ ec2 help [COMMAND] # Describe available commands or one specific command
63
+ ec2 ls [PATTERN] # list EC2 instances [with id or tags matching PATTERN]
64
+ ec2 start NAME # start a running instance
65
+ ec2 stop NAME # stop a running instance
66
+ ec2 update NAME # update an existing instance
67
+
68
+ Options:
69
+ -e, [--env=ENV] # Load environment variables from file
70
+
71
+ Commands:
72
+ elb create NAME # create new load-balancer
73
+ elb delete NAME # delete load-balancer
74
+ elb dns NAME # get DNS name for load-balancers matching NAME
75
+ elb dump NAME # dump VPC with id or tag NAME as yaml
76
+ elb health_check NAME # set health-check
77
+ elb help [COMMAND] # Describe available commands or one specific command
78
+ elb instances NAME # list instances and states for elb NAME
79
+ elb ls [PATTERN] # list vpcs [with any tags matching PATTERN]
80
+
81
+ Options:
82
+ -e, [--env=ENV] # Load environment variables from file
83
+
84
+ Commands:
85
+ lc clean NAME [NUM] # delete oldest NUM launch configs matching NAME
86
+ lc create NAME [FILE] # create a new launch configuration
87
+ lc delete NAME # delete launch configuration
88
+ lc dump NAME # dump existing launch_configuration as yaml
89
+ lc help [COMMAND] # Describe available commands or one specific command
90
+ lc latest # latest
91
+ lc ls [PATTERN] # list launch configs with name matching PATTERN
24
92
 
25
- ## Contributing
93
+ Options:
94
+ -e, [--env=ENV] # Load environment variables from file
26
95
 
27
- 1. Fork it ( https://github.com/[my-github-username]/awful/fork )
28
- 2. Create your feature branch (`git checkout -b my-new-feature`)
29
- 3. Commit your changes (`git commit -am 'Add some feature'`)
30
- 4. Push to the branch (`git push origin my-new-feature`)
31
- 5. Create a new Pull Request
96
+ Commands:
97
+ rds dns NAME # show DNS name and port for DB instance NAME
98
+ rds dump NAME # dump DB instance matching NAME
99
+ rds help [COMMAND] # Describe available commands or one specific command
100
+ rds ls [NAME] # list DB instances matching NAME
101
+
102
+ Options:
103
+ -e, [--env=ENV] # Load environment variables from file
104
+
105
+ Commands:
106
+ route dump NAME # dump route with id or tag NAME as yaml
107
+ route help [COMMAND] # Describe available commands or one specific command
108
+ route ls [PATTERN] # list routes
109
+
110
+ Options:
111
+ -e, [--env=ENV] # Load environment variables from file
112
+
113
+ Commands:
114
+ sg dump NAME # dump security group with NAME as yaml
115
+ sg help [COMMAND] # Describe available commands or one specific command
116
+ sg ls [NAME] # list security groups [matching NAME]
117
+
118
+ Options:
119
+ -e, [--env=ENV] # Load environment variables from file
120
+
121
+ Commands:
122
+ subnet create NAME # create subnet
123
+ subnet delete NAME # delete subnet with name or ID
124
+ subnet dump NAME # dump subnet with id or tag NAME as yaml
125
+ subnet help [COMMAND] # Describe available commands or one specific command
126
+ subnet ls [PATTERN] # list subnets [with any tags matching PATTERN]
127
+
128
+ Options:
129
+ -e, [--env=ENV] # Load environment variables from file
130
+
131
+ Commands:
132
+ vpc dump NAME # dump VPC with id or tag NAME as yaml
133
+ vpc help [COMMAND] # Describe available commands or one specific command
134
+ vpc ls [PATTERN] # list vpcs [with any tags matching PATTERN]
135
+
136
+ Options:
137
+ -e, [--env=ENV] # Load environment variables from file
138
+ ```
data/bin/dyn ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby
2
+ #-*- mode: ruby; -*-
3
+
4
+ require 'awful'
5
+ require 'awful/dynamodb'
6
+
7
+ Awful::DynamoDB.start(ARGV)
data/lib/awful.rb CHANGED
@@ -32,6 +32,10 @@ module Awful
32
32
  @datapipeline ||= Aws::DataPipeline::Client.new
33
33
  end
34
34
 
35
+ def dynamodb
36
+ @dynamodb ||= Aws::DynamoDB::Client.new
37
+ end
38
+
35
39
  def symbolize_keys(thing)
36
40
  if thing.is_a?(Hash)
37
41
  Hash[ thing.map { |k,v| [ k.to_sym, symbolize_keys(v) ] } ]
@@ -52,6 +56,7 @@ module Awful
52
56
  end
53
57
  end
54
58
 
59
+ ## merge options with config from erb-parsed yaml stdin or file
55
60
  def load_cfg(options = {}, file = nil)
56
61
  Dotenv.overload(options[:env]) if options[:env]
57
62
  src = (file and File.read(file)) || ((not $stdin.tty?) and $stdin.read)
@@ -59,6 +64,7 @@ module Awful
59
64
  symbolize_keys(cfg).merge(symbolize_keys(options.reject{ |_,v| v.nil? }))
60
65
  end
61
66
 
67
+ ## return a copy of hash, but with only listed keys
62
68
  def only_keys_matching(hash, keylist)
63
69
  hash.select do |key,_|
64
70
  keylist.include?(key)
@@ -0,0 +1,76 @@
1
+ module Awful
2
+
3
+ class DynamoDB < Cli
4
+
5
+ desc 'ls [PATTERN]', 'list dynamodb tables [matching PATTERN]'
6
+ method_option :long, aliases: '-l', default: false, desc: 'Long listing'
7
+ def ls(name = /./)
8
+ tables = dynamodb.list_tables.table_names.select do |table|
9
+ table.match(name)
10
+ end
11
+
12
+ if options[:long]
13
+ tables.map do |table|
14
+ dynamodb.describe_table(table_name: table).table
15
+ end.tap do |list|
16
+ print_table list.map { |t| [ t.table_name, t.table_status, t.item_count, t.table_size_bytes, t.creation_date_time ] }
17
+ end
18
+ else
19
+ tables.tap { |t| puts t }
20
+ end
21
+ end
22
+
23
+ desc 'dump NAME', 'dump table with name'
24
+ def dump(name)
25
+ dynamodb.describe_table(table_name: name).table.tap do |table|
26
+ puts YAML.dump(stringify_keys(table.to_hash))
27
+ end
28
+ end
29
+
30
+ desc 'scan NAME', 'scan table with NAME'
31
+ def scan(name, start_key = nil)
32
+ r = dynamodb.scan(table_name: name, exclusive_start_key: start_key) #.items.tap{ |x| p x.count }.tap do |table|
33
+ puts r.items.map { |item| JSON.generate(item) }.join("\n")
34
+ if r.last_evaluated_key # recurse if more data to get
35
+ scan(name, r.last_evaluated_key)
36
+ end
37
+ end
38
+
39
+ desc 'create_table NAME', 'create table with NAME'
40
+ def create_table(name, file = nil)
41
+ opt = load_cfg(options, file)
42
+ params = only_keys_matching(opt, %i[attribute_definitions key_schema])
43
+ params[:table_name] = name
44
+ params[:provisioned_throughput] = only_keys_matching(opt[:provisioned_throughput], %i[read_capacity_units write_capacity_units])
45
+ params[:local_secondary_indexes] = opt[:local_secondary_indexes].map do |lsi|
46
+ only_keys_matching(lsi, %i[index_name key_schema projection])
47
+ end
48
+ params[:global_secondary_indexes] = opt[:global_secondary_indexes].map do |gsi|
49
+ only_keys_matching(gsi, %i[index_name key_schema projection]).tap do |g|
50
+ if gsi[:provisioned_throughput]
51
+ g[:provisioned_throughput] = only_keys_matching(gsi[:provisioned_throughput], %i[read_capacity_units write_capacity_units])
52
+ end
53
+ end
54
+ end
55
+ dynamodb.create_table(params)
56
+ end
57
+
58
+ desc 'delete NAME', 'delete table with NAME'
59
+ def delete_table(name)
60
+ dynamodb.delete_table(table_name: name)
61
+ end
62
+
63
+ desc 'put_items NAME', 'puts json items into the table with NAME'
64
+ def put_items(name, file = nil)
65
+ io = (file and File.open(file)) || ((not $stdin.tty?) and $stdin)
66
+ count = 0
67
+ io.each_line do |line|
68
+ dynamodb.put_item(table_name: name, item: JSON.parse(line))
69
+ count += 1
70
+ end
71
+ count.tap { |c| puts "put #{c} items" }
72
+ end
73
+
74
+ end
75
+
76
+ end
data/lib/awful/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Awful
2
- VERSION = "0.0.26"
2
+ VERSION = "0.0.27"
3
3
  end
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.26
4
+ version: 0.0.27
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-07-27 00:00:00.000000000 Z
11
+ date: 2015-08-03 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
  - dp
90
+ - dyn
90
91
  - ec2
91
92
  - elb
92
93
  - lc
@@ -107,6 +108,7 @@ files:
107
108
  - bin/ami
108
109
  - bin/asg
109
110
  - bin/dp
111
+ - bin/dyn
110
112
  - bin/ec2
111
113
  - bin/elb
112
114
  - bin/lc
@@ -119,6 +121,7 @@ files:
119
121
  - lib/awful/ami.rb
120
122
  - lib/awful/auto_scaling.rb
121
123
  - lib/awful/datapipeline.rb
124
+ - lib/awful/dynamodb.rb
122
125
  - lib/awful/ec2.rb
123
126
  - lib/awful/elb.rb
124
127
  - lib/awful/launch_config.rb