awspec 0.29.0 → 0.30.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: 6103e00c3f0aa3f83d1c10e09d1ca8a5a5c918ac
4
- data.tar.gz: 653840c203951bbeec134d9f896fca01949a5b75
3
+ metadata.gz: 6a905721558237afba127319af4db1276f903347
4
+ data.tar.gz: 13acb88e7253a96c4bd8eb23afea29c5fb934c37
5
5
  SHA512:
6
- metadata.gz: 20a641e7724963fdc0898ceaebf578f2c4ea2c92581e8bb951bce565f878ae3afc117f0d1485ab06025f2176fc0cf157caf68723b73b15072fef7d93791ddfe2
7
- data.tar.gz: 2c2d5d47471aa4934285029bdccea1d85f3461282e8d6ef9682420b84006a7af7b5321693d802d8b37732ff6b932fc5763d3ae3b2ecbf98c07980527a81c3822
6
+ metadata.gz: d5af22547903d27edce8b88bba5b627578ba1b5e1d0783d549bb48e024e3a30e8aaedd61ea922685155009f9c9143791e84784f6dc6731990102b1578baa1542
7
+ data.tar.gz: 74fbb35e7cb25517623416b245e48fea042c381356960562f63ec387a6f2eb6e2a3f72e8496e0884796635fe93ddffe0a72a721cbd5d06a132ede3571509811e
@@ -0,0 +1,19 @@
1
+ ### exist
2
+
3
+ ```ruby
4
+ describe ami('my-ami') do
5
+ it { should exist }
6
+ end
7
+ ```
8
+
9
+ ### be_pending, be_available, be_invalid, be_deregistered, be_transient, be_failed, be_error
10
+
11
+ ```ruby
12
+ describe ami('my-ami') do
13
+ it { should be_available }
14
+ end
15
+ ```
16
+
17
+ ### advanced
18
+
19
+ `ami` can use `Aws::EC2::Image` resource (see http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Image.html).
@@ -14,14 +14,6 @@ describe ec2('my-ec2') do
14
14
  end
15
15
  ```
16
16
 
17
- ### be_pending
18
-
19
- ```ruby
20
- describe ec2('my-ec2') do
21
- it { should be_pending }
22
- end
23
- ```
24
-
25
17
  ### be_pending, be_running, be_shutting_down, be_terminated, be_stopping, be_stopped
26
18
 
27
19
  ```ruby
@@ -1,6 +1,7 @@
1
1
  # Resource Types
2
2
 
