awspec 0.22.1 → 0.23.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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -0
  3. data/doc/_resource_types/autoscaling_group.md +23 -0
  4. data/doc/_resource_types/cloudwatch_alarm.md +39 -0
  5. data/doc/_resource_types/directconnect_virtual_interface.md +30 -0
  6. data/doc/_resource_types/ebs.md +23 -0
  7. data/doc/_resource_types/ec2.md +61 -1
  8. data/doc/_resource_types/elasticache.md +47 -0
  9. data/doc/_resource_types/elasticache_cache_parameter_group.md +8 -0
  10. data/doc/_resource_types/elb.md +40 -0
  11. data/doc/_resource_types/iam_group.md +24 -0
  12. data/doc/_resource_types/iam_policy.md +39 -0
  13. data/doc/_resource_types/iam_role.md +16 -0
  14. data/doc/_resource_types/iam_user.md +24 -0
  15. data/doc/_resource_types/lambda.md +8 -0
  16. data/doc/_resource_types/network_acl.md +23 -2
  17. data/doc/_resource_types/rds.md +66 -0
  18. data/doc/_resource_types/rds_db_parameter_group.md +7 -0
  19. data/doc/_resource_types/route53_hosted_zone.md +25 -0
  20. data/doc/_resource_types/route_table.md +16 -0
  21. data/doc/_resource_types/s3.md +27 -0
  22. data/doc/_resource_types/security_group.md +8 -0
  23. data/doc/_resource_types/ses_identity.md +17 -0
  24. data/doc/_resource_types/subnet.md +15 -0
  25. data/doc/_resource_types/vpc.md +33 -0
  26. data/doc/resource_types.md +519 -72
  27. data/lib/awspec/generator/doc/type/directconnect_virtual_interface.rb +6 -2
  28. data/lib/awspec/generator/doc/type/ebs.rb +4 -2
  29. data/lib/awspec/generator/doc/type/ec2.rb +6 -2
  30. data/lib/awspec/generator/doc/type/elasticache.rb +7 -2
  31. data/lib/awspec/generator/doc/type/elb.rb +1 -1
  32. data/lib/awspec/generator/doc/type/network_acl.rb +4 -1
  33. data/lib/awspec/generator/doc/type/rds.rb +7 -2
  34. data/lib/awspec/generator/doc/type/s3.rb +1 -1
  35. data/lib/awspec/generator/doc/type/subnet.rb +4 -2
  36. data/lib/awspec/generator/doc/type/vpc.rb +4 -2
  37. data/lib/awspec/generator/template.rb +9 -4
  38. data/lib/awspec/helper/finder/s3.rb +6 -0
  39. data/lib/awspec/stub/iam_group.rb +9 -9
  40. data/lib/awspec/stub/iam_policy.rb +27 -0
  41. data/lib/awspec/stub/s3.rb +28 -0
  42. data/lib/awspec/type/directconnect_virtual_interface.rb +2 -2
  43. data/lib/awspec/type/ebs.rb +2 -2
  44. data/lib/awspec/type/ec2.rb +2 -2
  45. data/lib/awspec/type/elasticache.rb +2 -2
  46. data/lib/awspec/type/rds.rb +2 -2
  47. data/lib/awspec/type/s3.rb +19 -0
  48. data/lib/awspec/type/subnet.rb +2 -2
  49. data/lib/awspec/type/vpc.rb +2 -2
  50. data/lib/awspec/version.rb +1 -1
  51. metadata +14 -2
@@ -7,8 +7,12 @@ module Awspec::Generator
7
7
  @type_name = 'DirectconnectVirtualInterface'
8
8
  @type = Awspec::Type::DirectconnectVirtualInterface.new('my-directconnect-virtual-interface')
9
9
  @ret = @type.resource
10
- @matchers = []
11
- @ignore_matchers = []
10
+ @matchers = [
11
+ Awspec::Type::DirectconnectVirtualInterface::STATES.map { |state| 'be_' + state.tr('-', '_') }.join(', ')
12
+ ]
13
+ @ignore_matchers = Awspec::Type::DirectconnectVirtualInterface::STATES.map do |state|
14
+ 'be_' + state.tr('-', '_')
15
+ end
12
16
  @describes = []
