awspec 1.19.1 → 1.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/doc/_resource_types/cognito_identity_pool.md +7 -0
  3. data/doc/_resource_types/cognito_user_pool.md +7 -0
  4. data/doc/_resource_types/msk.md +15 -0
  5. data/doc/_resource_types/transit_gateway.md +24 -0
  6. data/doc/_resource_types/vpc_endpoints.md +70 -0
  7. data/doc/resource_types.md +180 -9
  8. data/lib/awspec/generator/doc/type/cognito_identity_pool.rb +17 -0
  9. data/lib/awspec/generator/doc/type/cognito_user_pool.rb +17 -0
  10. data/lib/awspec/generator/doc/type/msk.rb +17 -0
  11. data/lib/awspec/generator/doc/type/transit_gateway.rb +17 -0
  12. data/lib/awspec/generator/doc/type/vpc_endpoints.rb +17 -0
  13. data/lib/awspec/helper/finder.rb +12 -1
  14. data/lib/awspec/helper/finder/cognito_identity_pool.rb +15 -0
  15. data/lib/awspec/helper/finder/cognito_user_pool.rb +15 -0
  16. data/lib/awspec/helper/finder/ec2.rb +10 -1
  17. data/lib/awspec/helper/finder/ecr.rb +4 -0
  18. data/lib/awspec/helper/finder/msk.rb +15 -0
  19. data/lib/awspec/helper/finder/vpc_endpoints.rb +15 -0
  20. data/lib/awspec/helper/type.rb +1 -1
  21. data/lib/awspec/stub/cognito_identity_pool.rb +16 -0
  22. data/lib/awspec/stub/cognito_user_pool.rb +47 -0
  23. data/lib/awspec/stub/msk.rb +84 -0
  24. data/lib/awspec/stub/transit_gateway.rb +52 -0
  25. data/lib/awspec/stub/vpc_endpoints.rb +64 -0
  26. data/lib/awspec/type/cognito_identity_pool.rb +11 -0
  27. data/lib/awspec/type/cognito_user_pool.rb +11 -0
  28. data/lib/awspec/type/ecr_repository.rb +4 -0
  29. data/lib/awspec/type/msk.rb +27 -0
  30. data/lib/awspec/type/security_group.rb +44 -0
  31. data/lib/awspec/type/transit_gateway.rb +24 -0
  32. data/lib/awspec/type/vpc_endpoints.rb +43 -0
  33. data/lib/awspec/version.rb +1 -1
  34. metadata +26 -2
@@ -0,0 +1,11 @@
1
+ module Awspec::Type
2
+ class CognitoIdentityPool < ResourceBase
3
+ def resource_via_client
4
+ @resource_via_client ||= find_identitypool_by_name(@display_name)
5
+ end
6
+
7
+ def id
8
+ @id ||= resource_via_client.identity_pool_id if resource_via_client
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Awspec::Type
2
+ class CognitoUserPool < ResourceBase
3
+ def resource_via_client
4
+ @resource_via_client ||= find_userpool_by_name(@display_name)
5
+ end
6
+
7
+ def id
8
+ @id ||= resource_via_client.id if resource_via_client
9
+ end
10
+ end
11
+ end
@@ -14,5 +14,9 @@ module Awspec::Type
14
14
  def id
15
15
  @id ||= resource_via_client.repository_name if resource_via_client
16
16
  end
17
+
18
+ def policy_text
19
+ @policy_text ||= get_policy_text(@display_name)
20
+ end
17
21
  end
18
22
  end
@@ -0,0 +1,27 @@
1
+ module Awspec::Type
2
+ class Msk < ResourceBase
3
+ def initialize(name)
4
+ super
5
+ @desplay_name = name
6
+ end
7
+
8
+ def resource_via_client
9
+ @resource_via_client ||= find_msk_cluster_by_name(@display_name)
10
+ end
11
+
12
+ def id
13
+ @id ||= resource_via_client.cluster_arn if resource_via_client
14
+ end
15
+
16
+ STATES = %w(
17
+ active creating updating
18
+ deleting failed
19
+ )
20
+
21
+ STATES.each do |state|
22
+ define_method state + '?' do
23
+ resource_via_client.state == state.upcase
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,4 +1,5 @@
1
1
  module Awspec::Type
2
+ # rubocop:disable Metrics/ClassLength
2
3
  class SecurityGroup < ResourceBase
3
4
  aws_resource Aws::EC2::SecurityGroup
4
5
  tags_allowed
@@ -75,12 +76,24 @@ module Awspec::Type
75
76
  end
