vaws 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d1cfaef05b4b989fddfd11ba0d2424fd43f26d94d26320462364c9a57c99be67
4
- data.tar.gz: 2d66fce672b4957c00d89573446be245b111a060a39e465649c7e0dd9b0d2718
3
+ metadata.gz: 1436a9e8759ca8ea7032a05550d72d21047a7b893ce0ba1a8df23530fe0c9d1a
4
+ data.tar.gz: 3adeb052af24a2646be4369c2ec103af27e46e945474c5da077ba833faab7941
5
5
  SHA512:
6
- metadata.gz: 9830009d7ea188f8a73cb31756e02c5877c32dca90085b5fd234120419770f993227d3fbde9fda9f1ef8c3a0001f321fe945a5cec3b2b40c1de451befd42f183
7
- data.tar.gz: 8e2c40b1fe8eda1928cb4b4ac168d1de0e0a245c1ad8e53ff3521753bbdf37b27d08e5bd89e0165589b50ba778a6ac3c284faa8416d879c4d9286538651cec05
6
+ metadata.gz: 2c64a36363baedb0bc3966447862183ca6ace97ef86a00bfcf6f22fa1b05df57dafe3c82eba49a2c4c0344d644f692140dbf6b725c663c3786b4af0a9ad8c0f1
7
+ data.tar.gz: 6e8ae8f04ffdc5f1d855a1ffed51e5d3b72cb83188795d83cfc9941deaa94d00596b1ecd26d6e5ca82d2ee2dab720cb28e755c7c50bb06e37f22b4de29ecbd37
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vaws (0.7.0)
4
+ vaws (0.8.0)
5
5
  aws-sdk-acm
6
6
  aws-sdk-ec2
7
7
  aws-sdk-ecs
@@ -12,14 +12,22 @@ module Vaws
12
12
  end
13
13
 
14
14
  def set_basic_info
15
- rows = []
16
- certs = @acm_client.list_certificates({ max_items: 1000 })
15
+ rows = []
16
+ next_token = nil
17
17
 
18
- certs.certificate_summary_list.each do |cert|
19
- cert_arn = cert.certificate_arn
20
- cert_domain = cert.domain_name
21
- rows << [cert_domain, cert_arn]
22
- end
18
+ begin
19
+ param_args = {
20
+ max_items: 1000
21
+ }
22
+ param_args[:next_token] = next_token if next_token
23
+ resp = @acm_client.list_certificates(param_args)
24
+ resp.certificate_summary_list.each do |cert|
25
+ cert_arn = cert.certificate_arn
26
+ cert_domain = cert.domain_name
27
+ rows << [cert_domain, cert_arn]
28
+ end
29
+ next_token = resp.next_token
30
+ end while next_token
23
31
  @term_table = Terminal::Table.new :headings => ['Domain', 'Arn'], :rows => rows.sort
24
32
  end
25
33
  end
@@ -12,20 +12,28 @@ module Vaws
12
12
  end
13
13
 
14
14
  def set_basic_info
15
- rows = []
16
- albs = @alb_client.describe_load_balancers
15
+ rows = []
16
+ next_marker = nil
17
17
 
