awspec 0.71.0 → 0.72.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/doc/_resource_types/dynamodb_table.md +52 -0
- data/doc/resource_types.md +56 -0
- data/lib/awspec/command/generate.rb +1 -0
- data/lib/awspec/generator.rb +1 -0
- data/lib/awspec/generator/doc/type/dynamodb_table.rb +19 -0
- data/lib/awspec/generator/spec/acm.rb +27 -0
- data/lib/awspec/helper/finder.rb +4 -1
- data/lib/awspec/helper/finder/acm.rb +8 -0
- data/lib/awspec/helper/finder/dynamodb.rb +10 -0
- data/lib/awspec/helper/type.rb +1 -1
- data/lib/awspec/matcher.rb +4 -0
- data/lib/awspec/matcher/have_attribute_definition.rb +9 -0
- data/lib/awspec/matcher/have_key_schema.rb +9 -0
- data/lib/awspec/stub/dynamodb_table.rb +34 -0
- data/lib/awspec/type/dynamodb_table.rb +40 -0
- data/lib/awspec/version.rb +1 -1
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5371ca2443a738e61ee579d50fdf545bffc2945e
|
4
|
+
data.tar.gz: ae9a493ee4de0d9e3018aaa9f27418dfaa373b4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 468a0bd1edeb9fb36c3c4692e8466843a787cb600482738da645574a5bdd7a2748d16b00309062e78b9ab9aefa1392dcc5efef7fae2b68a5321e02196a9fc9e3
|
7
|
+
data.tar.gz: cf7146d314306504268dd344e1f4d5094a06183e1eae552b464b05770531699b59cb9d77fd553afd8612c09637f26d87f6ee90394ad459e231a5648b00886c43
|
@@ -0,0 +1,52 @@
|
|
1
|
+
### exist
|
2
|
+
|
3
|
+
```ruby
|
4
|
+
describe dynamodb_table('my-dynamodb-table') do
|
5
|
+
it { should exist }
|
6
|
+
end
|
7
|
+
```
|
8
|
+
|
9
|
+
### be_active
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
describe dynamodb_table('my-dynamodb-table') do
|
13
|
+
it { should be_active }
|
14
|
+
end
|
15
|
+
```
|
16
|
+
|
17
|
+
### have_attribute_definition
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
describe dynamodb_table('my-dynamodb-table') do
|
21
|
+
it { should have_attribute_definition('my-dynamodb-table-attaribute1').attribute_type('S') }
|
22
|
+
it { should have_attribute_definition('my-dynamodb-table-attaribute2').attribute_type('N') }
|
23
|
+
end
|
24
|
+
```
|
25
|
+
|
26
|
+
### have_key_schema
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
describe dynamodb_table('my-dynamodb-table') do
|
30
|
+
it { should have_key_schema('my-dynamodb-table-key_schema1').key_type('HASH') }
|
31
|
+
it { should have_key_schema('my-dynamodb-table-key_schema2').key_type('RANGE') }
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
### advanced
|
36
|
+
|
37
|
+
`dynamodb_table` can use `Aws::DynamoDB::Table` resource (see http://docs.aws.amazon.com/sdkforruby/api/Aws/DynamoDB/Table.html).
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
describe dynamodb_table('my-dynamodb-table') do
|
41
|
+
its('key_schema.first.key_type') { should eq 'HASH' }
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
or
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
describe dynamodb_table('my-dynamodb-table') do
|
49
|
+
its('resource.key_schema.first.key_type') { should eq 'HASH' }
|
50
|
+
end
|
51
|
+
```
|
52
|
+
|
data/doc/resource_types.md
CHANGED
@@ -11,6 +11,7 @@
|
|
11
11
|
| [cloudwatch_logs](#cloudwatch_logs)
|
12
12
|
| [customer_gateway](#customer_gateway)
|
13
13
|
| [directconnect_virtual_interface](#directconnect_virtual_interface)
|
14
|
+
| [dynamodb_table](#dynamodb_table)
|
14
15
|
| [ebs](#ebs)
|
15
16
|
| [ec2](#ec2)
|
16
17
|
| [ecr_repository](#ecr_repository)
|
@@ -2294,6 +2295,61 @@ end
|
|
2294
2295
|
```
|
2295
2296
|
|
2296
2297
|
### its(:log_group_name), its(:creation_time), its(:retention_in_days), its(:metric_filter_count), its(:arn), its(:stored_bytes)
|
2298
|
+
## <a name="dynamodb_table">dynamodb_table</a>
|
2299
|
+
|
2300
|
+
DynamodbTable resource type.
|
2301
|
+
|
2302
|
+
### exist
|
2303
|
+
|
2304
|
+
```ruby
|
2305
|
+
describe dynamodb_table('my-dynamodb-table') do
|
2306
|
+
it { should exist }
|
2307
|
+
end
|
2308
|
+
```
|
2309
|
+
|
2310
|
+
|
2311
|
+
### be_creating, be_updating, be_deleting, be_active
|
2312
|
+
|
2313
|
+
### have_attribute_definition
|
2314
|
+
|
2315
|
+
```ruby
|
2316
|
+
describe dynamodb_table('my-dynamodb-table') do
|
2317
|
+
it { should have_attribute_definition('my-dynamodb-table-attaribute1').attribute_type('S') }
|
2318
|
+
it { should have_attribute_definition('my-dynamodb-table-attaribute2').attribute_type('N') }
|
2319
|
+
end
|
2320
|
+
```
|
2321
|
+
|
2322
|
+
|
2323
|
+
### have_key_schema
|
2324
|
+
|
2325
|
+
```ruby
|
2326
|
+
describe dynamodb_table('my-dynamodb-table') do
|
2327
|
+
it { should have_key_schema('my-dynamodb-table-key_schema1').key_type('HASH') }
|
2328
|
+
it { should have_key_schema('my-dynamodb-table-key_schema2').key_type('RANGE') }
|
2329
|
+
end
|
2330
|
+
```
|
2331
|
+
|
2332
|
+
|
2333
|
+
### its(:table_name), its(:table_status), its(:creation_date_time), its(:table_size_bytes), its(:item_count), its(:table_arn), its(:local_secondary_indexes), its(:global_secondary_indexes), its(:stream_specification), its(:latest_stream_label), its(:latest_stream_arn)
|
2334
|
+
### :unlock: Advanced use
|
2335
|
+
|
2336
|
+
`dynamodb_table` can use `Aws::DynamoDB::Table` resource (see http://docs.aws.amazon.com/sdkforruby/api/Aws/DynamoDB/Table.html).
|
2337
|
+
|
2338
|
+
```ruby
|
2339
|
+
describe dynamodb_table('my-dynamodb-table') do
|
2340
|
+
its('key_schema.first.key_type') { should eq 'HASH' }
|
2341
|
+
end
|
2342
|
+
```
|
2343
|
+
|
2344
|
+
or
|
2345
|
+
|
2346
|
+
```ruby
|
2347
|
+
describe dynamodb_table('my-dynamodb-table') do
|
2348
|
+
its('resource.key_schema.first.key_type') { should eq 'HASH' }
|
2349
|
+
end
|
2350
|
+
```
|
2351
|
+
|
2352
|
+
|
2297
2353
|
# Account and Attributes
|
2298
2354
|
|
2299
2355
|
## <a name="account">account</a>
|
data/lib/awspec/generator.rb
CHANGED
@@ -22,6 +22,7 @@ require 'awspec/generator/spec/network_interface'
|
|
22
22
|
require 'awspec/generator/spec/iam_user'
|
23
23
|
require 'awspec/generator/spec/iam_group'
|
24
24
|
require 'awspec/generator/spec/iam_role'
|
25
|
+
require 'awspec/generator/spec/acm'
|
25
26
|
|
26
27
|
# Doc
|
27
28
|
require 'awspec/generator/doc/type'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Doc
|
3
|
+
module Type
|
4
|
+
class DynamodbTable < Base
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@type_name = 'DynamodbTable'
|
8
|
+
@type = Awspec::Type::DynamodbTable.new('my-dynamodb-table')
|
9
|
+
@ret = @type.resource_via_client
|
10
|
+
@matchers = [
|
11
|
+
Awspec::Type::DynamodbTable::STATUSES.map { |status| 'be_' + status.downcase }.join(', ')
|
12
|
+
]
|
13
|
+
@ignore_matchers = Awspec::Type::DynamodbTable::STATUSES.map { |status| 'be_' + status.downcase }
|
14
|
+
@describes = []
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Spec
|
3
|
+
class Acm
|
4
|
+
include Awspec::Helper::Finder
|
5
|
+
def generate_all
|
6
|
+
certificates = select_all_certificates
|
7
|
+
raise 'Not Found Certificates' if certificates.empty?
|
8
|
+
ERB.new(acm_spec_template, nil, '-').result(binding).chomp
|
9
|
+
end
|
10
|
+
|
11
|
+
def acm_spec_template
|
12
|
+
template = <<-'EOF'
|
13
|
+
<% certificates.each do |certificate| %>
|
14
|
+
describe acm('<%= certificate.domain_name %>') do
|
15
|
+
it { should exist }
|
16
|
+
<%- if certificate.status == 'ISSUED' -%>
|
17
|
+
it { should be_issued }
|
18
|
+
<% end -%>
|
19
|
+
its(:type) { should eq '<%= certificate.type %>' }
|
20
|
+
end
|
21
|
+
<% end %>
|
22
|
+
EOF
|
23
|
+
template
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/awspec/helper/finder.rb
CHANGED
@@ -29,6 +29,7 @@ require 'awspec/helper/finder/cloudtrail'
|
|
29
29
|
require 'awspec/helper/finder/waf'
|
30
30
|
require 'awspec/helper/finder/acm'
|
31
31
|
require 'awspec/helper/finder/cloudwatch_logs'
|
32
|
+
require 'awspec/helper/finder/dynamodb'
|
32
33
|
|
33
34
|
require 'awspec/helper/finder/account_attributes'
|
34
35
|
|
@@ -65,6 +66,7 @@ module Awspec::Helper
|
|
65
66
|
include Awspec::Helper::Finder::Acm
|
66
67
|
include Awspec::Helper::Finder::AccountAttributes
|
67
68
|
include Awspec::Helper::Finder::CloudwatchLogs
|
69
|
+
include Awspec::Helper::Finder::Dynamodb
|
68
70
|
|
69
71
|
CLIENTS = {
|
70
72
|
ec2_client: Aws::EC2::Client,
|
@@ -92,7 +94,8 @@ module Awspec::Helper
|
|
92
94
|
waf_client: Aws::WAF::Client,
|
93
95
|
sts_client: Aws::STS::Client,
|
94
96
|
acm_client: Aws::ACM::Client,
|
95
|
-
cloudwatch_logs_client: Aws::CloudWatchLogs::Client
|
97
|
+
cloudwatch_logs_client: Aws::CloudWatchLogs::Client,
|
98
|
+
dynamodb_client: Aws::DynamoDB::Client
|
96
99
|
}
|
97
100
|
|
98
101
|
CLIENTS.each do |method_name, client|
|
@@ -5,6 +5,14 @@ module Awspec::Helper
|
|
5
5
|
cert = acm_client.list_certificates.certificate_summary_list.find { |c| c[:domain_name] == domain }
|
6
6
|
acm_client.describe_certificate({ certificate_arn: cert.certificate_arn }).certificate
|
7
7
|
end
|
8
|
+
|
9
|
+
def select_all_certificates
|
10
|
+
certificates = []
|
11
|
+
acm_client.list_certificates.certificate_summary_list.each do |cert|
|
12
|
+
certificates << acm_client.describe_certificate({ certificate_arn: cert.certificate_arn }).certificate
|
13
|
+
end
|
14
|
+
certificates
|
15
|
+
end
|
8
16
|
end
|
9
17
|
end
|
10
18
|
end
|
data/lib/awspec/helper/type.rb
CHANGED
@@ -15,7 +15,7 @@ module Awspec
|
|
15
15
|
network_acl network_interface rds rds_db_cluster_parameter_group rds_db_parameter_group route53_hosted_zone
|
16
16
|
route_table s3_bucket security_group ses_identity subnet vpc cloudfront_distribution
|
17
17
|
elastictranscoder_pipeline waf_web_acl customer_gateway vpn_gateway vpn_connection internet_gateway acm
|
18
|
-
cloudwatch_logs
|
18
|
+
cloudwatch_logs dynamodb_table
|
19
19
|
)
|
20
20
|
|
21
21
|
ACCOUNT_ATTRIBUTES = %w(
|
data/lib/awspec/matcher.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
Aws.config[:dynamodb] = {
|
2
|
+
stub_responses: {
|
3
|
+
describe_table: {
|
4
|
+
table: {
|
5
|
+
table_name: 'my-dynamodb-table',
|
6
|
+
table_status: 'ACTIVE',
|
7
|
+
provisioned_throughput: {
|
8
|
+
read_capacity_units: 1,
|
9
|
+
write_capacity_units: 1
|
10
|
+
},
|
11
|
+
attribute_definitions: [
|
12
|
+
{
|
13
|
+
attribute_name: 'my-dynamodb-table-attaribute1',
|
14
|
+
attribute_type: 'S'
|
15
|
+
},
|
16
|
+
{
|
17
|
+
attribute_name: 'my-dynamodb-table-attaribute2',
|
18
|
+
attribute_type: 'N'
|
19
|
+
}
|
20
|
+
],
|
21
|
+
key_schema: [
|
22
|
+
{
|
23
|
+
attribute_name: 'my-dynamodb-table-key_schema1',
|
24
|
+
key_type: 'HASH'
|
25
|
+
},
|
26
|
+
{
|
27
|
+
attribute_name: 'my-dynamodb-table-key_schema2',
|
28
|
+
key_type: 'RANGE'
|
29
|
+
}
|
30
|
+
]
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Awspec::Type
|
2
|
+
class DynamodbTable < ResourceBase
|
3
|
+
aws_resource Aws::DynamoDB::Table
|
4
|
+
|
5
|
+
def resource_via_client
|
6
|
+
@resource_via_client ||= find_dynamodb_table(@display_name)
|
7
|
+
end
|
8
|
+
|
9
|
+
def id
|
10
|
+
@id ||= resource_via_client.table_name if resource_via_client
|
11
|
+
end
|
12
|
+
|
13
|
+
STATUSES = %w(
|
14
|
+
CREATING
|
15
|
+
UPDATING
|
16
|
+
DELETING
|
17
|
+
ACTIVE
|
18
|
+
)
|
19
|
+
|
20
|
+
STATUSES.each do |status|
|
21
|
+
define_method status.downcase + '?' do
|
22
|
+
resource_via_client.table_status == status
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def has_attribute_definition?(name, type)
|
27
|
+
ret = resource_via_client.attribute_definitions.select { |a| a.attribute_name == name }
|
28
|
+
return false if ret.empty?
|
29
|
+
return false unless ret.single_resource.attribute_type == type
|
30
|
+
return true if ret.single_resource.attribute_name == name
|
31
|
+
end
|
32
|
+
|
33
|
+
def has_key_schema?(name, type)
|
34
|
+
ret = resource_via_client.key_schema.select { |k| k.attribute_name == name }
|
35
|
+
return false if ret.empty?
|
36
|
+
return false unless ret.single_resource.key_type == type
|
37
|
+
return true if ret.single_resource.attribute_name == name
|
38
|
+
end
|
39
|
+
end
|
40
|
+
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.72.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-03-
|
11
|
+
date: 2017-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -216,6 +216,7 @@ files:
|
|
216
216
|
- doc/_resource_types/cloudwatch_logs.md
|
217
217
|
- doc/_resource_types/customer_gateway.md
|
218
218
|
- doc/_resource_types/directconnect_virtual_interface.md
|
219
|
+
- doc/_resource_types/dynamodb_table.md
|
219
220
|
- doc/_resource_types/ebs.md
|
220
221
|
- doc/_resource_types/ec2.md
|
221
222
|
- doc/_resource_types/ec2_account_attributes.md
|
@@ -284,6 +285,7 @@ files:
|
|
284
285
|
- lib/awspec/generator/doc/type/cloudwatch_logs.rb
|
285
286
|
- lib/awspec/generator/doc/type/customer_gateway.rb
|
286
287
|
- lib/awspec/generator/doc/type/directconnect_virtual_interface.rb
|
288
|
+
- lib/awspec/generator/doc/type/dynamodb_table.rb
|
287
289
|
- lib/awspec/generator/doc/type/ebs.rb
|
288
290
|
- lib/awspec/generator/doc/type/ec2.rb
|
289
291
|
- lib/awspec/generator/doc/type/ec2_account_attributes.rb
|
@@ -325,6 +327,7 @@ files:
|
|
325
327
|
- lib/awspec/generator/doc/type/vpn_connection.rb
|
326
328
|
- lib/awspec/generator/doc/type/vpn_gateway.rb
|
327
329
|
- lib/awspec/generator/doc/type/waf_web_acl.rb
|
330
|
+
- lib/awspec/generator/spec/acm.rb
|
328
331
|
- lib/awspec/generator/spec/cloudwatch_alarm.rb
|
329
332
|
- lib/awspec/generator/spec/cloudwatch_event.rb
|
330
333
|
- lib/awspec/generator/spec/directconnect.rb
|
@@ -364,6 +367,7 @@ files:
|
|
364
367
|
- lib/awspec/helper/finder/cloudwatch_event.rb
|
365
368
|
- lib/awspec/helper/finder/cloudwatch_logs.rb
|
366
369
|
- lib/awspec/helper/finder/directconnect.rb
|
370
|
+
- lib/awspec/helper/finder/dynamodb.rb
|
367
371
|
- lib/awspec/helper/finder/ebs.rb
|
368
372
|
- lib/awspec/helper/finder/ec2.rb
|
369
373
|
- lib/awspec/helper/finder/ecr.rb
|
@@ -399,8 +403,10 @@ files:
|
|
399
403
|
- lib/awspec/matcher/belong_to_replication_group.rb
|
400
404
|
- lib/awspec/matcher/belong_to_subnet.rb
|
401
405
|
- lib/awspec/matcher/belong_to_vpc.rb
|
406
|
+
- lib/awspec/matcher/have_attribute_definition.rb
|
402
407
|
- lib/awspec/matcher/have_inline_policy.rb
|
403
408
|
- lib/awspec/matcher/have_key_policy.rb
|
409
|
+
- lib/awspec/matcher/have_key_schema.rb
|
404
410
|
- lib/awspec/matcher/have_network_interface.rb
|
405
411
|
- lib/awspec/matcher/have_origin.rb
|
406
412
|
- lib/awspec/matcher/have_private_ip_address.rb
|
@@ -426,6 +432,7 @@ files:
|
|
426
432
|
- lib/awspec/stub/customer_gateway.rb
|
427
433
|
- lib/awspec/stub/directconnect_virtual_interface.rb
|
428
434
|
- lib/awspec/stub/duplicated_resource_type.rb
|
435
|
+
- lib/awspec/stub/dynamodb_table.rb
|
429
436
|
- lib/awspec/stub/ebs.rb
|
430
437
|
- lib/awspec/stub/ec2.rb
|
431
438
|
- lib/awspec/stub/ec2_has_multi_security_groups.rb
|
@@ -481,6 +488,7 @@ files:
|
|
481
488
|
- lib/awspec/type/cloudwatch_logs.rb
|
482
489
|
- lib/awspec/type/customer_gateway.rb
|
483
490
|
- lib/awspec/type/directconnect_virtual_interface.rb
|
491
|
+
- lib/awspec/type/dynamodb_table.rb
|
484
492
|
- lib/awspec/type/ebs.rb
|
485
493
|
- lib/awspec/type/ec2.rb
|
486
494
|
- lib/awspec/type/ec2_account_attributes.rb
|