76
77
  alias_method :outbound_permissions_count, :ip_permissions_egress_count
77
78
 
79
+ def has_inbound_rule?(rule)
80
+ resource_via_client.ip_permissions.find do |permission|
81
+ sg_rule_match?(permission, rule)
82
+ end
83
+ end
84
+
78
85
  def inbound_rule_count
79
86
  resource_via_client.ip_permissions.reduce(0) do |sum, permission|
80
87
  sum += permission.ip_ranges.count + permission.user_id_group_pairs.count
81
88
  end
82
89
  end
83
90
 
91
+ def has_outbound_rule?(rule)
92
+ resource_via_client.ip_permissions_egress.find do |permission|
93
+ sg_rule_match?(permission, rule)
94
+ end
95
+ end
96
+
84
97
  def outbound_rule_count
85
98
  resource_via_client.ip_permissions_egress.reduce(0) do |sum, permission|
86
99
  sum += permission.ip_ranges.count + permission.user_id_group_pairs.count
@@ -144,5 +157,36 @@ module Awspec::Type
144
157
  port.between?(from_port, to_port)
145
158
  end
146
159
  end
160
+
161
+ def sg_rule_match?(permission, rule)
162
+ rule[:ip_protocol] = '-1' if rule[:ip_protocol] == 'all'
163
+ return false unless permission.ip_protocol == rule[:ip_protocol]
164
+ return false unless permission.ip_protocol == '-1' || permission.from_port == rule[:from_port]
165
+ return false unless permission.ip_protocol == '-1' || permission.to_port == rule[:to_port]
166
+
167
+ if rule[:ip_range]
168
+ return false unless permission.ip_ranges.find do |ip_range|
169
+ ip_range.cidr_ip == rule[:ip_range]
170
+ end
171
+ elsif rule[:group_pair]
172
+ return false unless permission.user_id_group_pairs.find do |pair|
173
+ group_pair_match?(pair, rule[:group_pair])
174
+ end
175
+ end
176
+ true
177
+ end
178
+
179
+ def group_pair_match?(actual_pair, rule_pair)
180
+ return false unless actual_pair.group_id == rule_pair[:group_id] || rule_pair[:group_id].nil?
181
+ return false unless actual_pair.group_name == rule_pair[:group_name] || rule_pair[:group_name].nil?
182
+ return false unless actual_pair.user_id == rule_pair[:user_id] || rule_pair[:user_id].nil?
183
+ return false unless actual_pair.vpc_id == rule_pair[:vpc_id] || rule_pair[:vpc_id].nil?
184
+ return false unless
185
+ actual_pair.vpc_peering_connection_id == rule_pair[:vpc_peering_connection_id] ||
186
+ rule_pair[:vpc_peering_connection_id].nil?
187
+ return false unless actual_pair.peering_status == rule_pair[:peering_status] || rule_pair[:peering_status].nil?
188
+ true
189
+ end
147
190
  end
191
+ # rubocop:enable Metrics/ClassLength
148
192
  end
@@ -0,0 +1,24 @@
1
+ module Awspec::Type
2
+ class TransitGateway < ResourceBase
3
+ aws_resource Aws::EC2::Types::TransitGateway
4
+ tags_allowed
5
+
6
+ def resource_via_client
7
+ @resource_via_client ||= find_transit_gateway(@display_name)
8
+ end
9
+
10
+ def id
11
+ @id ||= resource_via_client.transit_gateway_id if resource_via_client
12
+ end
13
+
14
+ def options
15
+ resource_via_client.options
16
+ end
17
+
18
+ def has_attachment?(att_id)
19
+ atts = find_tgw_attachments_by_tgw_id(@id)
20
+ ret = atts.find_all { |att| att.transit_gateway_attachment_id == att_id }
21
+ ret.any?
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,43 @@
1
+ module Awspec::Type
2
+ class VpcEndpoints < ResourceBase
3
+ aws_resource Aws::EC2::Types::VpcEndpoint
4
+ tags_allowed
5
+
6
+ def resource_via_client
7
+ @resource_via_client ||= find_vpc_endpoint(@display_name)
8
+ end
9
+
10
+ def id
11
+ @id ||= resource_via_client.vpc_endpoint_id if resource_via_client
12
+ end
13
+
14
+ STATES = %w(
15
+ pendingacceptance pending available deleting
16
+ deleted rejected failed expired
17
+ )
18
+
19
+ STATES.each do |state|
20
+ define_method state + '?' do
21
+ resource_via_client.state == state
22
+ end
23
+ end
24
+
25
+ def has_route_table?(route_table_id)
26
+ rts = resource_via_client.route_table_ids
27
+
28
+ ret = rts.find do |rt|
29
+ rt == route_table_id
30
+ end
31
+ return true if ret
32
+ end
33
+
34
+ def has_subnet?(subnet_id)
35
+ subnets = resource_via_client.subnet_ids
36
+
37
+ ret = subnets.find do |subnet|
38
+ subnet == subnet_id
39
+ end
40
+ return true if ret
41
+ end
42
+ end
43
+ end
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '1.19.1'
2
+ VERSION = '1.22.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.19.1
4
+ version: 1.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-28 00:00:00.000000000 Z
11
+ date: 2020-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -251,6 +251,8 @@ files:
251
251
  - doc/_resource_types/codebuild.md