13
17
  end
14
18
  end
@@ -7,8 +7,10 @@ module Awspec::Generator
7
7
  @type_name = 'EBS'
8
8
  @type = Awspec::Type::Ebs.new('my-ebs')
9
9
  @ret = @type.resource
10
- @matchers = []
11
- @ignore_matchers = []
10
+ @matchers = [
11
+ Awspec::Type::Ebs::STATES.map { |state| 'be_' + state.tr('-', '_') }.join(', ')
12
+ ]
13
+ @ignore_matchers = Awspec::Type::Ebs::STATES.map { |state| 'be_' + state.tr('-', '_') }
12
14
  @describes = []
13
15
  end
14
16
  end
@@ -7,8 +7,12 @@ module Awspec::Generator
7
7
  @type_name = 'EC2'
8
8
  @type = Awspec::Type::Ec2.new('my-ec2')
9
9
  @ret = @type.resource
10
- @matchers = %w(belong_to_vpc belong_to_subnet)
11
- @ignore_matchers = []
10
+ @matchers = [
11
+ Awspec::Type::Ec2::STATES.map { |state| 'be_' + state.tr('-', '_') }.join(', '),
12
+ 'belong_to_vpc',
13
+ 'belong_to_subnet'
14
+ ]
15
+ @ignore_matchers = Awspec::Type::Ec2::STATES.map { |state| 'be_' + state.tr('-', '_') }
12
16
  @describes = []
13
17
  end
14
18
  end
@@ -7,8 +7,13 @@ module Awspec::Generator
7
7
  @type_name = 'Elasticache'
8
8
  @type = Awspec::Type::Elasticache.new('my-rep-group-001')
9
9
  @ret = @type.resource
10
- @matchers = %w(belong_to_vpc belong_to_replication_group belong_to_cache_subnet_group)
11
- @ignore_matchers = []
10
+ @matchers = [
11
+ Awspec::Type::Elasticache::STATES.map { |state| 'be_' + state.tr('-', '_') }.join(', '),
12
+ 'belong_to_vpc',
13
+ 'belong_to_replication_group',
14
+ 'belong_to_cache_subnet_group'
15
+ ]
16
+ @ignore_matchers = Awspec::Type::Elasticache::STATES.map { |state| 'be_' + state.tr('-', '_') }
12
17
  @describes = []
13
18
  end
14
19
  end
@@ -7,7 +7,7 @@ module Awspec::Generator
7
7
  @type_name = 'ELB'
8
8
  @type = Awspec::Type::Elb.new('my-elb')
9
9
  @ret = @type.resource
10
- @matchers = %w(belong_to_vpc belong_to_subnet)
10
+ @matchers = %w(belong_to_vpc)
11
11
  @ignore_matchers = []