18
- # https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/ElasticLoadBalancingV2/Client.html#describe_load_balancers-instance_method
19
- albs.load_balancers.each do |alb|
20
- arn = alb.load_balancer_arn.sub!(/arn:aws:elasticloadbalancing:ap-northeast-1:163714994724:loadbalancer\/...\//, '')
21
- dns = alb.dns_name
22
- name = alb.load_balancer_name
23
- scheme = alb.scheme
24
- vpc = alb.vpc_id
25
- type = alb.type
18
+ begin
19
+ param_args = {
20
+ page_size: 400
21
+ }
22
+ param_args[:marker] = next_marker if next_marker
23
+ resp = @alb_client.describe_load_balancers(param_args)
26
24
 
27
- rows << [name, type, scheme, vpc, arn, dns]
28
- end
25
+ # https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/ElasticLoadBalancingV2/Client.html#describe_load_balancers-instance_method
26
+ resp.load_balancers.each do |alb|
27
+ arn = alb.load_balancer_arn.sub!(/arn:aws:elasticloadbalancing:ap-northeast-1:163714994724:loadbalancer\/...\//, '')
28
+ dns = alb.dns_name
29
+ name = alb.load_balancer_name
30
+ scheme = alb.scheme
31
+ vpc = alb.vpc_id
32
+ type = alb.type
33
+ rows << [name, type, scheme, vpc, arn, dns]
34
+ next_marker = resp.next_marker
35
+ end
36
+ end while next_marker
29
37
  @term_table = Terminal::Table.new :headings => ['Name', 'Type', 'Scheme', 'Vpc', 'Short_Arn', 'Dns'], :rows => rows.sort
30
38
  end
31
39
  end
@@ -13,28 +13,37 @@ module Vaws
13
13
  end
14
14
 
15
15
  def set_basic_info
16
- rows = []
17
- sg_ids = ""
18
- ec2_reservations = @ec2_client.describe_instances.reservations
19
- ec2_reservations.each do |ec2_rsvn|
20
- ec2_rsvn.instances.each do |ec2_instance|
21
- ec2_instance.tags.each do |tag|
22
- @tag = tag.value if tag.key == 'Name'
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
16
+ rows = []
17
+ next_token = nil
18
+ sg_ids = ""
19
+
20
+ begin
21
+ param_args = {
22
+ max_results: 1000
23
+ }
24
+ param_args[:next_token] = next_token if next_token
25
+ resp = @ec2_client.describe_instances(param_args)
26
+ resp[:reservations].each do |reservation|
27
+ reservation.instances.each do |instance|
28
+ instance.tags.each do |tag|
29
+ @tag = tag.value if tag.key == 'Name'
30
+ end
31
+ instance.security_groups.each_with_index do |sg, index|
32
+ sg_ids << "#{sg.group_id}, "
33
+ sg_ids = sg_ids.gsub(/, $/, '') if index == instance.security_groups.size - 1
34
+ end
35
+ instance_id = instance.instance_id
36
+ instance_type = instance.instance_type
37
+ public_ip = instance.public_ip_address
38
+ private_ip = instance.private_ip_address
39
+ state_name = instance.state.name
40
+ rows << [@tag, instance_id, instance_type, public_ip, private_ip, state_name, sg_ids]
41
+ sg_ids = ''
27
42
  end
28
- instance_id = ec2_instance.instance_id
29
- instance_type = ec2_instance.instance_type
30
- public_ip = ec2_instance.public_ip_address
31
- private_ip = ec2_instance.private_ip_address
32
- state_name = ec2_instance.state.name
33
- rows << [@tag, instance_id, instance_type, public_ip, private_ip, state_name, sg_ids]
34
- sg_ids = ''
35
43
  end
36
- end
37
- @term_table = Terminal::Table.new :headings => ['Name', 'Id', 'Type', 'GlobalIp', 'PrivateIp', 'Status','SecurityGroupId'], :rows => rows.sort
44
+ next_token = resp.next_token
45
+ end while next_token
46
+ @term_table = Terminal::Table.new :headings => ['Name', 'Id', 'Type', 'GlobalIp', 'PrivateIp', 'Status', 'SecurityGroupId'], :rows => rows.sort
38
47
  end
39
48
  end
40
49
  end
@@ -14,14 +14,13 @@ module Vaws
14
14
  end
15
15
 
16
16
  def set_basic_info
17
- get_cluster_arns
18
-
19
17
  rows = []
20
- @cluster_arns.each do |cluster_arn|
18
+
19
+ cluster_arns.each do |cluster_arn|
21
20
  cluster_name = cluster_arn.gsub(/arn:aws:ecs:#{ENV['AWS_DEFAULT_REGION']}:[0-9]*:cluster\//, "")
22
21
  @cluster_info.store("#{cluster_name}", {})
23
22
  cluster_name = "#{cluster_name}"
24
- cluster_services = get_service_names(cluster_arn)
23
+ cluster_services = service_names(cluster_arn)
25
24
 
26
25
  ecs_cluster = @ecs_client.describe_clusters({ clusters: ["#{cluster_arn}"] }).clusters
27
26
  running_tasks_count = ecs_cluster[0].running_tasks_count
@@ -36,15 +35,22 @@ module Vaws
36
35
 
37
36
  private
38
37
 
39
- def get_cluster_arns
40
- @cluster_arns = @ecs_client.list_clusters[:cluster_arns]
38
+ def cluster_arns
39
+ param_args = {
40
+ max_results: 100
41
+ }
42
+ @ecs_client.list_clusters(param_args)[:cluster_arns]
41
43
  end
42
44
 
43
- def get_service_arns(cluster_arn)
44
- @ecs_client.list_services({ cluster: "#{cluster_arn}" })[:service_arns]
45
+ def service_arns(cluster_arn)
46
+ param_args = {
47
+ cluster: cluster_arn,
48
+ max_results: 1
49
+ }
50
+ @ecs_client.list_services(param_args)[:service_arns]
45
51
  end
46
52
 
47
- def get_service_names(cluster_arn)
53
+ def service_names(cluster_arn)
48
54
  service_ary = @ecs_client.list_services({ cluster: "#{cluster_arn}", max_results: 100 })[:service_arns].sort
49
55
  service_ary.join("\n").gsub(/arn:aws:ecs:#{ENV['AWS_DEFAULT_REGION']}:[0-9]*:service\//, "")
50
56
  end
@@ -14,33 +14,70 @@ module Vaws
14
14
 
15
15
  def set_basic_info
16
16
  rows = []
17
- get_hosted_zone
18
-
19
- @r53_hosted_zone_ids.each do |zone_id|
20
- record_values = ''
21
- records = @r53_client.list_resource_record_sets({ hosted_zone_id: "#{zone_id}", max_items: 1000 })
22
- records.resource_record_sets.each do |record_sets|
23
- record_name = record_sets.name
24
- record_type = record_sets.type
25
- record_ttl = record_sets.ttl
26
- if record_sets.alias_target.nil?
27
- record_sets.resource_records.each do |record|
17
+
18
+ zone_id = selected_zone_id
19
+ record_values = ''
20
+ next_record_identifier = nil
21
+ next_record_name = nil
22
+ next_record_type = nil
23
+
24
+ begin
25
+ param_args = {
26
+ hosted_zone_id: zone_id,
27
+ max_items: 200
28
+ }
29
+ param_args[:start_record_identifier] = next_record_identifier if next_record_identifier
30
+ param_args[:start_record_name] = next_record_name if next_record_name
31
+ param_args[:start_record_type] = next_record_type if next_record_type
32
+ resp = @r53_client.list_resource_record_sets(param_args)
33
+
34
+ resp.resource_record_sets.each do |record_set|
35
+ name = record_set.name
36
+ type = record_set.type
37
+ ttl = record_set.ttl
38
+ if record_set.alias_target.nil?
39
+ record_set.resource_records.each do |record|
28
40
  record_values << "#{record.value.to_s}\n"
29
41
  end
30
42
  else
31
- record_values = record_sets.alias_target.dns_name
43
+ record_values = record_set.alias_target.dns_name
32
44
  end
33
- rows << [record_name, record_type, record_values, record_ttl]
45
+ rows << [name, type, record_values, ttl]
34
46
  record_values = ''
35
47
  end
36
- end
48
+ next_record_identifier = resp.next_record_identifier
49
+ next_record_name = resp.next_record_name
50
+ next_record_type = resp.next_record_type
51
+ end while next_record_identifier
37
52
  @term_table = Terminal::Table.new :headings => ['Fqdn', 'Type', 'Value', 'Ttl'], :rows => rows.sort
38
53
  end
39
54
 
55
+
40
56
  private
41
57
 
42
- def get_hosted_zone
43
- @r53_client.list_hosted_zones({ max_items: 100 }).hosted_zones.each do |zone|
58
+ def selected_zone_id
59
+ puts "# ZONE LIST"
60
+ zones = hosted_zones
61
+ zones.each_with_index do |zone, cnt|
62
+ puts "#{cnt}:#{zone[:name]}"
63
+ end
64
+ print "zone number: "
65
+ input = STDIN.gets
66
+ begin
67
+ raise unless /[0-9].*/ =~ input
68
+ input_zone_number = input.to_i
69
+ zones[input_zone_number][:id] if zones[input_zone_number][:id]
70
+ rescue
71
+ puts "Not found zone"
72
+ return
73
+ end
74
+ end
75
+
76
+ def hosted_zones
77
+ param_args = {
78
+ max_items: 100
79
+ }
80
+ @r53_client.list_hosted_zones(param_args).hosted_zones.each do |zone|
44
81
  @r53_hosted_zone_ids << zone.id
45
82
  end
46
83
  end
@@ -13,33 +13,42 @@ module Vaws
13
13
  end
14
14
 
15
15
  def set_basic_info
16
- rows = []
17
- resp_sg = @ec2_client.describe_security_groups
18
- resp_sg.security_groups.each do |security_group|
19
- group_name = security_group.group_name
20
- group_id = security_group.group_id
16
+ rows = []
17
+ next_token = nil
21
18
 
22
- # Inboundルール
23
- security_group.ip_permissions.each do |ip_permission|
24
- ip_permission.from_port.nil? ? from_port = "all" : from_port = ip_permission.from_port.to_s
25
- ip_permission.ip_protocol == "-1" ? ip_protocol = "all" : ip_protocol = ip_permission.ip_protocol
19
+ begin
20
+ param_args = {
21
+ max_results: 100
22
+ }
23
+ param_args[:next_token] = next_token if next_token
24
+ resp = @ec2_client.describe_security_groups(param_args)
25
+ resp.security_groups.each do |security_group|
26
+ group_name = security_group.group_name
27
+ group_id = security_group.group_id
26
28
 
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, "#{cidr_ip}:#{from_port}", ip_protocol]
31
- group_name = ''
32
- group_id = ''
33
- end
34
- # IPアドレスによるルール
35
- ip_permission.ip_ranges.each do |ip_range|
36
- cidr_ip = ip_range.cidr_ip
37
- rows << [group_name, group_id, "#{cidr_ip}:#{from_port}", ip_protocol]
38
- group_name = ''
39
- group_id = ''
29
+ # Inboundルール
30
+ security_group.ip_permissions.each do |ip_permission|
31
+ ip_permission.from_port.nil? ? from_port = "all" : from_port = ip_permission.from_port.to_s
32
+ ip_permission.ip_protocol == "-1" ? ip_protocol = "all" : ip_protocol = ip_permission.ip_protocol
33
+
34
+ # セキュリティグループによるルール
35
+ ip_permission.user_id_group_pairs.each do |user_id_group_pair|
36
+ cidr_ip = user_id_group_pair.group_id
37
+ rows << [group_name, group_id, "#{cidr_ip}:#{from_port}", ip_protocol]
38
+ group_name = ''
39
+ group_id = ''
40
+ end
41
+ # IPアドレスによるルール
42
+ ip_permission.ip_ranges.each do |ip_range|
43
+ cidr_ip = ip_range.cidr_ip
44
+ rows << [group_name, group_id, "#{cidr_ip}:#{from_port}", ip_protocol]
45
+ group_name = ''
46
+ group_id = ''
47
+ end
40
48
  end
41
49
  end
42
- end
50
+ next_token = resp.next_token
51
+ end while next_token
43
52
  @term_table = Terminal::Table.new :headings => ['Name', 'Id', 'Inbound(Cidr|Securitygroup:Port)', 'Protocol'], :rows => rows
44
53
  end
45
54
  end
@@ -12,17 +12,24 @@ module Vaws
12
12
  end
13
13
 
14
14
  def set_basic_info
15
- rows = []
16
- params = @ssm_client.describe_parameters({ max_results: 50 })
15
+ rows = []
16
+ next_token = nil
17
17
 
18
- params.parameters.each do |param|
19
- name = param.name
20
- type = param.type
21
- version = param.version
22
- last_modify_date = param.last_modified_date
23
-
24
- rows << [name, type, version, last_modify_date]
25
- end
18
+ begin
19
+ param_args = {
20
+ max_results: 100
21
+ }
22
+ param_args[:next_token] = next_token if next_token
23
+ resp = @ssm_client.describe_parameters(param_args)
24
+ resp.parameters.each do |param|
25
+ name = param.name
26
+ type = param.type
27
+ version = param.version
28
+ last_modify_date = param.last_modified_date
29
+ rows << [name, type, version, last_modify_date]
30
+ end
31
+ next_token = resp.next_token
32
+ end while next_token
26
33
  @term_table = Terminal::Table.new :headings => ['Path', 'Type', 'Version', 'LastModifyDate'], :rows => rows.sort
27
34
  end
28
35
  end
@@ -12,16 +12,24 @@ module Vaws
12
12
  end
13
13
 
14
14
  def set_basic_info
15
- rows = []
16
- subnets = @subnet_client.describe_subnets
17
- subnets.subnets.each do |subnet|
18
- az = subnet.availability_zone
19
- cidr = subnet.cidr_block
20
- subnet_id = subnet.subnet_id
21
- vpc_id = subnet.vpc_id
15
+ rows = []
16
+ next_token = nil
22
17
 
23
- rows << [cidr, subnet_id, az, vpc_id]
24
- end
18
+ begin
19
+ param_args = {
20
+ max_results: 100
21
+ }
22
+ param_args[:next_token] = next_token if next_token
23
+ resp = @subnet_client.describe_subnets(param_args)
24
+ resp.subnets.each do |subnet|
25
+ az = subnet.availability_zone
26
+ cidr = subnet.cidr_block
27
+ subnet_id = subnet.subnet_id
28
+ vpc_id = subnet.vpc_id
29
+ rows << [cidr, subnet_id, az, vpc_id]
30
+ end
31
+ next_token = resp.next_token
32
+ end while next_token
25
33
  @term_table = Terminal::Table.new :headings => ['Cidr', 'SubnetId', 'Az', 'VpcId'], :rows => rows.sort
26
34
  end
27
35
  end
@@ -12,21 +12,27 @@ module Vaws
12
12
  end
13
13
 
14
14
  def set_basic_info
15
- rows = []
16
- vpcs = @vpc_client.describe_vpcs
15
+ rows = []
16
+ next_token = nil
17
17
 
18
- vpcs.vpcs.each do |vpc|
19
- cidr = vpc.cidr_block
20
- vpc_id = vpc.vpc_id
21
-
22
- tags = ''
23
- vpc.tags.each_with_index do |tag, index|
24
- tags << "#{tag.value}, "
25
- tags = tags.gsub(/, $/, '') if index == vpc.tags.size - 1
18
+ begin
19
+ param_args = {
20
+ max_results: 100
21
+ }
22
+ param_args[:next_token] = next_token if next_token
23
+ resp = @vpc_client.describe_vpcs(param_args)
24
+ resp.vpcs.each do |vpc|
25
+ cidr = vpc.cidr_block
26
+ vpc_id = vpc.vpc_id
27
+ tags = ''
28
+ vpc.tags.each_with_index do |tag, index|
29
+ tags << "#{tag.value}, "
30
+ tags = tags.gsub(/, $/, '') if index == vpc.tags.size - 1
31
+ end
32
+ rows << [vpc_id, cidr, tags]
26
33
  end
27
-
28
- rows << [vpc_id, cidr, tags]
29
- end
34
+ next_token = resp.next_token
35
+ end while next_token
30
36
  @term_table = Terminal::Table.new :headings => ['VpcId', 'Cidr', 'Tags'], :rows => rows.sort
31
37
  end
32
38
  end
@@ -1,3 +1,3 @@
1
1
  module Vaws
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
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.7.0
4
+ version: 0.8.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: 2020-03-07 00:00:00.000000000 Z
11
+ date: 2020-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -220,8 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
220
  - !ruby/object:Gem::Version
221
221
  version: '0'
222
222
  requirements: []
223
- rubyforge_project:
224
- rubygems_version: 2.7.6.2
223
+ rubygems_version: 3.1.2
225
224
  signing_key:
226
225
  specification_version: 4
227
226
  summary: The vaws command simplifies the display of AWS resources.