awspec 0.19.0 → 0.20.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 +4 -4
- data/.rubocop.yml +3 -0
- data/README.md +1 -3
- data/doc/_resource_types/network_acl.md +14 -0
- data/doc/resource_types.md +28 -3
- data/lib/awspec/generator/doc/type/{auto_scaling_group.rb → autoscaling_group.rb} +2 -2
- data/lib/awspec/generator/doc/type/network_acl.rb +17 -0
- data/lib/awspec/helper/credentials_loader.rb +1 -1
- data/lib/awspec/helper/finder.rb +3 -3
- data/lib/awspec/helper/finder/autoscaling.rb +12 -0
- data/lib/awspec/helper/type.rb +8 -2
- data/lib/awspec/matcher.rb +4 -0
- data/lib/awspec/matcher/be_allowed.rb +25 -0
- data/lib/awspec/matcher/be_denied.rb +25 -0
- data/lib/awspec/stub/{auto_scaling_group.rb → autoscaling_group.rb} +0 -0
- data/lib/awspec/stub/network_acl.rb +91 -0
- data/lib/awspec/type/{auto_scaling_group.rb → autoscaling_group.rb} +2 -2
- data/lib/awspec/type/network_acl.rb +112 -0
- data/lib/awspec/version.rb +1 -1
- metadata +12 -6
- data/lib/awspec/helper/finder/auto_scaling.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 909bee83f8e0ef005d5b759f4bcdb09f511fa538
|
4
|
+
data.tar.gz: e2f7486711f097f392d15ea5a3c5e8e76e9ac0fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5ee3970663f1fd780510981e655bdf03d5cccc8b1012075d44a3d6028586f4e8a912dbaa996090875e67bb6edf047ea7c64c71d1da41cb905805ab8c5e49a4a
|
7
|
+
data.tar.gz: fc09064d0a1efb4fff46c50e2e8c01342ab49fce8b9799783a372792a4dcad45617920ce0c7d4c4ad5056119d22ea62903be0fd95a07c791a1150357df9ed772
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -34,8 +34,6 @@ Or install it yourself as:
|
|
34
34
|
$ aws configure
|
35
35
|
|
36
36
|
...
|
37
|
-
|
38
|
-
$ export AWS_REGION='ap-northeast-1'
|
39
37
|
```
|
40
38
|
|
41
39
|
#### 2-2. Use spec/secrets.yml
|
@@ -76,7 +74,7 @@ Generate spec from AWS resources already exists.
|
|
76
74
|
$ awspec generate ec2 vpc-ab123cde >> spec/ec2_spec.rb
|
77
75
|
```
|
78
76
|
|
79
|
-
### Advanced Tips: Use Shared
|
77
|
+
### Advanced Tips: Use Shared Credentials (~/.aws/config ~/.aws/credentials)
|
80
78
|
|
81
79
|
```sh
|
82
80
|
$ awspec generate ec2 vpc-ab123cde --profile mycreds
|
@@ -0,0 +1,14 @@
|
|
1
|
+
### its(:inbound), its(:outbound)
|
2
|
+
|
3
|
+
```ruby
|
4
|
+
describe network_acl('my-network-acl') do
|
5
|
+
it { should exist }
|
6
|
+
it { should belong_to_vpc('my-vpc') }
|
7
|
+
it { should have_subnet('my-subnet') }
|
8
|
+
its(:inbound) { should be_allowed(80).protocol('tcp').source('123.0.456.789/32') }
|
9
|
+
its(:inbound) { should be_denied.rule_number('*').source('0.0.0.0/0') }
|
10
|
+
its(:outbound) { should be_allowed.protocol('ALL').source('0.0.0.0/0') }
|
11
|
+
its(:inbound_entries_count) { should eq 3 }
|
12
|
+
its(:outbound_entries_count) { should eq 2 }
|
13
|
+
end
|
14
|
+
```
|
data/doc/resource_types.md
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
| [vpc](#vpc)
|
8
8
|
| [s3](#s3)
|
9
9
|
| [route53_hosted_zone](#route53_hosted_zone)
|
10
|
-
| [
|
10
|
+
| [autoscaling_group](#autoscaling_group)
|
11
11
|
| [subnet](#subnet)
|
12
12
|
| [route_table](#route_table)
|
13
13
|
| [ebs](#ebs)
|
@@ -21,6 +21,7 @@
|
|
21
21
|
| [elasticache_cache_parameter_group](#elasticache_cache_parameter_group)
|
22
22
|
| [cloudwatch_alarm](#cloudwatch_alarm)
|
23
23
|
| [ses_identity](#ses_identity)
|
24
|
+
| [network_acl](#network_acl)
|
24
25
|
|
25
26
|
## <a name="ec2">ec2</a>
|
26
27
|
|
@@ -188,9 +189,9 @@ Route53HostedZone resource type.
|
|
188
189
|
### have_record_set
|
189
190
|
|
190
191
|
#### its(:id), its(:name), its(:caller_reference), its(:config), its(:resource_record_set_count)
|
191
|
-
## <a name="
|
192
|
+
## <a name="autoscaling_group">autoscaling_group</a>
|
192
193
|
|
193
|
-
|
194
|
+
AutoscalingGroup resource type.
|
194
195
|
|
195
196
|
### exist
|
196
197
|
|
@@ -425,3 +426,27 @@ SesIdentity resource type.
|
|
425
426
|
### have_identity_policy
|
426
427
|
|
427
428
|
#### its(:dkim_enabled), its(:dkim_verification_status), its(:bounce_topic), its(:complaint_topic), its(:delivery_topic), its(:forwarding_enabled), its(:verification_status), its(:verification_token)
|
429
|
+
## <a name="network_acl">network_acl</a>
|
430
|
+
|
431
|
+
NetworkAcl resource type.
|
432
|
+
|
433
|
+
### exist
|
434
|
+
|
435
|
+
### have_subnet
|
436
|
+
|
437
|
+
### its(:inbound), its(:outbound)
|
438
|
+
|
439
|
+
```ruby
|
440
|
+
describe network_acl('my-network-acl') do
|
441
|
+
it { should exist }
|
442
|
+
it { should belong_to_vpc('my-vpc') }
|
443
|
+
it { should have_subnet('my-subnet') }
|
444
|
+
its(:inbound) { should be_allowed(80).protocol('tcp').source('123.0.456.789/32') }
|
445
|
+
its(:inbound) { should be_denied.rule_number('*').source('0.0.0.0/0') }
|
446
|
+
its(:outbound) { should be_allowed.protocol('ALL').source('0.0.0.0/0') }
|
447
|
+
its(:inbound_entries_count) { should eq 3 }
|
448
|
+
its(:outbound_entries_count) { should eq 2 }
|
449
|
+
end
|
450
|
+
```
|
451
|
+
|
452
|
+
#### its(:inbound_entries_count), its(:outbound_entries_count), its(:network_acl_id), its(:vpc_id), its(:is_default)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Awspec::Generator
|
2
2
|
module Doc
|
3
3
|
module Type
|
4
|
-
class
|
4
|
+
class AutoscalingGroup < Base
|
5
5
|
def initialize
|
6
6
|
super
|
7
|
-
@type = Awspec::Type::
|
7
|
+
@type = Awspec::Type::AutoscalingGroup.new('my-auto-scaling-group')
|
8
8
|
@ret = @type.resource
|
9
9
|
@matchers = []
|
10
10
|
@ignore_matchers = []
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Doc
|
3
|
+
module Type
|
4
|
+
class NetworkAcl < Base
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@type_name = 'NetworkAcl'
|
8
|
+
@type = Awspec::Type::NetworkAcl.new('my-network-acl')
|
9
|
+
@ret = @type.resource
|
10
|
+
@matchers = ['its(:inbound), its(:outbound)']
|
11
|
+
@ignore_matchers = %w(be_allowed be_denied)
|
12
|
+
@describes = %w(inbound_entries_count outbound_entries_count)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -4,7 +4,7 @@ require 'aws_config'
|
|
4
4
|
module Awspec::Helper
|
5
5
|
module CredentialsLoader
|
6
6
|
def self.load(profile = nil)
|
7
|
-
profile = ENV['AWS_PROFILE'] if profile.nil?
|
7
|
+
profile = ENV['AWS_PROFILE'] if profile.nil?
|
8
8
|
if profile
|
9
9
|
# SharedCredentials
|
10
10
|
aws_config = AWSConfig.profiles[profile]
|
data/lib/awspec/helper/finder.rb
CHANGED
@@ -5,7 +5,7 @@ require 'awspec/helper/finder/security_group'
|
|
5
5
|
require 'awspec/helper/finder/rds'
|
6
6
|
require 'awspec/helper/finder/route53'
|
7
7
|
require 'awspec/helper/finder/s3'
|
8
|
-
require 'awspec/helper/finder/
|
8
|
+
require 'awspec/helper/finder/autoscaling'
|
9
9
|
require 'awspec/helper/finder/ebs'
|
10
10
|
require 'awspec/helper/finder/elb'
|
11
11
|
require 'awspec/helper/finder/lambda'
|
@@ -23,7 +23,7 @@ module Awspec::Helper
|
|
23
23
|
include Awspec::Helper::Finder::Rds
|
24
24
|
include Awspec::Helper::Finder::Route53
|
25
25
|
include Awspec::Helper::Finder::S3
|
26
|
-
include Awspec::Helper::Finder::
|
26
|
+
include Awspec::Helper::Finder::Autoscaling
|
27
27
|
include Awspec::Helper::Finder::Ebs
|
28
28
|
include Awspec::Helper::Finder::Elb
|
29
29
|
include Awspec::Helper::Finder::Lambda
|
@@ -38,7 +38,7 @@ module Awspec::Helper
|
|
38
38
|
@rds_client = Aws::RDS::Client.new
|
39
39
|
@route53_client = Aws::Route53::Client.new
|
40
40
|
@s3_client = Aws::S3::Client.new
|
41
|
-
@
|
41
|
+
@autoscaling_client = Aws::AutoScaling::Client.new
|
42
42
|
@elb_client = Aws::ElasticLoadBalancing::Client.new
|
43
43
|
@lambda_client = Aws::Lambda::Client.new
|
44
44
|
@iam_client = Aws::IAM::Client.new
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Awspec::Helper
|
2
|
+
module Finder
|
3
|
+
module Autoscaling
|
4
|
+
def find_autoscaling_group(id)
|
5
|
+
res = @autoscaling_client.describe_auto_scaling_groups({
|
6
|
+
auto_scaling_group_names: [id]
|
7
|
+
})
|
8
|
+
res[:auto_scaling_groups].first if res[:auto_scaling_groups].count == 1
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/lib/awspec/helper/type.rb
CHANGED
@@ -3,10 +3,10 @@ module Awspec
|
|
3
3
|
module Type
|
4
4
|
TYPES = %w(
|
5
5
|
base ec2 rds rds_db_parameter_group security_group
|
6
|
-
vpc s3 route53_hosted_zone
|
6
|
+
vpc s3 route53_hosted_zone autoscaling_group subnet
|
7
7
|
route_table ebs elb lambda iam_user iam_group iam_role
|
8
8
|
iam_policy elasticache elasticache_cache_parameter_group
|
9
|
-
cloudwatch_alarm ses_identity
|
9
|
+
cloudwatch_alarm ses_identity network_acl
|
10
10
|
)
|
11
11
|
|
12
12
|
TYPES.each do |type|
|
@@ -16,6 +16,12 @@ module Awspec
|
|
16
16
|
eval "Awspec::Type::#{type.camelize}.new(name)"
|
17
17
|
end
|
18
18
|
end
|
19
|
+
|
20
|
+
# deprecated resource type
|
21
|
+
def auto_scaling_group(name)
|
22
|
+
puts '!!! `auto_scaling_group` type is deprecated. use `autoscaling_group` !!!'
|
23
|
+
Awspec::Type::AutoscalingGroup.new(name)
|
24
|
+
end
|
19
25
|
end
|
20
26
|
end
|
21
27
|
end
|
data/lib/awspec/matcher.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
RSpec::Matchers.define :be_allowed do |port|
|
2
|
+
match do |resource|
|
3
|
+
resource.allowed?(port, @protocol, @cidr, @rule_number)
|
4
|
+
end
|
5
|
+
|
6
|
+
chain :protocol do |protocol|
|
7
|
+
@protocol = protocol
|
8
|
+
end
|
9
|
+
|
10
|
+
chain :for do |cidr|
|
11
|
+
@cidr = cidr
|
12
|
+
end
|
13
|
+
|
14
|
+
chain :target do |cidr|
|
15
|
+
@cidr = cidr
|
16
|
+
end
|
17
|
+
|
18
|
+
chain :source do |cidr|
|
19
|
+
@cidr = cidr
|
20
|
+
end
|
21
|
+
|
22
|
+
chain :rule_number do |rule_number|
|
23
|
+
@rule_number = rule_number
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
RSpec::Matchers.define :be_denied do |port|
|
2
|
+
match do |resource|
|
3
|
+
resource.denied?(port, @protocol, @cidr, @rule_number)
|
4
|
+
end
|
5
|
+
|
6
|
+
chain :protocol do |protocol|
|
7
|
+
@protocol = protocol
|
8
|
+
end
|
9
|
+
|
10
|
+
chain :for do |cidr|
|
11
|
+
@cidr = cidr
|
12
|
+
end
|
13
|
+
|
14
|
+
chain :target do |cidr|
|
15
|
+
@cidr = cidr
|
16
|
+
end
|
17
|
+
|
18
|
+
chain :source do |cidr|
|
19
|
+
@cidr = cidr
|
20
|
+
end
|
21
|
+
|
22
|
+
chain :rule_number do |rule_number|
|
23
|
+
@rule_number = rule_number
|
24
|
+
end
|
25
|
+
end
|
File without changes
|
@@ -0,0 +1,91 @@
|
|
1
|
+
Aws.config[:ec2] = {
|
2
|
+
stub_responses: {
|
3
|
+
describe_network_acls: {
|
4
|
+
network_acls: [
|
5
|
+
{ network_acl_id: 'acl-1abc2d3e',
|
6
|
+
vpc_id: 'vpc-ab123cde',
|
7
|
+
is_default: true,
|
8
|
+
entries:
|
9
|
+
[
|
10
|
+
{ rule_number: 100,
|
11
|
+
protocol: '-1',
|
12
|
+
rule_action: 'allow',
|
13
|
+
egress: true,
|
14
|
+
cidr_block: '0.0.0.0/0'
|
15
|
+
},
|
16
|
+
{ rule_number: 32_767,
|
17
|
+
protocol: '-1',
|
18
|
+
rule_action: 'deny',
|
19
|
+
egress: true,
|
20
|
+
cidr_block: '0.0.0.0/0'
|
21
|
+
},
|
22
|
+
{ rule_number: 2,
|
23
|
+
protocol: '6',
|
24
|
+
rule_action: 'allow',
|
25
|
+
egress: false,
|
26
|
+
cidr_block: '123.0.456.789/32',
|
27
|
+
port_range: {
|
28
|
+
from: 80, to: 80
|
29
|
+
}
|
30
|
+
},
|
31
|
+
{ rule_number: 100,
|
32
|
+
protocol: '-1',
|
33
|
+
rule_action: 'allow',
|
34
|
+
egress: false,
|
35
|
+
cidr_block: '0.0.0.0/0'
|
36
|
+
},
|
37
|
+
{ rule_number: 32_767,
|
38
|
+
protocol: '-1',
|
39
|
+
rule_action: 'deny',
|
40
|
+
egress: false,
|
41
|
+
cidr_block: '0.0.0.0/0'
|
42
|
+
}
|
43
|
+
],
|
44
|
+
associations:
|
45
|
+
[
|
46
|
+
{
|
47
|
+
network_acl_association_id: 'aclassoc-12345678',
|
48
|
+
network_acl_id: 'acl-1abc2d3e',
|
49
|
+
subnet_id: 'subnet-1234a567'
|
50
|
+
}
|
51
|
+
],
|
52
|
+
tags: [
|
53
|
+
{
|
54
|
+
key: 'Name',
|
55
|
+
value: 'my-network-acl'
|
56
|
+
}
|
57
|
+
]
|
58
|
+
}
|
59
|
+
]
|
60
|
+
},
|
61
|
+
describe_vpcs: {
|
62
|
+
vpcs: [
|
63
|
+
{
|
64
|
+
vpc_id: 'vpc-ab123cde',
|
65
|
+
tags: [
|
66
|
+
{
|
67
|
+
key: 'Name',
|
68
|
+
value: 'my-vpc'
|
69
|
+
}
|
70
|
+
]
|
71
|
+
}
|
72
|
+
]
|
73
|
+
},
|
74
|
+
describe_subnets: {
|
75
|
+
subnets: [
|
76
|
+
{
|
77
|
+
state: 'available',
|
78
|
+
vpc_id: 'vpc-ab123cde',
|
79
|
+
subnet_id: 'subnet-1234a567',
|
80
|
+
cidr_block: '10.0.1.0/24',
|
81
|
+
tags: [
|
82
|
+
{
|
83
|
+
key: 'Name',
|
84
|
+
value: 'my-subnet'
|
85
|
+
}
|
86
|
+
]
|
87
|
+
}
|
88
|
+
]
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
@@ -0,0 +1,112 @@
|
|
1
|
+
module Awspec::Type
|
2
|
+
class NetworkAcl < Base
|
3
|
+
def initialize(id)
|
4
|
+
super
|
5
|
+
@resource = find_network_acl(id)
|
6
|
+
@id = @resource[:network_acl_id] if @resource
|
7
|
+
end
|
8
|
+
|
9
|
+
def has_subnet?(subnet_id)
|
10
|
+
@resource.associations.find do |a|
|
11
|
+
return true if a.subnet_id == subnet_id
|
12
|
+
subnet = find_subnet(subnet_id)
|
13
|
+
return false unless subnet
|
14
|
+
return a.subnet_id == subnet[:subnet_id]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def allowed?(port = nil, protocol = nil, cidr = nil, rule_number = nil)
|
19
|
+
rule_action = 'allow'
|
20
|
+
entry?(rule_action, port, protocol, cidr, rule_number)
|
21
|
+
end
|
22
|
+
|
23
|
+
def denied?(port = nil, protocol = nil, cidr = nil, rule_number = nil)
|
24
|
+
rule_action = 'deny'
|
25
|
+
entry?(rule_action, port, protocol, cidr, rule_number)
|
26
|
+
end
|
27
|
+
|
28
|
+
def inbound
|
29
|
+
@egress = false
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
def outbound
|
34
|
+
@egress = true
|
35
|
+
self
|
36
|
+
end
|
37
|
+
|
38
|
+
def inbound_entries_count
|
39
|
+
@resource[:entries].count do |entry|
|
40
|
+
entry.egress == false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def outbound_entries_count
|
45
|
+
@resource[:entries].count do |entry|
|
46
|
+
entry.egress == true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def entry?(rule_action, port = nil, protocol = nil, cidr = nil, rule_number = nil)
|
53
|
+
@resource[:entries].find do |entry|
|
54
|
+
# egress rule_action
|
55
|
+
next false if entry.egress != @egress
|
56
|
+
next false if entry.rule_action != rule_action
|
57
|
+
# protocol
|
58
|
+
unless protocol.nil?
|
59
|
+
next false unless protocol_match?(protocol, entry.protocol)
|
60
|
+
end
|
61
|
+
# cidr
|
62
|
+
next false if !cidr.nil? && entry.cidr_block != cidr
|
63
|
+
# rule_number
|
64
|
+
rule_number = 32_767 if rule_number == '*'
|
65
|
+
next false if !rule_number.nil? && entry.rule_number != rule_number
|
66
|
+
# port
|
67
|
+
unless entry.port_range.nil?
|
68
|
+
next false unless port_between?(port, entry.port_range.from, entry.port_range.to)
|
69
|
+
end
|
70
|
+
next true
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# rubocop:disable Metrics/LineLength
|
75
|
+
PROTOCOLS = { 'ALL' => -1, 'HOPOPT' => 0, 'ICMP' => 1, 'IGMP' => 2, 'GGP' => 3, 'IPv4' => 4, 'ST' => 5, 'TCP' => 6, 'CBT' => 7, 'EGP' => 8, 'IGP' => 9, 'BBN-RCC-MON' => 10,
|
76
|
+
'NVP-II' => 11, 'PUP' => 12, 'ARGUS' => 13, 'EMCON' => 14, 'XNET' => 15, 'CHAOS' => 16, 'UDP' => 17, 'MUX' => 18, 'DCN-MEAS' => 19, 'HMP' => 20,
|
77
|
+
'PRM' => 21, 'XNS-IDP' => 22, 'TRUNK-1' => 23, 'TRUNK-2' => 24, 'LEAF-1' => 25, 'LEAF-2' => 26, 'RDP' => 27, 'IRTP' => 28, 'ISO-TP4' => 29, 'NETBLT' => 30,
|
78
|
+
'MFE-NSP' => 31, 'MERIT-INP' => 32, 'DCCP' => 33, '3PC' => 34, 'IDPR' => 35, 'XTP' => 36, 'DDP' => 37, 'IDPR-CMTP' => 38, 'TP++' => 39, 'IL' => 40,
|
79
|
+
'IPv6' => 41, 'SDRP' => 42, 'IPv6-Route' => 43, 'IPv6-Frag' => 44, 'IDRP' => 45, 'RSVP' => 46, 'GRE' => 47, 'DSR' => 48, 'BNA' => 49, 'ESP' => 50,
|
80
|
+
'AH' => 51, 'I-NLSP' => 52, 'SWIPE' => 53, 'NARP' => 54, 'MOBILE' => 55, 'TLSP' => 56, 'IPv6-ICMP' => 58, 'IPv6-NoNxt' => 59, 'IPv6-Opts' => 60,
|
81
|
+
'61' => 61, 'CFTP' => 62, '63' => 63, 'SAT-EXPAK' => 64, 'KRYPTOLAN' => 65, 'RVD' => 66, 'IPPC' => 67, '68' => 68, 'SAT-MON' => 69, 'VISA' => 70,
|
82
|
+
'IPCV' => 71, 'CPNX' => 72, 'CPHB' => 73, 'WSN' => 74, 'PVP' => 75, 'BR-SAT-MON' => 76, 'SUN-ND' => 77, 'WB-MON' => 78, 'WB-EXPAK' => 79, 'ISO-IP' => 80,
|
83
|
+
'VMTP' => 81, 'SECURE-VMTP' => 82, 'VINES' => 83, 'IPTM' => 84, 'TTP' => 84, 'NSFNET-IGP' => 85, 'DGP' => 86, 'TCF' => 87, 'EIGRP' => 88, 'OSPFIGP' => 89, 'Sprite-RPC' => 90,
|
84
|
+
'LARP' => 91, 'MTP' => 92, 'AX.25' => 93, 'IPIP' => 94, 'MICP' => 95, 'SCC-SP' => 96, 'ETHERIP' => 97, 'ENCAP' => 98, '99' => 99, 'GMTP' => 100,
|
85
|
+
'IFMP' => 101, 'PNNI' => 102, 'PIM' => 103, 'ARIS' => 104, 'SCPS' => 105, 'QNX' => 106, 'A/N' => 107, 'IPComp' => 108, 'SNP' => 109, 'Compaq-Peer' => 110,
|
86
|
+
'IPX-in-IP' => 111, 'VRRP' => 112, 'PGM' => 113, '114' => 114, 'L2TP' => 115, 'DDX' => 116, 'IATP' => 117, 'STP' => 118, 'SRP' => 119, 'UTI' => 120,
|
87
|
+
'SMP' => 121, 'SM' => 122, 'PTP' => 123, 'ISIS over IPv4' => 124, 'FIRE' => 125, 'CRTP' => 126, 'CRUDP' => 127, 'SSCOPMCE' => 128, 'IPLT' => 129, 'SPS' => 130,
|
88
|
+
'PIPE' => 131, 'SCTP' => 132, 'FC' => 133, 'RSVP-E2E-IGNORE' => 134, 'Mobility Header' => 135, 'UDPLite' => 136, 'MPLS-in-IP' => 137, 'manet' => 138, 'HIP' => 139, 'Shim6' => 140,
|
89
|
+
'WESP' => 141, 'ROHC' => 142, '253' => 253, '254' => 254 }
|
90
|
+
# rubocop:enable Metrics/LineLength
|
91
|
+
|
92
|
+
def protocol_match?(a, b)
|
93
|
+
if a.match(/\A\d+\z/) && a.to_i >= 0
|
94
|
+
return false unless b.to_i == a.to_i
|
95
|
+
else
|
96
|
+
lower_h = PROTOCOLS.map { |k, v| [k.downcase, v] }.to_h
|
97
|
+
return false unless lower_h.key?(a.downcase)
|
98
|
+
return false unless b.to_i == lower_h[a.downcase]
|
99
|
+
end
|
100
|
+
true
|
101
|
+
end
|
102
|
+
|
103
|
+
def port_between?(port, from_port, to_port)
|
104
|
+
if port.is_a?(String) && port.include?('-')
|
105
|
+
f, t = port.split('-')
|
106
|
+
from_port == f.to_i && to_port == t.to_i
|
107
|
+
else
|
108
|
+
port.between?(from_port, to_port)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
data/lib/awspec/version.rb
CHANGED
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: 0.
|
4
|
+
version: 0.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k1LoW
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -176,6 +176,7 @@ files:
|
|
176
176
|
- doc/_resource_types/iam_role.md
|
177
177
|
- doc/_resource_types/iam_user.md
|
178
178
|
- doc/_resource_types/lambda.md
|
179
|
+
- doc/_resource_types/network_acl.md
|
179
180
|
- doc/_resource_types/rds_db_parameter_group.md
|
180
181
|
- doc/_resource_types/security_group.md
|
181
182
|
- doc/contributing.md
|
@@ -188,7 +189,7 @@ files:
|
|
188
189
|
- lib/awspec/ext/struct.rb
|
189
190
|
- lib/awspec/generator.rb
|
190
191
|
- lib/awspec/generator/doc/type.rb
|
191
|
-
- lib/awspec/generator/doc/type/
|
192
|
+
- lib/awspec/generator/doc/type/autoscaling_group.rb
|
192
193
|
- lib/awspec/generator/doc/type/base.rb
|
193
194
|
- lib/awspec/generator/doc/type/cloudwatch_alarm.rb
|
194
195
|
- lib/awspec/generator/doc/type/ebs.rb
|
@@ -201,6 +202,7 @@ files:
|
|
201
202
|
- lib/awspec/generator/doc/type/iam_role.rb
|
202
203
|
- lib/awspec/generator/doc/type/iam_user.rb
|
203
204
|
- lib/awspec/generator/doc/type/lambda.rb
|
205
|
+
- lib/awspec/generator/doc/type/network_acl.rb
|
204
206
|
- lib/awspec/generator/doc/type/rds.rb
|
205
207
|
- lib/awspec/generator/doc/type/rds_db_parameter_group.rb
|
206
208
|
- lib/awspec/generator/doc/type/route53_hosted_zone.rb
|
@@ -222,7 +224,7 @@ files:
|
|
222
224
|
- lib/awspec/helper.rb
|
223
225
|
- lib/awspec/helper/credentials_loader.rb
|
224
226
|
- lib/awspec/helper/finder.rb
|
225
|
-
- lib/awspec/helper/finder/
|
227
|
+
- lib/awspec/helper/finder/autoscaling.rb
|
226
228
|
- lib/awspec/helper/finder/cloudwatch.rb
|
227
229
|
- lib/awspec/helper/finder/ebs.rb
|
228
230
|
- lib/awspec/helper/finder/ec2.rb
|
@@ -238,7 +240,9 @@ files:
|
|
238
240
|
- lib/awspec/helper/finder/vpc.rb
|
239
241
|
- lib/awspec/helper/type.rb
|
240
242
|
- lib/awspec/matcher.rb
|
243
|
+
- lib/awspec/matcher/be_allowed.rb
|
241
244
|
- lib/awspec/matcher/be_allowed_action.rb
|
245
|
+
- lib/awspec/matcher/be_denied.rb
|
242
246
|
- lib/awspec/matcher/be_opened.rb
|
243
247
|
- lib/awspec/matcher/belong_to_cache_subnet_group.rb
|
244
248
|
- lib/awspec/matcher/belong_to_db_subnet_group.rb
|
@@ -251,7 +255,7 @@ files:
|
|
251
255
|
- lib/awspec/matcher/have_route.rb
|
252
256
|
- lib/awspec/setup.rb
|
253
257
|
- lib/awspec/stub.rb
|
254
|
-
- lib/awspec/stub/
|
258
|
+
- lib/awspec/stub/autoscaling_group.rb
|
255
259
|
- lib/awspec/stub/cloudwatch_alarm.rb
|
256
260
|
- lib/awspec/stub/ebs.rb
|
257
261
|
- lib/awspec/stub/ec2.rb
|
@@ -263,6 +267,7 @@ files:
|
|
263
267
|
- lib/awspec/stub/iam_role.rb
|
264
268
|
- lib/awspec/stub/iam_user.rb
|
265
269
|
- lib/awspec/stub/lambda.rb
|
270
|
+
- lib/awspec/stub/network_acl.rb
|
266
271
|
- lib/awspec/stub/rds.rb
|
267
272
|
- lib/awspec/stub/rds_db_parameter_group.rb
|
268
273
|
- lib/awspec/stub/route53_hosted_zone.rb
|
@@ -273,7 +278,7 @@ files:
|
|
273
278
|
- lib/awspec/stub/subnet.rb
|
274
279
|
- lib/awspec/stub/vpc.rb
|
275
280
|
- lib/awspec/toolbox.rb
|
276
|
-
- lib/awspec/type/
|
281
|
+
- lib/awspec/type/autoscaling_group.rb
|
277
282
|
- lib/awspec/type/base.rb
|
278
283
|
- lib/awspec/type/cloudwatch_alarm.rb
|
279
284
|
- lib/awspec/type/ebs.rb
|
@@ -286,6 +291,7 @@ files:
|
|
286
291
|
- lib/awspec/type/iam_role.rb
|
287
292
|
- lib/awspec/type/iam_user.rb
|
288
293
|
- lib/awspec/type/lambda.rb
|
294
|
+
- lib/awspec/type/network_acl.rb
|
289
295
|
- lib/awspec/type/rds.rb
|
290
296
|
- lib/awspec/type/rds_db_parameter_group.rb
|
291
297
|
- lib/awspec/type/route53_hosted_zone.rb
|
@@ -1,12 +0,0 @@
|
|
1
|
-
module Awspec::Helper
|
2
|
-
module Finder
|
3
|
-
module AutoScaling
|
4
|
-
def find_auto_scaling_group(id)
|
5
|
-
res = @auto_scaling_client.describe_auto_scaling_groups({
|
6
|
-
auto_scaling_group_names: [id]
|
7
|
-
})
|
8
|
-
res[:auto_scaling_groups].first if res[:auto_scaling_groups].count == 1
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|