awspec 0.12.1 → 0.13.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 285ebaa881bc63d59e64be0062ba5c986af30fad
4
- data.tar.gz: a3e96559203b15ec30373fa7b31e4a6fd191805b
3
+ metadata.gz: f8bcb89202861083c0752985d3f1fb134cf000a0
4
+ data.tar.gz: 9d5e2caa69463851d22ae2d98c6128c08823e857
5
5
  SHA512:
6
- metadata.gz: 88a08d9a0d4b4f95a7833fdda4ee84e59caa236e32f7fc1e679acc48807712c44979c34a3b8471f2b7d362e0c025717bdae751f803228a5e445fd8ee95dbfcae
7
- data.tar.gz: 4d748396a3e146fff94b92d80d92baeafcbdb1e81f4e07b744a3ce7a69f764a698c85ea6d7c5b81a0d0edf43caa5809d83e1fea9ef7d2dfb20cee844a5408518
6
+ metadata.gz: 8f7337502c862ddb03a507996d94e3bce404d91f88c38c9a7c60fda1708b2fd60ed3bf67f0fe51dc2d40f2080cded953556d90e225ddaf32a74fc87cf9df8a35
7
+ data.tar.gz: 7020a396f1a4ac68742ac099f1081b588c70cae17ca51ba05a5ab2c638d53dc73d1584706bf14f42620cad4dc76683a9904670be635e67ce794a8a9083c3250e
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  RSpec tests for your AWS resources.
4
4
 
5
- [Resource Types](doc/resource_types.md)
5
+ [Resource Types](doc/resource_types.md) | [Contributing](doc/contributing.md)
6
6
 
7
7
  ## Installation
8
8
 
@@ -98,33 +98,16 @@ $ awspec generate ec2 vpc-ab123cde >> spec/ec2_spec.rb
98
98
  - [x] IAM Group (`iam_group`)
99
99
  - [x] IAM Role (`iam_role`)
100
100
  - [x] IAM Policy (`iam_policy`)
101
+ - [x] ElastiCache (`elasticache`)
102
+ - [ ] ElastiCache Cache Parameter Group
101
103
 
102
104
  [Resource Types more infomation here](doc/resource_types.md)
103
105
 
104
106
  ### Next..?
105
107
 
106
- - [ ] ElastiCache
107
108
  - [ ] CloudWatch
108
109
  - ...
109
110
 