12
12
  @describes = %w(
13
13
  health_check_target health_check_interval health_check_timeout
@@ -7,7 +7,10 @@ module Awspec::Generator
7
7
  @type_name = 'NetworkAcl'
8
8
  @type = Awspec::Type::NetworkAcl.new('my-network-acl')
9
9
  @ret = @type.resource
10
- @matchers = ['its(:inbound), its(:outbound)']
10
+ @matchers = [
11
+ 'belong_to_vpc',
12
+ 'its(:inbound), its(:outbound), its(:inbound_entries_count), its(:outbound_entries_count)'
13
+ ]
11
14
  @ignore_matchers = %w(be_allowed be_denied)
12
15
  @describes = %w(inbound_entries_count outbound_entries_count)
13
16
  end
@@ -7,8 +7,13 @@ module Awspec::Generator
7
7
  @type_name = 'RDS'
8
8
  @type = Awspec::Type::Rds.new('my-rds')
9
9
  @ret = @type.resource
10
- @matchers = %w(belong_to_vpc belong_to_subnet belong_to_db_subnet_group)
11
- @ignore_matchers = []
10
+ @matchers = [
11
+ Awspec::Type::Rds::STATES.map { |state| 'be_' + state.tr('-', '_') }.join(', '),
12
+ 'belong_to_vpc',
13
+ 'belong_to_subnet',
14
+ 'belong_to_db_subnet_group'
15
+ ]
16
+ @ignore_matchers = Awspec::Type::Rds::STATES.map { |state| 'be_' + state.tr('-', '_') }
12
17
  @describes = %w(vpc_id)
13
18
  end
14
19
  end
@@ -8,7 +8,7 @@ module Awspec::Generator
8
8
  @ret = @type.resource
9
9
  @matchers = []
10
10
  @ignore_matchers = []
11
- @describes = []
11
+ @describes = %w(acl_grants_count acl_owner)
12
12
  end
13
13
  end
14
14
  end
@@ -6,8 +6,10 @@ module Awspec::Generator
6
6
  super
7
7
  @type = Awspec::Type::Subnet.new('my-route-table')
8
8
  @ret = @type.resource
9
- @matchers = []
10
- @ignore_matchers = []
9
+ @matchers = [
10
+ Awspec::Type::Subnet::STATES.map { |state| 'be_' + state.tr('-', '_') }.join(', ')
11
+ ]
12
+ @ignore_matchers = Awspec::Type::Subnet::STATES.map { |state| 'be_' + state.tr('-', '_') }
11
13
  @describes = []
12
14
  end
13
15
  end
@@ -7,8 +7,10 @@ module Awspec::Generator
7
7
  @type_name = 'VPC'
8
8
  @type = Awspec::Type::Vpc.new('my-vpc')
9
9
  @ret = @type.resource
10
- @matchers = []
11
- @ignore_matchers = []
10
+ @matchers = [
11
+ Awspec::Type::Vpc::STATES.map { |state| 'be_' + state.tr('-', '_') }.join(', ')
12
+ ]
13
+ @ignore_matchers = Awspec::Type::Vpc::STATES.map { |state| 'be_' + state.tr('-', '_') }
12
14
  @describes = []
13
15
  end
14
16
  end
@@ -7,12 +7,12 @@ module Awspec::Generator
7
7
  generate_type
8
8
  generate_type_spec
9
9
  generate_generator_doc
10
+ generate_resource_type_doc
10
11
  put_message
11
12
  end
12
13
 
13
14
  def self.generate_type
14
15
  path = 'lib/awspec/type/' + @type.underscore + '.rb'
15
- full_path = @root_path + path
16
16
  content = <<-"EOF"
17
17
  module Awspec::Type
18
18
  class #{@type.camelize} < Base
@@ -28,7 +28,6 @@ EOF
28
28
 
29
29
  def self.generate_stub
30
30
  path = 'lib/awspec/stub/' + @type.underscore + '.rb'
31
- full_path = @root_path + path
32
31
  content = <<-"EOF"
33
32
  # Aws.config[:ec2] = {
34
33
  # stub_responses: true
@@ -39,7 +38,6 @@ EOF
39
38
 
40
39
  def self.generate_type_spec
41
40
  path = 'spec/type/' + @type.underscore + '_spec.rb'
42
- full_path = @root_path + path
43
41
  content = <<-"EOF"
44
42
  require 'spec_helper'
45
43
  Awspec::Stub.load '#{@type.underscore}'
@@ -53,7 +51,6 @@ EOF
53
51
 
54
52
  def self.generate_generator_doc
55
53
  path = 'lib/awspec/generator/doc/type/' + @type.underscore + '.rb'
56
- full_path = @root_path + path
57
54
  content = <<-"EOF"
58
55
  module Awspec::Generator
59
56
  module Doc
@@ -76,6 +73,14 @@ EOF
76
73
  self.file_check_and_puts(path, content)
77
74
  end
78
75
 
76
+ def self.generate_resource_type_doc
77
+ path = 'doc/_resource_types/' + @type.underscore + '.md'
78
+ content = <<-"EOF"
79
+ # exist
80
+ EOF
81
+ self.file_check_and_puts(path, content)
82
+ end
83
+
79
84
  def self.put_message
80
85
  content = <<-"EOF"
81
86
 
@@ -7,6 +7,12 @@ module Awspec::Helper
7
7
  bucket.name == id
8
8
  end
9
9
  end
10
+
11
+ def find_bucket_acl(id)
12
+ @s3_client.get_bucket_acl(bucket: id)
13
+ rescue Aws::S3::Errors::NoSuchBucket
14
+ nil
15
+ end
10
16
  end
11
17
  end
12
18
  end
@@ -1,14 +1,5 @@
1
1
  Aws.config[:iam] = {
2
2
  stub_responses: {
3
- list_groups: {
4
- groups: [
5
- path: '/',
6
- group_name: 'my-iam-group',
7
- group_id: 'GABCDEFGHI123455689',
8
- arn: 'arn:aws:iam::123456789012:group/my-iam-group',
9
- create_date: Time.local(2015)
10
- ]
11
- },
12
3
  list_users: {
13
4
  users: [
14
5
  path: '/',
@@ -18,6 +9,15 @@ Aws.config[:iam] = {
18
9
  create_date: Time.local(2015)
19
10
  ]
20
11
  },
12
+ list_groups: {
13
+ groups: [
14
+ path: '/',
15
+ group_name: 'my-iam-group',
16
+ group_id: 'GABCDEFGHI123455689',
17
+ arn: 'arn:aws:iam::123456789012:group/my-iam-group',
18
+ create_date: Time.local(2015)
19
+ ]
20
+ },
21
21
  list_groups_for_user: {
22
22
  groups: [
23
23
  {
@@ -1,5 +1,32 @@
1
1
  Aws.config[:iam] = {
2
2
  stub_responses: {
3
+ list_users: {
4
+ users: [
5
+ path: '/',
6
+ user_name: 'my-iam-user',
7
+ user_id: 'ABCDEFGHI1234556890',
8
+ arn: 'arn:aws:iam::123456789012:user/my-iam-user',
9
+ create_date: Time.local(2015)
10
+ ]
11
+ },
12
+ list_groups: {
13
+ groups: [
14
+ path: '/',
15
+ group_name: 'my-iam-group',
16
+ group_id: 'GABCDEFGHI123455689',
17
+ arn: 'arn:aws:iam::123456789012:group/my-iam-group',
18
+ create_date: Time.local(2015)
19
+ ]
20
+ },
21
+ list_roles: {
22
+ roles: [
23
+ path: '/',
24
+ role_name: 'HelloIAmGodRole',
25
+ role_id: 'RABCDEFGHI123455689',
26
+ arn: 'arn:aws:iam::123456789012:role/HelloIAmGodRole',
27
+ create_date: Time.local(2015)
28
+ ]
29
+ },
3
30
  list_policies: {
4
31
  policies: [
5
32
  {
@@ -9,6 +9,34 @@ Aws.config[:s3] = {
9
9
  },
10
10
  head_object: {
11
11
  content_type: 'binary/octet-stream'
12
+ },
13
+ get_bucket_acl: {
14
+ owner: {
15
+ display_name: 'my-bucket-owner'
16
+ },
17
+ grants: [
18
+ {
19
+ grantee: {
20
+ display_name: 'my-bucket-owner',
21
+ type: 'CanonicalUser'
22
+ },
23
+ permission: 'FULL_CONTROL'
24
+ },
25
+ {
26
+ grantee: {
27
+ display_name: 'my-bucket-write-only',
28
+ type: 'CanonicalUser'
29
+ },
30
+ permission: 'WRITE'
31
+ },
32
+ {
33
+ grantee: {
34
+ display_name: 'my-bucket-read-only',
35
+ type: 'CanonicalUser'
36
+ },
37
+ permission: 'READ'
38
+ }
39
+ ]
12
40
  }
13
41
  }
14
42
  }
@@ -6,12 +6,12 @@ module Awspec::Type
6
6
  @id = @resource[:virtual_interface_id] if @resource
7
7
  end
8
8
 
9
- states = %w(
9
+ STATES = %w(
10
10
  confirming verifying pending available
11
11
  deleting deleted rejected
12
12
  )
13
13
 
14
- states.each do |state|
14
+ STATES.each do |state|
15
15
  define_method state + '?' do
16
16
  @resource[:virtual_interface_state] == state
17
17
  end
@@ -6,11 +6,11 @@ module Awspec::Type
6
6
  @id = @resource[:volume_id] if @resource
7
7
  end
8
8
 
9
- states = %w(
9
+ STATES = %w(
10
10
  creating available in-use deleting deleted error
11
11
  )
12
12
 
13
- states.each do |state|
13
+ STATES.each do |state|
14
14
  define_method state.tr('-', '_') + '?' do
15
15
  @resource[:state] == state
16
16
  end
@@ -9,12 +9,12 @@ module Awspec::Type
9
9
  @id = @resource[:instance_id] if @resource
10
10
  end
11
11
 
12
- states = %w(
12
+ STATES = %w(
13
13
  pending running shutting-down
14
14
  terminated stopping stopped
15
15
  )
16
16
 
17
- states.each do |state|
17
+ STATES.each do |state|
18
18
  define_method state.tr('-', '_') + '?' do
19
19
  @resource[:state][:name] == state
20
20
  end
@@ -6,14 +6,14 @@ module Awspec::Type
6
6
  @id = @resource[:cache_cluster_id] if @resource
7
7
  end
8
8
 
9
- states = %w(
9
+ STATES = %w(
10
10
  available creating deleted deleting
11
11
  incompatible-network modifying
12
12
  rebooting-cache-cluster-nodes restore-failed
13
13
  snapshotting
14
14
  )
15
15
 
16
- states.each do |state|
16
+ STATES.each do |state|
17
17
  define_method state.tr('-', '_') + '?' do
18
18
  @resource[:cache_cluster_status] == state
19
19
  end
@@ -6,7 +6,7 @@ module Awspec::Type
6
6
  @id = @resource[:db_instance_identifier] if @resource
7
7
  end
8
8
 
9
- states = %w(
9
+ STATES = %w(
10
10
  available backing-up creating deleting
11
11
  failed inaccessible-encryption-credentials
12
12
  incompatible-credentials incompatible-network
@@ -16,7 +16,7 @@ module Awspec::Type
16
16
  restore-error storage-full upgrading
17
17
  )
18
18
 
19
- states.each do |state|
19
+ STATES.each do |state|
20
20
  define_method state.tr('-', '_') + '?' do
21
21
  @resource[:db_instance_status] == state
22
22
  end
@@ -15,5 +15,24 @@ module Awspec::Type
15
15
  rescue
16
16
  false
17
17
  end
18
+
19
+ def has_acl_grant?(grantee:, permission:)
20
+ @acl = find_bucket_acl(@id)
21
+ @acl.grants.find do |grant|
22
+ next false if !grantee.nil? && grant.grantee.display_name != grantee && grant.grantee.id != grantee
23
+ next false if !permission.nil? && grant.permission != permission
24
+ true
25
+ end
26
+ end
27
+
28
+ def acl_owner
29
+ @acl = find_bucket_acl(@id)
30
+ @acl.owner.display_name
31
+ end
32
+
33
+ def acl_grants_count
34
+ @acl = find_bucket_acl(@id)
35
+ @acl.grants.count
36
+ end
18
37
  end
19
38
  end
@@ -6,11 +6,11 @@ module Awspec::Type
6
6
  @id = @resource[:subnet_id] if @resource
7
7
  end
8
8
 
9
- states = %w(
9
+ STATES = %w(
10
10
  available pending
11
11
  )
12
12
 
13
- states.each do |state|
13
+ STATES.each do |state|
14
14
  define_method state + '?' do
15
15
  @resource[:state] == state
16
16
  end
@@ -9,11 +9,11 @@ module Awspec::Type
9
9
  @id = @resource[:vpc_id] if @resource
10
10
  end
11
11
 
12
- states = %w(
12
+ STATES = %w(
13
13
  available pending
14
14
  )
15
15
 
16
- states.each do |state|
16
+ STATES.each do |state|
17
17
  define_method state + '?' do
18
18
  @resource[:state] == state
19
19
  end
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '0.22.1'
2
+ VERSION = '0.23.0'
3
3
  end