252
252
  - doc/_resource_types/codedeploy.md
253
253
  - doc/_resource_types/codedeploy_deployment_group.md
254
+ - doc/_resource_types/cognito_identity_pool.md
255
+ - doc/_resource_types/cognito_user_pool.md
254
256
  - doc/_resource_types/customer_gateway.md
255
257
  - doc/_resource_types/directconnect_virtual_interface.md
256
258
  - doc/_resource_types/dynamodb_table.md
@@ -283,6 +285,7 @@ files:
283
285
  - doc/_resource_types/launch_configuration.md
284
286
  - doc/_resource_types/launch_template.md
285
287
  - doc/_resource_types/mq.md
288
+ - doc/_resource_types/msk.md
286
289
  - doc/_resource_types/nat_gateway.md
287
290
  - doc/_resource_types/network_acl.md
288
291
  - doc/_resource_types/network_interface.md
@@ -306,7 +309,9 @@ files:
306
309
  - doc/_resource_types/sqs.md
307
310
  - doc/_resource_types/ssm_parameter.md
308
311
  - doc/_resource_types/subnet.md
312
+ - doc/_resource_types/transit_gateway.md
309
313
  - doc/_resource_types/vpc.md
314
+ - doc/_resource_types/vpc_endpoints.md
310
315
  - doc/_resource_types/vpn_connection.md
311
316
  - doc/_resource_types/vpn_gateway.md
312
317
  - doc/_resource_types/waf_web_acl.md
@@ -349,6 +354,8 @@ files:
349
354
  - lib/awspec/generator/doc/type/codebuild.rb
350
355
  - lib/awspec/generator/doc/type/codedeploy.rb
351
356
  - lib/awspec/generator/doc/type/codedeploy_deployment_group.rb
357
+ - lib/awspec/generator/doc/type/cognito_identity_pool.rb
358
+ - lib/awspec/generator/doc/type/cognito_user_pool.rb
352
359
  - lib/awspec/generator/doc/type/customer_gateway.rb
353
360
  - lib/awspec/generator/doc/type/directconnect_virtual_interface.rb
354
361
  - lib/awspec/generator/doc/type/dynamodb_table.rb
@@ -382,6 +389,7 @@ files:
382
389
  - lib/awspec/generator/doc/type/launch_configuration.rb
383
390
  - lib/awspec/generator/doc/type/launch_template.rb
384
391
  - lib/awspec/generator/doc/type/mq.rb
392
+ - lib/awspec/generator/doc/type/msk.rb
385
393
  - lib/awspec/generator/doc/type/nat_gateway.rb
386
394
  - lib/awspec/generator/doc/type/network_acl.rb
387
395
  - lib/awspec/generator/doc/type/network_interface.rb
@@ -405,7 +413,9 @@ files:
405
413
  - lib/awspec/generator/doc/type/sqs.rb
406
414
  - lib/awspec/generator/doc/type/ssm_parameter.rb
407
415
  - lib/awspec/generator/doc/type/subnet.rb
416
+ - lib/awspec/generator/doc/type/transit_gateway.rb
408
417
  - lib/awspec/generator/doc/type/vpc.rb
418
+ - lib/awspec/generator/doc/type/vpc_endpoints.rb
409
419
  - lib/awspec/generator/doc/type/vpn_connection.rb
410
420
  - lib/awspec/generator/doc/type/vpn_gateway.rb
411
421
  - lib/awspec/generator/doc/type/waf_web_acl.rb
@@ -468,6 +478,8 @@ files:
468
478
  - lib/awspec/helper/finder/cloudwatch_logs.rb
469
479
  - lib/awspec/helper/finder/codebuild.rb
470
480
  - lib/awspec/helper/finder/codedeploy.rb
481
+ - lib/awspec/helper/finder/cognito_identity_pool.rb
482
+ - lib/awspec/helper/finder/cognito_user_pool.rb
471
483
  - lib/awspec/helper/finder/directconnect.rb
