awspec 1.1.0 → 1.2.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/.travis.yml +2 -1
- data/doc/_resource_types/vpc.md +20 -0
- data/doc/resource_types.md +22 -0
- data/lib/awspec/helper/finder/vpc.rb +11 -0
- data/lib/awspec/matcher.rb +4 -0
- data/lib/awspec/matcher/be_connected_to_vpc.rb +13 -0
- data/lib/awspec/matcher/have_vpc_peering_connection.rb +13 -0
- data/lib/awspec/stub/vpc.rb +36 -0
- data/lib/awspec/type/vpc.rb +26 -0
- data/lib/awspec/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b179910887dad4c07a7dcb3a3964eddd1bd89a5
|
4
|
+
data.tar.gz: '09e960c5431fbf85ed39531e42dee075f46e9e67'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 348f694481e7db4994744ffbc6ee94001f10d2132ae6762dc6f2f314e7dbb62d6e30c2e30609f833604c30bcc5d8472c0a972fd94f6d907ac3ed2815dbd6bccb
|
7
|
+
data.tar.gz: 1584f796a4420efa011fdd2f297096e8872f48d473becda49b8dbfce86d896613546c28d9347ebd5b90e7cd31ce1f2d716cbc5b3e5824202b19c274657dc6087
|
data/.travis.yml
CHANGED
data/doc/_resource_types/vpc.md
CHANGED
@@ -14,6 +14,16 @@ describe vpc('vpc-ab123cde') do
|
|
14
14
|
end
|
15
15
|
```
|
16
16
|
|
17
|
+
### be_connected_to_vpc
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
describe vpc('vpc-ab123cde') do
|
21
|
+
it { should be_connected_to_vpc('vpc-bcd1235e') }
|
22
|
+
it { should be_connected_to_vpc('vpc-bcd1235e').as_accepter }
|
23
|
+
it { should_not be_connected_to_vpc('vpc-bcd1235e').as_requester }
|
24
|
+
end
|
25
|
+
```
|
26
|
+
|
17
27
|
### have_network_acl
|
18
28
|
|
19
29
|
```ruby
|
@@ -40,6 +50,16 @@ describe vpc('vpc-ab123cde') do
|
|
40
50
|
end
|
41
51
|
```
|
42
52
|
|
53
|
+
### have_vpc_peering_connection
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
describe vpc('vpc-ab123cde') do
|
57
|
+
it { should have_vpc_peering_connection('pcx-c56789de') }
|
58
|
+
it { should have_vpc_peering_connection('pcx-c56789de').as_accepter }
|
59
|
+
it { should_not have_vpc_peering_connection('pcx-c56789de').as_requester }
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
43
63
|
### advanced
|
44
64
|
|
45
65
|
`vpc` can use `Aws::EC2::Vpc` resource (see http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Vpc.html).
|
data/doc/resource_types.md
CHANGED
@@ -2454,6 +2454,17 @@ end
|
|
2454
2454
|
```
|
2455
2455
|
|
2456
2456
|
|
2457
|
+
### be_connected_to_vpc
|
2458
|
+
|
2459
|
+
```ruby
|
2460
|
+
describe vpc('vpc-ab123cde') do
|
2461
|
+
it { should be_connected_to_vpc('vpc-bcd1235e') }
|
2462
|
+
it { should be_connected_to_vpc('vpc-bcd1235e').as_accepter }
|
2463
|
+
it { should_not be_connected_to_vpc('vpc-bcd1235e').as_requester }
|
2464
|
+
end
|
2465
|
+
```
|
2466
|
+
|
2467
|
+
|
2457
2468
|
### have_network_acl
|
2458
2469
|
|
2459
2470
|
```ruby
|
@@ -2483,6 +2494,17 @@ end
|
|
2483
2494
|
```
|
2484
2495
|
|
2485
2496
|
|
2497
|
+
### have_vpc_peering_connection
|
2498
|
+
|
2499
|
+
```ruby
|
2500
|
+
describe vpc('vpc-ab123cde') do
|
2501
|
+
it { should have_vpc_peering_connection('pcx-c56789de') }
|
2502
|
+
it { should have_vpc_peering_connection('pcx-c56789de').as_accepter }
|
2503
|
+
it { should_not have_vpc_peering_connection('pcx-c56789de').as_requester }
|
2504
|
+
end
|
2505
|
+
```
|
2506
|
+
|
2507
|
+
|
2486
2508
|
### its(:cidr_block), its(:dhcp_options_id), its(:state), its(:vpc_id), its(:instance_tenancy), its(:ipv_6_cidr_block_association_set), its(:cidr_block_association_set), its(:is_default)
|
2487
2509
|
### :unlock: Advanced use
|
2488
2510
|
|
@@ -72,6 +72,17 @@ module Awspec::Helper
|
|
72
72
|
})
|
73
73
|
res.vpc_peering_connections.single_resource(vpc_peering_connection_id)
|
74
74
|
end
|
75
|
+
|
76
|
+
def select_vpc_peering_connection_by_vpc_id(vpc_id, status_code = nil)
|
77
|
+
params = {}
|
78
|
+
params = { filters: [{ name: 'status-code', values: [status_code] }] } if status_code
|
79
|
+
vpc_peering_connections = ec2_client.describe_vpc_peering_connections(params).map do |res|
|
80
|
+
res.vpc_peering_connections
|
81
|
+
end.flatten
|
82
|
+
vpc_peering_connections.select do |conn|
|
83
|
+
conn.accepter_vpc_info.vpc_id == vpc_id || conn.requester_vpc_info.vpc_id == vpc_id
|
84
|
+
end
|
85
|
+
end
|
75
86
|
end
|
76
87
|
end
|
77
88
|
end
|
data/lib/awspec/matcher.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
RSpec::Matchers.define :be_connected_to_vpc do |vpc_id|
|
2
|
+
match do |vpc|
|
3
|
+
vpc.connected_to_vpc?(vpc_id, @accepter_or_requester)
|
4
|
+
end
|
5
|
+
|
6
|
+
chain :as_accepter do
|
7
|
+
@accepter_or_requester = 'accepter'
|
8
|
+
end
|
9
|
+
|
10
|
+
chain :as_requester do
|
11
|
+
@accepter_or_requester = 'requester'
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
RSpec::Matchers.define :have_vpc_peering_connection do |vpc_peering_connection_id|
|
2
|
+
match do |vpc|
|
3
|
+
vpc.has_vpc_peering_connection?(vpc_peering_connection_id, @accepter_or_requester)
|
4
|
+
end
|
5
|
+
|
6
|
+
chain :as_accepter do
|
7
|
+
@accepter_or_requester = 'accepter'
|
8
|
+
end
|
9
|
+
|
10
|
+
chain :as_requester do
|
11
|
+
@accepter_or_requester = 'requester'
|
12
|
+
end
|
13
|
+
end
|
data/lib/awspec/stub/vpc.rb
CHANGED
@@ -64,6 +64,42 @@ Aws.config[:ec2] = {
|
|
64
64
|
]
|
65
65
|
}
|
66
66
|
]
|
67
|
+
},
|
68
|
+
describe_vpc_peering_connections: {
|
69
|
+
vpc_peering_connections: [
|
70
|
+
{
|
71
|
+
vpc_peering_connection_id: 'pcx-c56789de',
|
72
|
+
accepter_vpc_info: {
|
73
|
+
cidr_block: nil,
|
74
|
+
ipv_6_cidr_block_set: [],
|
75
|
+
cidr_block_set: [],
|
76
|
+
owner_id: '123453345554',
|
77
|
+
peering_options: nil,
|
78
|
+
vpc_id: 'vpc-ab123cde',
|
79
|
+
region: 'ap-northeast-1'
|
80
|
+
},
|
81
|
+
expiration_time: nil,
|
82
|
+
requester_vpc_info: {
|
83
|
+
cidr_block: nil,
|
84
|
+
ipv_6_cidr_block_set: [],
|
85
|
+
cidr_block_set: [],
|
86
|
+
owner_id: '192912349399',
|
87
|
+
peering_options: nil,
|
88
|
+
vpc_id: 'vpc-bcd1235e',
|
89
|
+
region: 'ap-northeast-1'
|
90
|
+
},
|
91
|
+
status: {
|
92
|
+
code: 'active',
|
93
|
+
message: 'Active'
|
94
|
+
},
|
95
|
+
tags: [
|
96
|
+
{
|
97
|
+
key: 'Name',
|
98
|
+
value: 'my-pcx'
|
99
|
+
}
|
100
|
+
]
|
101
|
+
}
|
102
|
+
]
|
67
103
|
}
|
68
104
|
}
|
69
105
|
}
|
data/lib/awspec/type/vpc.rb
CHANGED
@@ -32,5 +32,31 @@ module Awspec::Type
|
|
32
32
|
return false unless n
|
33
33
|
n.vpc_id == id
|
34
34
|
end
|
35
|
+
|
36
|
+
def connected_to_vpc?(vpc_id, accepter_or_requester = nil)
|
37
|
+
connections = select_vpc_peering_connection_by_vpc_id(vpc_id, 'active')
|
38
|
+
return connections.single_resource(vpc_id) unless accepter_or_requester
|
39
|
+
|
40
|
+
if accepter_or_requester == 'accepter'
|
41
|
+
connections.select do |conn|
|
42
|
+
conn.accepter_vpc_info.vpc_id == @id
|
43
|
+
end.single_resource(vpc_id)
|
44
|
+
elsif accepter_or_requester == 'requester'
|
45
|
+
connections.select do |conn|
|
46
|
+
conn.requester_vpc_info.vpc_id == @id
|
47
|
+
end.single_resource(vpc_id)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def has_vpc_peering_connection?(vpc_peering_connection_id, accepter_or_requester = nil)
|
52
|
+
connection = find_vpc_peering_connection(vpc_peering_connection_id)
|
53
|
+
res = if accepter_or_requester == 'accepter'
|
54
|
+
connection.accepter_vpc_info.vpc_id == @id
|
55
|
+
elsif accepter_or_requester == 'requester'
|
56
|
+
connection.requester_vpc_info.vpc_id == @id
|
57
|
+
else
|
58
|
+
connection
|
59
|
+
end
|
60
|
+
end
|
35
61
|
end
|
36
62
|
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: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- k1LoW
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -419,6 +419,7 @@ files:
|
|
419
419
|
- lib/awspec/matcher/be_allowed.rb
|
420
420
|
- lib/awspec/matcher/be_allowed_action.rb
|
421
421
|
- lib/awspec/matcher/be_attached_to.rb
|
422
|
+
- lib/awspec/matcher/be_connected_to_vpc.rb
|
422
423
|
- lib/awspec/matcher/be_denied.rb
|
423
424
|
- lib/awspec/matcher/be_opened.rb
|
424
425
|
- lib/awspec/matcher/be_opened_only.rb
|
@@ -443,6 +444,7 @@ files:
|
|
443
444
|
- lib/awspec/matcher/have_rule.rb
|
444
445
|
- lib/awspec/matcher/have_subscription_filter.rb
|
445
446
|
- lib/awspec/matcher/have_tag.rb
|
447
|
+
- lib/awspec/matcher/have_vpc_peering_connection.rb
|
446
448
|
- lib/awspec/resource_reader.rb
|
447
449
|
- lib/awspec/setup.rb
|
448
450
|
- lib/awspec/shared_context.rb
|