awspec 0.37.8 → 0.38.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c75b4619a1b6266e3fd777490ae3791b3d7e9af
4
- data.tar.gz: 839b1e5938d29199a66b8b5ab2abc7dc599a618b
3
+ metadata.gz: 9499d052c8395a806e4f186986c5f4b6ff8e9ff5
4
+ data.tar.gz: b121eb4314727b919490ceb8f0f17384f8f38ea1
5
5
  SHA512:
6
- metadata.gz: 131cc663be38749be8975eff6b28117d466f5fee261d221b8afec8f5a6f7371f456607484efbbe713e55f2eab4745a85ff5fb043e176935727d656b43bc9020c
7
- data.tar.gz: 96293279c8beff04c9d181ed980d854e5be8b1d169fd97eec0be3167a5936ae55fd495bebfc1d9556d5cff78a93c17e0a4a602b5378bd439222f309311a4ea92
6
+ metadata.gz: 635f51f380b8387c06e86c3ff321e94e0f0a4951679adf21047e99d41f8d01229196d78dceb1c0fe2fb01e5af4868aaef7c1979f7c03ddcc3e2924c62cc22642
7
+ data.tar.gz: 2c47e474a2a8d1cea044adf05b50a22f2043e23655a3b60c51ee5db601a6bf3c85a4636d77bd953631bd3f2896aac2edd493c7545fb7c543f8ce31ab91db38b5
@@ -0,0 +1,44 @@
1
+ ### exist
2
+
3
+ ```ruby
4
+ describe cloudfront_distribution('123456789zyxw.cloudfront.net') do
5
+ it { should exist }
6
+ end
7
+ ```
8
+
9
+ ### be_in_progress, be_deployed
10
+
11
+ ```ruby
12
+ describe cloudfront_distribution('123456789zyxw.cloudfront.net') do
13
+ it { should be_deployed }
14
+ end
15
+ ```
16
+
17
+ ### have_origin
18
+
19
+ ```ruby
20
+ describe cloudfront_distribution('E2CLOUDFRONTXX') do
21
+ it do
22
+ should have_origin('cf-s3-origin-hosting.dev.example.com')
23
+ .domain_name('cf-s3-origin-hosting.dev.example.com.s3.amazonaws.com')
24
+ .origin_path('/img')
25
+ .origin_access_identity('origin-access-identity/cloudfront/E2VVVVVVVVVVVV')
26
+ end
27
+ end
28
+ ```
29
+
30
+ ### have_origin_domain_name
31
+
32
+ ```ruby
33
+ describe cloudfront_distribution('123456789zyxw.cloudfront.net') do
34
+ it { should have_origin_domain_name('cf-s3-origin-hosting.dev.example.com.s3.amazonaws.com') }
35
+ end
36
+ ```
37
+
38
+ ### have_origin_domain_name_and_path
39
+
40
+ ```ruby
41
+ describe cloudfront_distribution('123456789zyxw.cloudfront.net') do
42
+ it { should have_origin_domain_name_and_path('cf-s3-origin-hosting.dev.example.com.s3.amazonaws.com/img') }
43
+ end
44
+ ```
@@ -27,6 +27,7 @@
27
27
  | [ses_identity](#ses_identity)
28
28
  | [subnet](#subnet)
29
29
  | [vpc](#vpc)
30
+ | [cloudfront_distribution](#cloudfront_distribution)
30
31
 
31
32
  ## <a name="ami">ami</a>
32
33
 
@@ -1496,3 +1497,58 @@ describe vpc('my-vpc') do
1496
1497
  its('resource.route_tables.first.route_table_id') { should eq 'rtb-a12bcd34' }
1497
1498
  end
1498
1499
  ```
1500
+
1501
+ ## <a name="cloudfront_distribution">cloudfront_distribution</a>
1502
+
1503
+ CloudfrontDistribution resource type.
1504
+
1505
+ ### exist
1506
+
1507
+ ```ruby
1508
+ describe cloudfront_distribution('123456789zyxw.cloudfront.net') do
1509
+ it { should exist }
1510
+ end
1511
+ ```
1512
+
1513
+
1514
+ ### be_in_progress, be_deployed
1515
+
1516
+ ```ruby
1517
+ describe cloudfront_distribution('123456789zyxw.cloudfront.net') do
1518
+ it { should be_deployed }
1519
+ end
1520
+ ```
1521
+
1522
+
1523
+ ### have_origin
1524
+
1525
+ ```ruby
1526
+ describe cloudfront_distribution('E2CLOUDFRONTXX') do
1527
+ it do
1528
+ should have_origin('cf-s3-origin-hosting.dev.example.com')
1529
+ .domain_name('cf-s3-origin-hosting.dev.example.com.s3.amazonaws.com')
1530
+ .origin_path('/img')
1531
+ .origin_access_identity('origin-access-identity/cloudfront/E2VVVVVVVVVVVV')
1532
+ end
1533
+ end
1534
+ ```
1535
+
1536
+
1537
+ ### have_origin_domain_name
1538
+
1539
+ ```ruby
1540
+ describe cloudfront_distribution('123456789zyxw.cloudfront.net') do
1541
+ it { should have_origin_domain_name('cf-s3-origin-hosting.dev.example.com.s3.amazonaws.com') }
1542
+ end
1543
+ ```
1544
+
1545
+
1546
+ ### have_origin_domain_name_and_path
1547
+
1548
+ ```ruby
1549
+ describe cloudfront_distribution('123456789zyxw.cloudfront.net') do
1550
+ it { should have_origin_domain_name_and_path('cf-s3-origin-hosting.dev.example.com.s3.amazonaws.com/img') }
1551
+ end
1552
+ ```
1553
+
1554
+ ### its(:id), its(:status), its(:last_modified_time), its(:domain_name), its(:comment), its(:price_class), its(:enabled), its(:web_acl_id)
@@ -0,0 +1,20 @@
1
+ module Awspec::Generator
2
+ module Doc
3
+ module Type
4
+ class CloudfrontDistribution < Base
5
+ def initialize
6
+ super
7
+ @type_name = 'CloudfrontDistribution'
8
+ @type = Awspec::Type::CloudfrontDistribution.new('123456789zyxw.cloudfront.net')
9
+ @ret = @type.resource_via_client
10
+ @matchers = [
11
+ Awspec::Type::CloudfrontDistribution::STATUSES.map { |status| 'be_' + status.underscore }.join(', ')
12
+ ]
13
+
14
+ @ignore_matchers = Awspec::Type::CloudfrontDistribution::STATUSES.map { |status| 'be_' + status.underscore }
15
+ @describes = []
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -16,6 +16,7 @@ require 'awspec/helper/finder/cloudwatch'
16
16
  require 'awspec/helper/finder/ses'
17
17
  require 'awspec/helper/finder/directconnect'
18
18
  require 'awspec/helper/finder/ami'
19
+ require 'awspec/helper/finder/cloudfront'
19
20
 
20
21
  module Awspec::Helper
21
22
  module Finder
@@ -36,6 +37,7 @@ module Awspec::Helper
36
37
  include Awspec::Helper::Finder::Ses
37
38
  include Awspec::Helper::Finder::Directconnect
38
39
  include Awspec::Helper::Finder::Ami
40
+ include Awspec::Helper::Finder::Cloudfront
39
41
 
40
42
  CLIENTS = {
41
43
  ec2_client: Aws::EC2::Client,
@@ -49,7 +51,8 @@ module Awspec::Helper
49
51
  elasticache_client: Aws::ElastiCache::Client,
50
52
  cloudwatch_client: Aws::CloudWatch::Client,
51
53
  ses_client: Aws::SES::Client,
52
- directconnect_client: Aws::DirectConnect::Client
54
+ directconnect_client: Aws::DirectConnect::Client,
55
+ cloudfront_client: Aws::CloudFront::Client
53
56
  }
54
57
 
55
58
  CLIENTS.each do |method_name, client|
@@ -0,0 +1,18 @@
1
+ module Awspec::Helper
2
+ module Finder
3
+ module Cloudfront
4
+ def find_cloudfront_distribution(id)
5
+ selected = []
6
+ res = cloudfront_client.list_distributions
7
+ loop do
8
+ selected += res.distribution_list.items.select do |item|
9
+ item.id == id || item.domain_name == id
10
+ end
11
+ (res.next_page? && res = res.next_page) || break
12
+ end
13
+
14
+ selected.single_resource(id)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -8,7 +8,7 @@ module Awspec
8
8
  ebs ec2 elasticache elasticache_cache_parameter_group elb iam_group
9
9
  iam_policy iam_role iam_user lambda launch_configuration nat_gateway
10
10
  network_acl network_interface rds rds_db_parameter_group route53_hosted_zone
11
- route_table s3_bucket security_group ses_identity subnet vpc
11
+ route_table s3_bucket security_group ses_identity subnet vpc cloudfront_distribution
12
12
  )
13
13
 
14
14
  TYPES.each do |type|
@@ -37,3 +37,6 @@ require 'awspec/matcher/be_denied'
37
37
  # NetworkInterface
38
38
  require 'awspec/matcher/be_attached_to'
39
39
  require 'awspec/matcher/have_private_ip_address'
40
+
41
+ # CloudFront
42
+ require 'awspec/matcher/have_origin'
@@ -0,0 +1,21 @@
1
+ RSpec::Matchers.define :have_origin do |origin_id|
2
+ match do |cloudfront_distribution|
3
+ cloudfront_distribution.has_origin?(origin_id,
4
+ domain_name: @domain_name,
5
+ origin_path: @origin_path,
6
+ origin_access_identity: @origin_access_identity
7
+ )
8
+ end
9
+
10
+ chain :domain_name do |domain_name|
11
+ @domain_name = domain_name
12
+ end
13
+
14
+ chain :origin_path do |origin_path|
15
+ @origin_path = origin_path
16
+ end
17
+
18
+ chain :origin_access_identity do |origin_access_identity|
19
+ @origin_access_identity = origin_access_identity
20
+ end
21
+ end
@@ -0,0 +1,204 @@
1
+ Aws.config[:cloudfront] = {
2
+ stub_responses: {
3
+ list_distributions: {
4
+ distribution_list: {
5
+ marker: '',
6
+ next_marker: nil,
7
+ max_items: 100,
8
+ is_truncated: false,
9
+ quantity: 2,
10
+ items:
11
+ [
12
+ {
13
+ id: 'E1ABCDEFG2HIJK',
14
+ status: 'Deployed',
15
+ last_modified_time: Time.new(2015, 1, 2, 10, 00, 00, '+00:00'),
16
+ domain_name: 'abcdefghijklmn.cloudfront.net',
17
+ aliases: {
18
+ quantity: 0,
19
+ items: []
20
+ },
21
+ origins: {
22
+ quantity: 1,
23
+ items:
24
+ [
25
+ {
26
+ id: 'cf-s3-origin-test',
27
+ domain_name: 'cf-origin-test.s3.amazonaws.com',
28
+ origin_path: '',
29
+ custom_headers: {
30
+ quantity: 0,
31
+ items: []
32
+ },
33
+ s3_origin_config: {
34
+ origin_access_identity: ''
35
+ },
36
+ custom_origin_config: nil
37
+ }
38
+ ]
39
+ },
40
+ default_cache_behavior: {
41
+ target_origin_id: 'cf-s3-origin-test',
42
+ forwarded_values:
43
+ {
44
+ query_string: false,
45
+ cookies:
46
+ {
47
+ forward: 'none',
48
+ whitelisted_names: nil
49
+ },
50
+ headers:
51
+ {
52
+ quantity: 0,
53
+ items: []
54
+ }
55
+ },
56
+ trusted_signers: {
57
+ enabled: false,
58
+ quantity: 0,
59
+ items: []
60
+ },
61
+ viewer_protocol_policy: 'allow-all',
62
+ min_ttl: 0,
63
+ allowed_methods: {
64
+ quantity: 2,
65
+ items: %w(HEAD GET),
66
+ cached_methods: {
67
+ quantity: 2,
68
+ items: %w(HEAD GET)
69
+ }
70
+ },
71
+ smooth_streaming: false,
72
+ default_ttl: 86_400,
73
+ max_ttl: 31_536_000,
74
+ compress: false
75
+ },
76
+ cache_behaviors: {
77
+ quantity: 0,
78
+ items: []
79
+ },
80
+ custom_error_responses: {
81
+ quantity: 0,
82
+ items: []
83
+ },
84
+ comment: '',
85
+ price_class: 'PriceClass_All',
86
+ enabled: true,
87
+ viewer_certificate: {
88
+ cloud_front_default_certificate: true,
89
+ iam_certificate_id: nil,
90
+ acm_certificate_arn: nil,
91
+ ssl_support_method: nil,
92
+ minimum_protocol_version: 'SSLv3',
93
+ certificate: nil,
94
+ certificate_source: 'cloudfront'
95
+ },
96
+ restrictions: {
97
+
98
+ geo_restriction: {
99
+
100
+ restriction_type: 'none',
101
+ quantity: 0,
102
+ items: []
103
+ }
104
+ },
105
+ web_acl_id: ''
106
+ },
107
+ {
108
+ id: 'E2CLOUDFRONTXX',
109
+ status: 'Deployed',
110
+ last_modified_time: Time.new(2016, 3, 2, 10, 00, 00, '+00:00'),
111
+ domain_name: '123456789zyxw.cloudfront.net',
112
+ aliases: {
113
+ quantity: 1,
114
+ items: ['cf-s3-origin-hosting.dev.example.com']
115
+ },
116
+ origins: {
117
+ quantity: 1,
118
+ items:
119
+ [
120
+ {
121
+ id: 'cf-s3-origin-hosting.dev.example.com',
122
+ domain_name: 'cf-s3-origin-hosting.dev.example.com.s3.amazonaws.com',
123
+ origin_path: '/img',
124
+ custom_headers: {
125
+ quantity: 0,
126
+ items: []
127
+ },
128
+ s3_origin_config: {
129
+ origin_access_identity:
130
+ 'origin-access-identity/cloudfront/E2VVVVVVVVVVVV'
131
+ },
132
+ custom_origin_config: nil
133
+ }
134
+ ]
135
+ },
136
+ default_cache_behavior: {
137
+ target_origin_id: 'cf-s3-origin-hosting.dev.example.com',
138
+ forwarded_values: {
139
+ query_string: false,
140
+ cookies: {
141
+ forward: 'none',
142
+ whitelisted_names: nil
143
+ },
144
+ headers: {
145
+ quantity: 0,
146
+ items: []
147
+ }
148
+ },
149
+ trusted_signers: {
150
+ enabled: false,
151
+ quantity: 0,
152
+ items: []
153
+ },
154
+ viewer_protocol_policy: 'redirect-to-https',
155
+ min_ttl: 0,
156
+ allowed_methods: {
157
+ quantity: 2,
158
+ items: %w(HEAD GET),
159
+ cached_methods: {
160
+ quantity: 2,
161
+ items: %w(HEAD GET)
162
+ }
163
+ },
164
+ smooth_streaming: false,
165
+ default_ttl: 3600,
166
+ max_ttl: 86_400,
167
+ compress: false
168
+ },
169
+ cache_behaviors: {
170
+ quantity: 0,
171
+ items: []
172
+ },
173
+ custom_error_responses: {
174
+ quantity: 0,
175
+ items: []
176
+ },
177
+ comment: 'cf-s3-origin-hosting.dev.example.com',
178
+ price_class: 'PriceClass_200',
179
+ enabled: true,
180
+ viewer_certificate: {
181
+ cloud_front_default_certificate: nil,
182
+ iam_certificate_id: nil,
183
+ acm_certificate_arn:
184
+ 'arn:aws:acm:us-east-1:012345678900:certificate/e1234e56-abcd-1234-5c6e-789ca0123d4b',
185
+ ssl_support_method: 'sni-only',
186
+ minimum_protocol_version: 'TLSv1',
187
+ certificate:
188
+ 'arn:aws:acm:us-east-1:012345678900:certificate/e1234e56-abcd-1234-5c6e-789ca0123d4b',
189
+ certificate_source: 'acm'
190
+ },
191
+ restrictions: {
192
+ geo_restriction: {
193
+ restriction_type: 'none',
194
+ quantity: 0,
195
+ items: []
196
+ }
197
+ },
198
+ web_acl_id: ''
199
+ }
200
+ ]
201
+ }
202
+ }
203
+ }
204
+ }
@@ -0,0 +1,44 @@
1
+ module Awspec::Type
2
+ class CloudfrontDistribution < Base
3
+ def initialize(id)
4
+ super
5
+ @resource_via_client = find_cloudfront_distribution(id)
6
+ @id = @resource_via_client.id if @resource_via_client
7
+ end
8
+
9
+ STATUSES = %w(
10
+ InProgress Deployed
11
+ )
12
+
13
+ STATUSES.each do |status|
14
+ define_method status.underscore + '?' do
15
+ @resource_via_client.status == status
16
+ end
17
+ end
18
+
19
+ def has_origin?(origin_id,
20
+ domain_name: nil,
21
+ origin_path: nil,
22
+ origin_access_identity: nil)
23
+ return false unless [origin_id, domain_name].any?
24
+ @resource_via_client.origins.items.find do |origin|
25
+ next false if !origin_id.nil? && origin.id != origin_id
26
+ next false if !domain_name.nil? && origin.domain_name != domain_name
27
+ next false if !origin_path.nil? && origin.origin_path != origin_path
28
+ next false if !origin_access_identity.nil? && \
29
+ origin.s3_origin_config.origin_access_identity != origin_access_identity
30
+ true
31
+ end
32
+ end
33
+
34
+ def has_origin_domain_name?(domain_name)
35
+ has_origin?(nil, domain_name: domain_name)
36
+ end
37
+
38
+ def has_origin_domain_name_and_path?(domain_name_and_path)
39
+ domain_name = domain_name_and_path.gsub(%r(/.*\z), '')
40
+ origin_path = domain_name_and_path.gsub(%r(\A[^/]*), '')
41
+ has_origin?(nil, domain_name: domain_name, origin_path: origin_path)
42
+ end
43
+ end
44
+ end
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '0.37.8'
2
+ VERSION = '0.38.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: 0.37.8
4
+ version: 0.38.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-04 00:00:00.000000000 Z
11
+ date: 2016-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -202,6 +202,7 @@ files:
202
202
  - bin/toolbox
203
203
  - doc/_resource_types/ami.md
204
204
  - doc/_resource_types/autoscaling_group.md
205
+ - doc/_resource_types/cloudfront_distribution.md
205
206
  - doc/_resource_types/cloudwatch_alarm.md
206
207
  - doc/_resource_types/directconnect_virtual_interface.md
207
208
  - doc/_resource_types/ebs.md
@@ -242,6 +243,7 @@ files:
242
243
  - lib/awspec/generator/doc/type/ami.rb
243
244
  - lib/awspec/generator/doc/type/autoscaling_group.rb
244
245
  - lib/awspec/generator/doc/type/base.rb
246
+ - lib/awspec/generator/doc/type/cloudfront_distribution.rb
245
247
  - lib/awspec/generator/doc/type/cloudwatch_alarm.rb
246
248
  - lib/awspec/generator/doc/type/directconnect_virtual_interface.rb
247
249
  - lib/awspec/generator/doc/type/ebs.rb
@@ -293,6 +295,7 @@ files:
293
295
  - lib/awspec/helper/finder.rb
294
296
  - lib/awspec/helper/finder/ami.rb
295
297
  - lib/awspec/helper/finder/autoscaling.rb
298
+ - lib/awspec/helper/finder/cloudfront.rb
296
299
  - lib/awspec/helper/finder/cloudwatch.rb
297
300
  - lib/awspec/helper/finder/directconnect.rb
298
301
  - lib/awspec/helper/finder/ebs.rb
@@ -324,6 +327,7 @@ files:
324
327
  - lib/awspec/matcher/belong_to_subnet.rb
325
328
  - lib/awspec/matcher/belong_to_vpc.rb
326
329
  - lib/awspec/matcher/have_inline_policy.rb
330
+ - lib/awspec/matcher/have_origin.rb
327
331
  - lib/awspec/matcher/have_private_ip_address.rb
328
332
  - lib/awspec/matcher/have_record_set.rb
329
333
  - lib/awspec/matcher/have_route.rb
@@ -333,6 +337,7 @@ files:
333
337
  - lib/awspec/stub.rb
334
338
  - lib/awspec/stub/ami.rb
335
339
  - lib/awspec/stub/autoscaling_group.rb
340
+ - lib/awspec/stub/cloudfront_distribution.rb
336
341
  - lib/awspec/stub/cloudwatch_alarm.rb
337
342
  - lib/awspec/stub/directconnect_virtual_interface.rb
338
343
  - lib/awspec/stub/duplicated_resource_type.rb
@@ -363,6 +368,7 @@ files:
363
368
  - lib/awspec/type/ami.rb
364
369
  - lib/awspec/type/autoscaling_group.rb
365
370
  - lib/awspec/type/base.rb
371
+ - lib/awspec/type/cloudfront_distribution.rb
366
372
  - lib/awspec/type/cloudwatch_alarm.rb
367
373
  - lib/awspec/type/directconnect_virtual_interface.rb
368
374
  - lib/awspec/type/ebs.rb