472
484
  - lib/awspec/helper/finder/dynamodb.rb
473
485
  - lib/awspec/helper/finder/ebs.rb
@@ -487,6 +499,7 @@ files:
487
499
  - lib/awspec/helper/finder/kms.rb
488
500
  - lib/awspec/helper/finder/lambda.rb
489
501
  - lib/awspec/helper/finder/mq.rb
502
+ - lib/awspec/helper/finder/msk.rb
490
503
  - lib/awspec/helper/finder/nlb.rb
491
504
  - lib/awspec/helper/finder/rds.rb
492
505
  - lib/awspec/helper/finder/redshift.rb
@@ -500,6 +513,7 @@ files:
500
513
  - lib/awspec/helper/finder/ssm_parameter.rb
501
514
  - lib/awspec/helper/finder/subnet.rb
502
515
  - lib/awspec/helper/finder/vpc.rb
516
+ - lib/awspec/helper/finder/vpc_endpoints.rb
503
517
  - lib/awspec/helper/finder/waf.rb
504
518
  - lib/awspec/helper/finder/wafregional.rb
505
519
  - lib/awspec/helper/type.rb
@@ -568,6 +582,8 @@ files:
568
582
  - lib/awspec/stub/codebuild.rb
569
583
  - lib/awspec/stub/codedeploy.rb
570
584
  - lib/awspec/stub/codedeploy_deployment_group.rb
585
+ - lib/awspec/stub/cognito_identity_pool.rb
586
+ - lib/awspec/stub/cognito_user_pool.rb
571
587
  - lib/awspec/stub/customer_gateway.rb
572
588
  - lib/awspec/stub/directconnect_virtual_interface.rb
573
589
  - lib/awspec/stub/duplicated_resource_type.rb
@@ -602,6 +618,7 @@ files:
602
618
  - lib/awspec/stub/launch_configuration.rb
603
619
  - lib/awspec/stub/launch_template.rb
604
620
  - lib/awspec/stub/mq.rb
621
+ - lib/awspec/stub/msk.rb
605
622
  - lib/awspec/stub/nat_gateway.rb
606
623
  - lib/awspec/stub/network_acl.rb
607
624
  - lib/awspec/stub/network_interface.rb
@@ -623,7 +640,9 @@ files:
623
640
  - lib/awspec/stub/sqs.rb
624
641
  - lib/awspec/stub/ssm_parameter.rb
625
642
  - lib/awspec/stub/subnet.rb
643
+ - lib/awspec/stub/transit_gateway.rb
626
644
  - lib/awspec/stub/vpc.rb
645
+ - lib/awspec/stub/vpc_endpoints.rb
627
646
  - lib/awspec/stub/vpn_connection.rb
628
647
  - lib/awspec/stub/vpn_gateway.rb
629
648
  - lib/awspec/stub/waf_web_acl.rb
@@ -652,6 +671,8 @@ files:
652
671
  - lib/awspec/type/codebuild.rb
653
672
  - lib/awspec/type/codedeploy.rb
654
673
  - lib/awspec/type/codedeploy_deployment_group.rb
674
+ - lib/awspec/type/cognito_identity_pool.rb
675
+ - lib/awspec/type/cognito_user_pool.rb
655
676
  - lib/awspec/type/customer_gateway.rb
656
677
  - lib/awspec/type/directconnect_virtual_interface.rb
657
678
  - lib/awspec/type/dynamodb_table.rb
@@ -685,6 +706,7 @@ files:
685
706
  - lib/awspec/type/launch_configuration.rb
686
707
  - lib/awspec/type/launch_template.rb
687
708
  - lib/awspec/type/mq.rb
709
+ - lib/awspec/type/msk.rb
688
710
  - lib/awspec/type/nat_gateway.rb
689
711
  - lib/awspec/type/network_acl.rb
690
712
  - lib/awspec/type/network_interface.rb
@@ -709,7 +731,9 @@ files:
709
731
  - lib/awspec/type/sqs.rb
710
732
  - lib/awspec/type/ssm_parameter.rb
711
733
  - lib/awspec/type/subnet.rb
734
+ - lib/awspec/type/transit_gateway.rb
712
735
  - lib/awspec/type/vpc.rb
736
+ - lib/awspec/type/vpc_endpoints.rb
713
737
  - lib/awspec/type/vpn_connection.rb
714
738
  - lib/awspec/type/vpn_gateway.rb
715
739
  - lib/awspec/type/waf_web_acl.rb