vaws 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/lib/vaws/aws/alb_describer.rb +1 -1
- data/lib/vaws/aws/ec2_describer.rb +8 -2
- data/lib/vaws/aws/ecs_describer.rb +1 -1
- data/lib/vaws/aws/route53_describer.rb +1 -1
- data/lib/vaws/aws/security_group_describer.rb +42 -0
- data/lib/vaws/aws/subnet_describer.rb +1 -1
- data/lib/vaws/aws/vpc_describer.rb +1 -1
- data/lib/vaws/handlers/describer.rb +13 -0
- data/lib/vaws/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43597882b166d87a1da3e4a98bd058a62445d9b8c8403a502964f631d1ca52fe
|
4
|
+
data.tar.gz: c6d9932b12cb31dc9e8c4989d526793aa9dff2041f3c1c576dfb15918ecff28b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 206e8689f29f63b88cdc1d4524919d98f1ad18d80f30c75e2c083e0afa3112f6dc7a0b3de56245b0e9863267e703f3ab2d2c52741748a10f1163d56cd1c17601
|
7
|
+
data.tar.gz: 1e0b1b1e9a131bcecef8118d8ee54279c22ea81ef5b4ed6002c5b94fcc1a2f236b8a327965f6d21100f171add490c9f1f4fb26ffaf19247ab9d33e01ff77edc1
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -26,7 +26,7 @@ module Vaws
|
|
26
26
|
|
27
27
|
rows << [name, type, scheme, vpc, arn, dns]
|
28
28
|
end
|
29
|
-
@term_table = Terminal::Table.new :headings => ['Name', 'Type', 'Scheme', 'Vpc', 'Short_Arn', 'Dns'], :rows => rows
|
29
|
+
@term_table = Terminal::Table.new :headings => ['Name', 'Type', 'Scheme', 'Vpc', 'Short_Arn', 'Dns'], :rows => rows.sort
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -14,21 +14,27 @@ module Vaws
|
|
14
14
|
|
15
15
|
def set_basic_info
|
16
16
|
rows = []
|
17
|
+
sg_ids = ""
|
17
18
|
ec2_reservations = @ec2_client.describe_instances.reservations
|
18
19
|
ec2_reservations.each do |ec2_rsvn|
|
19
20
|
ec2_rsvn.instances.each do |ec2_instance|
|
20
21
|
ec2_instance.tags.each do |tag|
|
21
22
|
@tag = tag.value if tag.key == 'Name'
|
22
23
|
end
|
24
|
+
ec2_instance.security_groups.each_with_index do |sg, index|
|
25
|
+
sg_ids << "#{sg.group_id}, "
|
26
|
+
sg_ids = sg_ids.gsub(/, $/, '') if index == ec2_instance.security_groups.size - 1
|
27
|
+
end
|
23
28
|
instance_id = ec2_instance.instance_id
|
24
29
|
instance_type = ec2_instance.instance_type
|
25
30
|
public_ip = ec2_instance.public_ip_address
|
26
31
|
private_ip = ec2_instance.private_ip_address
|
27
32
|
state_name = ec2_instance.state.name
|
28
|
-
rows << [@tag, instance_id, instance_type, public_ip, private_ip, state_name]
|
33
|
+
rows << [@tag, instance_id, instance_type, public_ip, private_ip, state_name, sg_ids]
|
34
|
+
sg_ids = ''
|
29
35
|
end
|
30
36
|
end
|
31
|
-
@term_table = Terminal::Table.new :headings => ['Name', 'Id', 'Type', 'GlobalIp', 'PrivateIp', 'Status'], :rows => rows
|
37
|
+
@term_table = Terminal::Table.new :headings => ['Name', 'Id', 'Type', 'GlobalIp', 'PrivateIp', 'Status','SecurityGroupId'], :rows => rows.sort
|
32
38
|
end
|
33
39
|
end
|
34
40
|
end
|
@@ -31,7 +31,7 @@ module Vaws
|
|
31
31
|
rows << [cluster_name, cluster_services, active_services_count, running_tasks_count, pending_tasks_count]
|
32
32
|
end
|
33
33
|
|
34
|
-
@term_table = Terminal::Table.new :headings => ['ClusterName', 'Services', 'ActService', 'RunTask', 'PenTask'], :rows => rows
|
34
|
+
@term_table = Terminal::Table.new :headings => ['ClusterName', 'Services', 'ActService', 'RunTask', 'PenTask'], :rows => rows.sort
|
35
35
|
end
|
36
36
|
|
37
37
|
private
|
@@ -33,7 +33,7 @@ module Vaws
|
|
33
33
|
record_alias = ''
|
34
34
|
end
|
35
35
|
end
|
36
|
-
@term_table = Terminal::Table.new :headings => ['Fqdn', 'Type', 'Value', 'Ttl', 'Alias'], :rows => rows
|
36
|
+
@term_table = Terminal::Table.new :headings => ['Fqdn', 'Type', 'Value', 'Ttl', 'Alias'], :rows => rows.sort
|
37
37
|
end
|
38
38
|
|
39
39
|
private
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'aws-sdk-ec2'
|
2
|
+
require 'vaws/aws/describer'
|
3
|
+
|
4
|
+
module Vaws
|
5
|
+
module Aws
|
6
|
+
class SecurityGroupDescriber < Describer
|
7
|
+
attr_reader :term_table
|
8
|
+
|
9
|
+
def initialize(is_in, is_out)
|
10
|
+
@ec2_client = ::Aws::EC2::Client.new
|
11
|
+
@term_table = ''
|
12
|
+
@is_in = is_in
|
13
|
+
@is_out = is_out
|
14
|
+
end
|
15
|
+
|
16
|
+
def set_basic_info
|
17
|
+
rows = []
|
18
|
+
resp_sg = @ec2_client.describe_security_groups
|
19
|
+
|
20
|
+
resp_sg.security_groups.each do |security_group|
|
21
|
+
group_name = security_group.group_name
|
22
|
+
group_id = security_group.group_id
|
23
|
+
|
24
|
+
security_group.ip_permissions.each do |ip_permission|
|
25
|
+
ip_permission.from_port.nil? ? from_port = "ALL" : from_port = ip_permission.from_port.to_s
|
26
|
+
ip_permission.ip_protocol == "-1" ? ip_protocol = "ALL" : ip_protocol = ip_permission.ip_protocol
|
27
|
+
|
28
|
+
ip_permission.user_id_group_pairs.each do |user_id_group_pair|
|
29
|
+
cidr_ip = user_id_group_pair.group_id
|
30
|
+
rows << [group_name, group_id, from_port, cidr_ip, ip_protocol]
|
31
|
+
end
|
32
|
+
ip_permission.ip_ranges.each do |ip_range|
|
33
|
+
cidr_ip = ip_range.cidr_ip
|
34
|
+
rows << [group_name, group_id, from_port, cidr_ip, ip_protocol]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
@term_table = Terminal::Table.new :headings => ['Name', 'Id', 'AllowPort', 'AllowNetwork', 'AllowProtocol'], :rows => rows.sort
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -22,7 +22,7 @@ module Vaws
|
|
22
22
|
|
23
23
|
rows << [cidr, subnet_id, az, vpc_id]
|
24
24
|
end
|
25
|
-
@term_table = Terminal::Table.new :headings => ['Cidr', 'SubnetId', 'Az', 'VpcId'], :rows => rows
|
25
|
+
@term_table = Terminal::Table.new :headings => ['Cidr', 'SubnetId', 'Az', 'VpcId'], :rows => rows.sort
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -27,7 +27,7 @@ module Vaws
|
|
27
27
|
|
28
28
|
rows << [vpc_id, cidr, tags]
|
29
29
|
end
|
30
|
-
@term_table = Terminal::Table.new :headings => ['VpcId', 'Cidr', 'Tags'], :rows => rows
|
30
|
+
@term_table = Terminal::Table.new :headings => ['VpcId', 'Cidr', 'Tags'], :rows => rows.sort
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -6,6 +6,7 @@ require 'vaws/aws/subnet_describer'
|
|
6
6
|
require 'vaws/aws/vpc_describer'
|
7
7
|
require 'vaws/aws/ecs_describer'
|
8
8
|
require 'vaws/aws/route53_describer'
|
9
|
+
require 'vaws/aws/security_group_describer'
|
9
10
|
|
10
11
|
module Vaws
|
11
12
|
module Handlers
|
@@ -57,6 +58,18 @@ module Vaws
|
|
57
58
|
r53_desc.set_basic_info
|
58
59
|
puts r53_desc.term_table
|
59
60
|
end
|
61
|
+
|
62
|
+
desc 'sg', 'View Security Group'
|
63
|
+
option :in, :aliases => 'i', :type => :boolean, banner: "Inbound security group"
|
64
|
+
option :out, :aliases => 'o', :type => :boolean, banner: "Outbound security group"
|
65
|
+
|
66
|
+
def sg
|
67
|
+
is_in = options[:in] if options[:in]
|
68
|
+
is_out = options[:out] if options[:out]
|
69
|
+
sg_desc = Vaws::Aws::SecurityGroupDescriber.new(is_in, is_out)
|
70
|
+
sg_desc.set_basic_info
|
71
|
+
puts sg_desc.term_table
|
72
|
+
end
|
60
73
|
end
|
61
74
|
end
|
62
75
|
end
|
data/lib/vaws/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vaws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shota Ito
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -163,6 +163,7 @@ files:
|
|
163
163
|
- lib/vaws/aws/ec2_describer.rb
|
164
164
|
- lib/vaws/aws/ecs_describer.rb
|
165
165
|
- lib/vaws/aws/route53_describer.rb
|
166
|
+
- lib/vaws/aws/security_group_describer.rb
|
166
167
|
- lib/vaws/aws/subnet_describer.rb
|
167
168
|
- lib/vaws/aws/vpc_describer.rb
|
168
169
|
- lib/vaws/handlers/describer.rb
|