110
- ## Contributing
111
-
112
- 1. Fork it ( https://github.com/k1LoW/awspec/fork )
113
- 2. Create your feature branch (`git checkout -b my-new-feature`)
114
- 3. Commit your changes (`git commit -am 'Add some feature'`)
115
- 4. Push to the branch (`git push origin my-new-feature`)
116
- 5. Create a new Pull Request
117
-
118
- ### How to add new resource type (ex. Redshift resource)
119
-
120
- 1. Create your feature branch (`git checkout -b add-type-redshift`)
121
- 2. Generate template files (`bundle exec ./lib/awspec/bin/toolbox template redshift`)
122
- 3. Fill files with code.
123
- 4. Generate [doc/resource_types.md](doc/resource_types.md) (`bundle exec ./lib/awspec/bin/toolbox docgen > doc/resource_type.md`)
124
- 5. Run test (`bundle exec rake spec`)
125
- 6. Push to the branch (`git push origin add-type-redshift`)
126
- 7. Create a new Pull Request
127
-
128
111
  ## References
129
112
 
130
113
  awspec is inspired by Serverspec.
@@ -0,0 +1,26 @@
1
+ # Contributing
2
+
3
+ ## Add new resource type (ex. Redshift resource)
4
+
5
+ 1. Create your feature branch (`git checkout -b add-type-redshift`)
6
+ 2. Generate template files (`bundle exec ./lib/awspec/bin/toolbox template redshift`)
7
+ 3. Fill files with code.
8
+ 4. Generate [doc/resource_types.md](doc/resource_types.md) (`bundle exec ./lib/awspec/bin/toolbox docgen > doc/resource_type.md`)
9
+ 5. Run test (`bundle exec rake spec`)
10
+ 6. Push to the branch (`git push origin add-type-redshift`)
11
+ 7. Create a new Pull Request
12
+
13
+ ## Append resource type document (ex. VPC resource `be_available`)
14
+
15
+ 1. Create vpc.md (`touch doc/_resource_types/vpc.md`)
16
+ 2. Write following document.
17
+
18
+ <pre>
19
+ ### be_available
20
+ (Write cool description)
21
+ ```ruby
22
+ describe vpc('my-vpc') do
23
+ it { should be_available }
24
+ end
25
+ ```
26
+ </pre>
@@ -17,6 +17,7 @@
17
17
  | [iam_group](#iam_group)
18
18
  | [iam_role](#iam_role)
19
19
  | [iam_policy](#iam_policy)
20
+ | [elasticache](#elasticache)
20
21
 
21
22
  ## <a name="ec2">ec2</a>
22
23
 
@@ -347,3 +348,36 @@ IamPolicy resource type.
347
348
  ### be_attached_to_user
348
349
 
349
350
  #### its(:policy_name), its(:policy_id), its(:arn), its(:path), its(:default_version_id), its(:attachment_count), its(:is_attachable), its(:description), its(:create_date), its(:update_date)
351
+ ## <a name="elasticache">elasticache</a>
352
+
353
+ Elasticache resource type.
354
+
355
+ ### exist
356
+
357
+ ### be_available
358
+
359
+ ### be_creating
360
+
361
+ ### be_deleted
362
+
363
+ ### be_deleting
364
+
365
+ ### be_incompatible_network
366
+
367
+ ### be_modifying
368
+
369
+ ### be_rebooting_cache_cluster_nodes
370
+
371
+ ### be_restore_failed
372
+
373
+ ### be_snapshotting
374
+
375
+ ### have_cache_parameter_group
376
+
377
+ ### belong_to_cache_subnet_group
378
+
379
+ ### belong_to_replication_group
380
+
381
+ ### belong_to_vpc
382
+
383
+ #### its(:cache_cluster_id), its(:configuration_endpoint), its(:client_download_landing_page), its(:cache_node_type), its(:engine), its(:engine_version), its(:cache_cluster_status), its(:num_cache_nodes), its(:preferred_availability_zone), its(:cache_cluster_create_time), its(:preferred_maintenance_window), its(:notification_configuration), its(:cache_subnet_group_name), its(:auto_minor_version_upgrade), its(:replication_group_id), its(:snapshot_retention_limit), its(:snapshot_window)
@@ -0,0 +1,17 @@
1
+ module Awspec::Generator
2
+ module Doc
3
+ module Type
4
+ class Elasticache < Base
5
+ def initialize
6
+ super
7
+ @type_name = 'Elasticache'
8
+ @type = Awspec::Type::Elasticache.new('my-rep-group-001')
9
+ @ret = @type.resource
10
+ @matchers = %w(belong_to_vpc belong_to_replication_group belong_to_cache_subnet_group)
11
+ @ignore_matchers = []
12
+ @describes = []
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -10,6 +10,7 @@ require 'awspec/helper/finder/ebs'
10
10
  require 'awspec/helper/finder/elb'
11
11
  require 'awspec/helper/finder/lambda'
12
12
  require 'awspec/helper/finder/iam'
13
+ require 'awspec/helper/finder/elasticache'
13
14
 
14
15
  module Awspec::Helper
15
16
  module Finder
@@ -25,6 +26,7 @@ module Awspec::Helper
25
26
  include Awspec::Helper::Finder::Elb
26
27
  include Awspec::Helper::Finder::Lambda
27
28
  include Awspec::Helper::Finder::Iam
29
+ include Awspec::Helper::Finder::Elasticache
28
30
 
29
31
  # rubocop:disable all
30
32
  def initialize(id = nil)
@@ -36,6 +38,7 @@ module Awspec::Helper
36
38
  @elb_client = Aws::ElasticLoadBalancing::Client.new
37
39
  @lambda_client = Aws::Lambda::Client.new
38
40
  @iam_client = Aws::IAM::Client.new
41
+ @elasticache_client = Aws::ElastiCache::Client.new
39
42
  end
40
43
  end
41
44
  end
@@ -0,0 +1,21 @@
1
+ module Awspec::Helper
2
+ module Finder
3
+ module Elasticache
4
+ def find_cache_cluster(id)
5
+ res = @elasticache_client.describe_cache_clusters({
6
+ cache_cluster_id: id
7
+ })
8
+ res[:cache_clusters].first if res[:cache_clusters].count == 1
9
+ rescue
10
+ nil
11
+ end
12
+
13
+ def find_cache_subnet_group(group_name)
14
+ res = @elasticache_client.describe_cache_subnet_groups({
15
+ cache_subnet_group_name: group_name
16
+ })
17
+ res[:cache_subnet_groups].first if res[:cache_subnet_groups].count == 1
18
+ end
19
+ end
20
+ end
21
+ end
@@ -5,7 +5,7 @@ module Awspec
5
5
  base ec2 rds rds_db_parameter_group security_group
6
6
  vpc s3 route53_hosted_zone auto_scaling_group subnet
7
7
  route_table ebs elb lambda iam_user iam_group iam_role
8
- iam_policy
8
+ iam_policy elasticache
9
9
  )
10
10
 
11
11
  TYPES.each do |type|
@@ -19,3 +19,7 @@ require 'awspec/matcher/belong_to_iam_group'
19
19
 
20
20
  # IAM User/Group/Role
21
21
  require 'awspec/matcher/be_allowed_action'
22
+
23
+ # ElastiCache
24
+ require 'awspec/matcher/belong_to_replication_group'
25
+ require 'awspec/matcher/belong_to_cache_subnet_group'
@@ -0,0 +1,5 @@
1
+ RSpec::Matchers.define :belong_to_cache_subnet_group do |cache_subnet_group_name|
2
+ match do |resource|
3
+ return true if resource.resource[:cache_subnet_group_name] == cache_subnet_group_name
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ RSpec::Matchers.define :belong_to_replication_group do |group_id|
2
+ match do |resource|
3
+ # ElastiCache
4
+ resource.resource[:replication_group_id] == group_id
5
+ end
6
+ end
@@ -0,0 +1,77 @@
1
+ Aws.config[:elasticache] = {
2
+ stub_responses: {
3
+ describe_cache_clusters: {
4
+ cache_clusters:
5
+ [
6
+ {
7
+ cache_cluster_id: 'my-rep-group-001',
8
+ configuration_endpoint: nil,
9
+ client_download_landing_page:
10
+ 'https://console.aws.amazon.com/elasticache/home#client-download:',
11
+ cache_node_type: 'cache.m3.medium',
12
+ engine: 'redis',
13
+ engine_version: '2.8.21',
14
+ cache_cluster_status: 'available',
15
+ num_cache_nodes: 1,
16
+ preferred_availability_zone: 'ap-northeast-1b',
17
+ cache_cluster_create_time: Time.new(2015, 1, 2, 10, 00, 00, '+00:00'),
18
+ preferred_maintenance_window: 'wed:15:30-wed:16:30',
19
+ pending_modified_values:
20
+ {
21
+ num_cache_nodes: nil,
22
+ cache_node_ids_to_remove: [],
23
+ engine_version: nil
24
+ },
25
+ notification_configuration: nil,
26
+ cache_security_groups: [],
27
+ cache_parameter_group:
28
+ {
29
+ cache_parameter_group_name: 'my-cache-parameter-group',
30
+ parameter_apply_status: 'in-sync',
31
+ cache_node_ids_to_reboot: []
32
+ },
33
+ cache_subnet_group_name: 'my-cache-subnet-group',
34
+ cache_nodes: [],
35
+ auto_minor_version_upgrade: true,
36
+ security_groups: [
37
+ {
38
+ security_group_id: 'sg-da1bc2ef',
39
+ status: 'active'
40
+ }
41
+ ],
42
+ replication_group_id: 'my-rep-group',
43
+ snapshot_retention_limit: 0,
44
+ snapshot_window: '17:30-18:30'
45
+ }
46
+ ]
47
+ },
48
+ describe_cache_subnet_groups: {
49
+ cache_subnet_groups: [
50
+ {
51
+ cache_subnet_group_name: 'my-cache-subnet-group',
52
+ cache_subnet_group_description: 'stub',
53
+ vpc_id: 'vpc-ab123cde',
54
+ subnets: []
55
+ }
56
+ ]
57
+ }
58
+ }
59
+ }
60
+
61
+ Aws.config[:ec2] = {
62
+ stub_responses: {
63
+ describe_vpcs: {
64
+ vpcs: [
65
+ {
66
+ vpc_id: 'vpc-ab123cde',
67
+ tags: [
68
+ {
69
+ key: 'Name',
70
+ value: 'my-vpc'
71
+ }
72
+ ]
73
+ }
74
+ ]
75
+ }
76
+ }
77
+ }
@@ -0,0 +1,31 @@
1
+ module Awspec::Type
2
+ class Elasticache < Base
3
+ def initialize(id)
4
+ super
5
+ @resource = find_cache_cluster(id)
6
+ @id = @resource[:cache_cluster_id] if @resource
7
+ end
8
+
9
+ states = %w(
10
+ available creating deleted deleting
11
+ incompatible-network modifying
12
+ rebooting-cache-cluster-nodes restore-failed
13
+ snapshotting
14
+ )
15
+
16
+ states.each do |state|
17
+ define_method state.tr('-', '_') + '?' do
18
+ @resource[:cache_cluster_status] == state
19
+ end
20
+ end
21
+
22
+ def has_cache_parameter_group?(group_name)
23
+ @resource[:cache_parameter_group][:cache_parameter_group_name] == group_name
24
+ end
25
+
26
+ def vpc_id
27
+ cache_subnet_group = find_cache_subnet_group(@resource[:cache_subnet_group_name])
28
+ cache_subnet_group[:vpc_id] if cache_subnet_group
29
+ end
30
+ end
31
+ end
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '0.12.1'
2
+ VERSION = '0.13.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.12.1
4
+ version: 0.13.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-09-16 00:00:00.000000000 Z
11
+ date: 2015-09-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -163,6 +163,7 @@ files:
163
163
  - doc/_resource_types/lambda.md
164
164
  - doc/_resource_types/rds_db_parameter_group.md
165
165
  - doc/_resource_types/security_group.md
166
+ - doc/contributing.md
166
167
  - doc/resource_types.md
167
168
  - lib/awspec.rb
168
169
  - lib/awspec/bin/toolbox
@@ -176,6 +177,7 @@ files:
176
177
  - lib/awspec/generator/doc/type/base.rb
177
178
  - lib/awspec/generator/doc/type/ebs.rb
178
179
  - lib/awspec/generator/doc/type/ec2.rb
180
+ - lib/awspec/generator/doc/type/elasticache.rb
179
181
  - lib/awspec/generator/doc/type/elb.rb
180
182
  - lib/awspec/generator/doc/type/iam_group.rb
181
183
  - lib/awspec/generator/doc/type/iam_policy.rb
@@ -203,6 +205,7 @@ files:
203
205
  - lib/awspec/helper/finder/auto_scaling.rb
204
206
  - lib/awspec/helper/finder/ebs.rb
205
207
  - lib/awspec/helper/finder/ec2.rb
208
+ - lib/awspec/helper/finder/elasticache.rb
206
209
  - lib/awspec/helper/finder/elb.rb
207
210
  - lib/awspec/helper/finder/iam.rb
208
211
  - lib/awspec/helper/finder/lambda.rb
@@ -215,8 +218,10 @@ files:
215
218
  - lib/awspec/matcher.rb
216
219
  - lib/awspec/matcher/be_allowed_action.rb
217
220
  - lib/awspec/matcher/be_opened.rb
221
+ - lib/awspec/matcher/belong_to_cache_subnet_group.rb
218
222
  - lib/awspec/matcher/belong_to_db_subnet_group.rb
219
223
  - lib/awspec/matcher/belong_to_iam_group.rb
224
+ - lib/awspec/matcher/belong_to_replication_group.rb
220
225
  - lib/awspec/matcher/belong_to_subnet.rb
221
226
  - lib/awspec/matcher/belong_to_vpc.rb
222
227
  - lib/awspec/matcher/have_record_set.rb
@@ -226,6 +231,7 @@ files:
226
231
  - lib/awspec/stub/auto_scaling_group.rb
227
232
  - lib/awspec/stub/ebs.rb
228
233
  - lib/awspec/stub/ec2.rb
234
+ - lib/awspec/stub/elasticache.rb
229
235
  - lib/awspec/stub/elb.rb
230
236
  - lib/awspec/stub/iam_group.rb
231
237
  - lib/awspec/stub/iam_policy.rb
@@ -245,6 +251,7 @@ files:
245
251
  - lib/awspec/type/base.rb
246
252
  - lib/awspec/type/ebs.rb
247
253
  - lib/awspec/type/ec2.rb
254
+ - lib/awspec/type/elasticache.rb
248
255
  - lib/awspec/type/elb.rb
249
256
  - lib/awspec/type/iam_group.rb
250
257
  - lib/awspec/type/iam_policy.rb