3
- [autoscaling_group](#autoscaling_group)
3
+ [ami](#ami)
4
+ | [autoscaling_group](#autoscaling_group)
4
5
  | [cloudwatch_alarm](#cloudwatch_alarm)
5
6
  | [directconnect_virtual_interface](#directconnect_virtual_interface)
6
7
  | [ebs](#ebs)
@@ -26,6 +27,33 @@
26
27
  | [subnet](#subnet)
27
28
  | [vpc](#vpc)
28
29
 
30
+ ## <a name="ami">ami</a>
31
+
32
+ AMI resource type.
33
+
34
+ ### exist
35
+
36
+ ```ruby
37
+ describe ami('my-ami') do
38
+ it { should exist }
39
+ end
40
+ ```
41
+
42
+
43
+ ### be_pending, be_available, be_invalid, be_deregistered, be_transient, be_failed, be_error
44
+
45
+ ```ruby
46
+ describe ami('my-ami') do
47
+ it { should be_available }
48
+ end
49
+ ```
50
+
51
+
52
+ ### its(:image_id), its(:image_location), its(:state), its(:owner_id), its(:creation_date), its(:public), its(:architecture), its(:image_type), its(:kernel_id), its(:ramdisk_id), its(:platform), its(:sriov_net_support), its(:state_reason), its(:image_owner_alias), its(:name), its(:description), its(:root_device_type), its(:root_device_name), its(:virtualization_type), its(:hypervisor)
53
+ ### :unlock: Advanced use
54
+
55
+ `ami` can use `Aws::EC2::Image` resource (see http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Image.html).
56
+
29
57
  ## <a name="autoscaling_group">autoscaling_group</a>
30
58
 
31
59
  AutoscalingGroup resource type.
@@ -0,0 +1,19 @@
1
+ module Awspec::Generator
2
+ module Doc
3
+ module Type
4
+ class Ami < Base
5
+ def initialize
6
+ super
7
+ @type_name = 'AMI'
8
+ @type = Awspec::Type::Ami.new('my-ami')
9
+ @ret = @type.resource_via_client
10
+ @matchers = [
11
+ Awspec::Type::Ami::STATES.map { |state| 'be_' + state }.join(', ')
12
+ ]
13
+ @ignore_matchers = Awspec::Type::Ami::STATES.map { |state| 'be_' + state.tr('-', '_') }
14
+ @describes = []
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -14,6 +14,7 @@ require 'awspec/helper/finder/elasticache'
14
14
  require 'awspec/helper/finder/cloudwatch'
15
15
  require 'awspec/helper/finder/ses'
16
16
  require 'awspec/helper/finder/directconnect'
17
+ require 'awspec/helper/finder/ami'
17
18
 
18
19
  module Awspec::Helper
19
20
  module Finder
@@ -32,6 +33,7 @@ module Awspec::Helper
32
33
  include Awspec::Helper::Finder::Cloudwatch
33
34
  include Awspec::Helper::Finder::Ses
34
35
  include Awspec::Helper::Finder::Directconnect
36
+ include Awspec::Helper::Finder::Ami
35
37
 
36
38
  CLIENTS = {
37
39
  ec2_client: Aws::EC2::Client,
@@ -0,0 +1,20 @@
1
+ module Awspec::Helper
2
+ module Finder
3
+ module Ami
4
+ def find_ami(image_id)
5
+ res = ec2_client.describe_images({
6
+ filters: [{ name: 'image-id', values: [image_id] }]
7
+ })
8
+ return res[:images].first if res[:images].count == 1
9
+ res = ec2_client.describe_images({
10
+ filters: [{ name: 'name', values: [image_id] }]
11
+ })
12
+ return res[:images].first if res[:images].count == 1
13
+ res = ec2_client.describe_images({
14
+ filters: [{ name: 'tag:Name', values: [image_id] }]
15
+ })
16
+ return res[:images].first if res[:images].count == 1
17
+ end
18
+ end
19
+ end
20
+ end
@@ -4,7 +4,7 @@ module Awspec
4
4
  require 'awspec/type/base'
5
5
 
6
6
  TYPES = %w(
7
- autoscaling_group cloudwatch_alarm directconnect_virtual_interface
7
+ ami autoscaling_group cloudwatch_alarm directconnect_virtual_interface
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 rds rds_db_parameter_group route53_hosted_zone route_table
@@ -25,8 +25,9 @@ module Awspec
25
25
  create|delete|put|update|add|
26
26
  attach|detach|
27
27
  reboot|start|stop|terminate|
28
- modify|reset|replace
29
- authorize|revoke
28
+ modify|reset|replace|
29
+ authorize|revoke|
30
+ deregister
30
31
  /ix
31
32
 
32
33
  def match_black_list?(name)
@@ -0,0 +1,53 @@
1
+ Aws.config[:ec2] = {
2
+ stub_responses: {
3
+ describe_images: {
4
+ images: [
5
+ {
6
+ image_id: 'ami-82640282',
7
+ image_location:
8
+ 'aws-marketplace/CentOS Linux 6 x86_64 20150928_0-74e73035-3435-48d6-88e0-89cc02ad83ee-ami-2b35794e.2',
9
+ state: 'available',
10
+ owner_id: '123456789012',
11
+ creation_date: '2015-10-13T23:00:25.000Z',
12
+ public: true,
13
+ product_codes: [
14
+ {
15
+ product_code_id: 'abcdefghijklmn01234567890',
16
+ product_code_type: 'marketplace'
17
+ }
18
+ ],
19
+ architecture: 'x86_64',
20
+ image_type: 'machine',
21
+ kernel_id: nil,
22
+ ramdisk_id: nil,
23
+ platform: nil,
24
+ sriov_net_support: nil,
25
+ state_reason: nil,
26
+ image_owner_alias: 'aws-marketplace',
27
+ name: 'my-ami',
28
+ description: 'CentOS Linux 6 x86_64 HVM EBS 20150928_01',
29
+ root_device_type: 'ebs',
30
+ root_device_name: '/dev/sda1',
31
+ block_device_mappings: [
32
+ {
33
+ virtual_name: nil,
34
+ device_name: '/dev/sda1',
35
+ ebs: {
36
+ snapshot_id: 'snap-be484c23',
37
+ volume_size: 8,
38
+ delete_on_termination: false,
39
+ volume_type: 'standard',
40
+ iops: nil,
41
+ encrypted: false
42
+ },
43
+ no_device: nil
44
+ }
45
+ ],
46
+ virtualization_type: 'hvm',
47
+ tags: [],
48
+ hypervisor: 'xen'
49
+ }
50
+ ]
51
+ }
52
+ }
53
+ }
@@ -0,0 +1,22 @@
1
+ module Awspec::Type
2
+ class Ami < Base
3
+ aws_resource Aws::EC2::Image
4
+
5
+ def initialize(id)
6
+ super
7
+ @resource_via_client = find_ami(id)
8
+ @id = @resource_via_client[:image_id] if @resource_via_client
9
+ end
10
+
11
+ STATES = %w(
12
+ pending available invalid deregistered
13
+ transient failed error
14
+ )
15
+
16
+ STATES.each do |state|
17
+ define_method state + '?' do
18
+ @resource_via_client[:state] == state
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '0.29.0'
2
+ VERSION = '0.30.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.29.0
4
+ version: 0.30.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-24 00:00:00.000000000 Z
11
+ date: 2016-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -200,6 +200,7 @@ files:
200
200
  - bin/console
201
201
  - bin/setup
202
202
  - bin/toolbox
203
+ - doc/_resource_types/ami.md
203
204
  - doc/_resource_types/autoscaling_group.md
204
205
  - doc/_resource_types/cloudwatch_alarm.md
205
206
  - doc/_resource_types/directconnect_virtual_interface.md
@@ -235,6 +236,7 @@ files:
235
236
  - lib/awspec/ext/struct.rb
236
237
  - lib/awspec/generator.rb
237
238
  - lib/awspec/generator/doc/type.rb
239
+ - lib/awspec/generator/doc/type/ami.rb
238
240
  - lib/awspec/generator/doc/type/autoscaling_group.rb
239
241
  - lib/awspec/generator/doc/type/base.rb
240
242
  - lib/awspec/generator/doc/type/cloudwatch_alarm.rb
@@ -281,6 +283,7 @@ files:
281
283
  - lib/awspec/helper/color.rb
282
284
  - lib/awspec/helper/credentials_loader.rb
283
285
  - lib/awspec/helper/finder.rb
286
+ - lib/awspec/helper/finder/ami.rb
284
287
  - lib/awspec/helper/finder/autoscaling.rb
285
288
  - lib/awspec/helper/finder/cloudwatch.rb
286
289
  - lib/awspec/helper/finder/directconnect.rb
@@ -314,6 +317,7 @@ files:
314
317
  - lib/awspec/resource_reader.rb
315
318
  - lib/awspec/setup.rb
316
319
  - lib/awspec/stub.rb
320
+ - lib/awspec/stub/ami.rb
317
321
  - lib/awspec/stub/autoscaling_group.rb
318
322
  - lib/awspec/stub/cloudwatch_alarm.rb
319
323
  - lib/awspec/stub/directconnect_virtual_interface.rb
@@ -340,6 +344,7 @@ files:
340
344
  - lib/awspec/stub/subnet.rb
341
345
  - lib/awspec/stub/vpc.rb
342
346
  - lib/awspec/toolbox.rb
347
+ - lib/awspec/type/ami.rb
343
348
  - lib/awspec/type/autoscaling_group.rb
344
349
  - lib/awspec/type/base.rb
345
350
  - lib/awspec/type/cloudwatch_alarm.rb