lita-aws 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -3
- data/lib/lita-aws/base.rb +3 -0
- data/lib/lita-aws/version.rb +1 -1
- data/lib/lita/handlers/aws-profile.rb +2 -2
- data/lib/lita/handlers/aws.rb +3 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c75caabc9cd62d2a88b6696149d25e6b07c890d6
|
4
|
+
data.tar.gz: 2990a58e788f53f522e1aaadff8f3842c16b72f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43ce2007c124cbeb3c9c693db5cf91a81e3c1d81a5afd605f9031a8b3a0ddb716c732e3b83a37161dc86565d36091381c41b3d5208f59a7797ef760a4f88a908
|
7
|
+
data.tar.gz: 8429f13e8ec42c4ea4605ff480d49452b57ccf438fdc540a7ad6ded992e7ca5c27e18d36c4da38893e5529e49955e8c26f418faa3141b0aad7aa08d00353e5c8
|
data/README.md
CHANGED
@@ -59,7 +59,7 @@ Example:
|
|
59
59
|
(lita) aws account-id --profile 5fpro
|
60
60
|
```
|
61
61
|
|
62
|
-
|
62
|
+
# Execute as aws-cli
|
63
63
|
|
64
64
|
```
|
65
65
|
(lita) aws-cli ec2 describe-instances --page-size 10 --profile {profile_name}
|
@@ -74,9 +74,15 @@ aws ec2 describe-instances --page-size 10 --profile {profile_name}
|
|
74
74
|
and return json.
|
75
75
|
|
76
76
|
|
77
|
+
## Customized commands usage
|
78
|
+
|
79
|
+
- `lita-aws` provide customized commands for re-composing json data and formatting output to human-readable response. All of these customized command will use `aws ` as command prefix.
|
80
|
+
|
81
|
+
- Here is the exmaple to get cloudwatch data:
|
82
|
+
|
77
83
|
#### Get cloudwatch metric data.
|
78
84
|
|
79
|
-
-
|
85
|
+
- Get EC2 instance memory utilization from Cloudwatch.
|
80
86
|
|
81
87
|
```
|
82
88
|
(lita) aws ec2-memutil {Instance ID} --ago 2d --cal Average --period 300s --profile {profile_name}
|
@@ -105,7 +111,7 @@ options:
|
|
105
111
|
- period: `300s` means each data contains 300 seconds.
|
106
112
|
- cal: `Averages` means each period data will calculate its average as output value. To see more values http://docs.aws.amazon.com/cli/latest/reference/cloudwatch/get-metric-statistics.html and find `--statistics`.
|
107
113
|
|
108
|
-
|
114
|
+
## More customized commands
|
109
115
|
|
110
116
|
```
|
111
117
|
(lita) help aws
|
data/lib/lita-aws/base.rb
CHANGED
@@ -6,6 +6,8 @@ module LitaAws
|
|
6
6
|
|
7
7
|
def exec_cli(cmd, opts = {})
|
8
8
|
cmd_postfix = opts.to_a.map { |e| "--#{e.first} #{e.last}"}.join(' ')
|
9
|
+
cmd = cmd.gsub(';', '')
|
10
|
+
cmd_postfix = cmd_postfix.gsub(';', '')
|
9
11
|
`aws #{cmd} #{cmd_postfix}`
|
10
12
|
end
|
11
13
|
|
@@ -17,5 +19,6 @@ module LitaAws
|
|
17
19
|
# TODO: debug here
|
18
20
|
response.reply(text)
|
19
21
|
end
|
22
|
+
|
20
23
|
end
|
21
24
|
end
|
data/lib/lita-aws/version.rb
CHANGED
@@ -10,7 +10,7 @@ module Lita
|
|
10
10
|
results = profiles.inject({}) do |h, e|
|
11
11
|
h.merge(e => attrs.inject({}) do |hh, ee|
|
12
12
|
profile = e == 'default' ? '' : "--profile #{e}"
|
13
|
-
hh.merge(ee =>
|
13
|
+
hh.merge(ee => exec_cli("configure get #{ee} #{profile}").gsub("\n", ''))
|
14
14
|
end)
|
15
15
|
end
|
16
16
|
lines = results.to_a.inject([]) { |a, e| a + ["#{e[0]}: #{e[1].values.join(', ')}"] }
|
@@ -22,7 +22,7 @@ module Lita
|
|
22
22
|
name, @region, @aws_access_key_id, @aws_secret_access_key = response.matches.first
|
23
23
|
cmd_postfix = name == 'default' ? '' : "--profile #{name}"
|
24
24
|
['region', 'aws_access_key_id', 'aws_secret_access_key'].each do |attr|
|
25
|
-
|
25
|
+
exec_cli("configure set #{attr} #{instance_variable_get("@#{attr}")} #{cmd_postfix}")
|
26
26
|
end
|
27
27
|
response.reply("Set profile #{name}:\n region: #{@region}\n aws_access_key_id: #{@aws_access_key_id}\n aws_secret_access_key: #{@aws_secret_access_key}")
|
28
28
|
end
|
data/lib/lita/handlers/aws.rb
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
module Lita
|
2
2
|
module Handlers
|
3
3
|
class Aws < Handler
|
4
|
+
include ::LitaAws::Base
|
4
5
|
|
5
6
|
help = { 'aws [service] help' => 'Get command options help of [service].' }
|
6
7
|
route(/aws (.+) help$/, help: help) do |response|
|
7
8
|
service = response.matches[0][0]
|
8
|
-
text =
|
9
|
+
text = exec_cli("#{service} help|cat")
|
9
10
|
response.reply(text.gsub("\n\n", "\n"))
|
10
11
|
end
|
11
12
|
|
12
13
|
help = { 'aws-cli [command]' => 'Execute aws-cli.' }
|
13
14
|
route(/aws\-cli (.+)$/, help: help) do |response|
|
14
|
-
response.reply(
|
15
|
+
response.reply(exec_cli(response.matches.first[0]))
|
15
16
|
end
|
16
17
|
|
17
18
|
Lita.register_handler(self)
|