awspec 0.52.4 → 0.54.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: e393eeb36c4eccf1cbd32d049cf124f22dd3600f
4
- data.tar.gz: 66932a70dcf579e8846121c99cb219a73c1170c2
3
+ metadata.gz: 2d2a41e2828f5a25b1300bcc300425153df818ef
4
+ data.tar.gz: d5228c0353fb70b41aa66ce0aa2a86a918ed008d
5
5
  SHA512:
6
- metadata.gz: f708d931d45c30313af2ce8566f261449e9a18d5a5a6f91e9b93458ff33888921dd7bdf15d1a4e69e92eeac42995622eced4bdb7bec1aec2c89ab254ba1f7d1d
7
- data.tar.gz: 93bac28b5810a34334ab2f269ac834aaae82ca3b55d77be75a52d57341ceb98334f127675dcf97fe7864f0ee9451de790c936f38a762be40c24fd521e1dfdbef
6
+ metadata.gz: 47f40131bb7292c146ab29716f988b3961cfad51d94c5ec5a6e5d3b32c279f21e7c2248cae73c02cdf23bb8efc1bca9ec0250d1adcb2d6721bb9b9bd62c8ab2a
7
+ data.tar.gz: a48177d7fde1e573422f781edba9395a7ca0635f3af490142f689b7f1b783f230e9287b9a5d378c6b1cbad8fc44327d66e941b909358e8b8f68c2fc02ab9f956
@@ -0,0 +1,48 @@
1
+ ### exist
2
+
3
+ ```ruby
4
+ describe elasticsearch('my-elasticsearch') do
5
+ it { should exist }
6
+ end
7
+ ```
8
+
9
+ ### be_created
10
+
11
+ ```ruby
12
+ describe elasticsearch('my-elasticsearch') do
13
+ it { should be_created }
14
+ end
15
+ ```
16
+
17
+ ### be_deleted
18
+
19
+ ```ruby
20
+ describe elasticsearch('my-elasticsearch') do
21
+ it { should be_deleted }
22
+ end
23
+ ```
24
+
25
+ ### have_access_policies
26
+
27
+ ```ruby
28
+ describe elasticsearch('my-elasticsearch') do
29
+ it do
30
+ should have_access_policies <<-policy
31
+ {
32
+ "version": "2012-10-17",
33
+ "statement": [
34
+ {
35
+ "effect": "allow",
36
+ "principal": "*",
37
+ "action": [
38
+ "es:*"
39
+ ],
40
+ "resource": "arn:aws:es:ap-northeast-1:1234567890:domain/my-elasticsearch/*"
41
+ }
42
+ ]
43
+ }
44
+ policy
45
+ end
46
+ end
47
+ ```
48
+
@@ -0,0 +1,70 @@
1
+ ### exist
2
+
3
+ ```ruby
4
+ describe kms('my-kms-key') do
5
+ it { should exist }
6
+ end
7
+ ```
8
+
9
+ ### be_enabled
10
+
11
+ ```ruby
12
+ describe kms('my-kms-key') do
13
+ it { should be_enabled }
14
+ end
15
+ ```
16
+
17
+ ### have_key_policy
18
+
19
+ ```ruby
20
+ describe kms('my-kms-key') do
21
+ it { should exist }
22
+ it { should be_enabled }
23
+ it do
24
+ should have_key_policy('default').policy_document(<<-'DOC')
25
+ {
26
+ "Version" : "2012-10-17",
27
+ "Id" : "key-consolepolicy-2",
28
+ "Statement" : [ {
29
+ "Sid" : "Enable IAM User Permissions",
30
+ "Effect" : "Allow",
31
+ "Principal" : {
32
+ "AWS" : "arn:aws:iam::1234567890:root"
33
+ },
34
+ "Action" : "kms:*",
35
+ "Resource" : "*"
36
+ }, {
37
+ "Sid" : "Allow access for Key Administrators",
38
+ "Effect" : "Allow",
39
+ "Principal" : {
40
+ "AWS" : "arn:aws:iam::1234567890:user/test-user"
41
+ },
42
+ "Action" : [ "kms:Create*", "kms:Describe*", "kms:Enable*", "kms:List*", "kms:Put*", "kms:Update*", "kms:Revoke*", "kms:Disable*", "kms:Get*", "kms:Delete*", "kms:ScheduleKeyDeletion", "kms:CancelKeyDeletion" ],
43
+ "Resource" : "*"
44
+ }, {
45
+ "Sid" : "Allow use of the key",
46
+ "Effect" : "Allow",
47
+ "Principal" : {
48
+ "AWS" : [ "arn:aws:iam::1234567890:user/test-user", "arn:aws:iam::1234567890:role/test-role" ]
49
+ },
50
+ "Action" : [ "kms:Encrypt", "kms:Decrypt", "kms:ReEncrypt*", "kms:GenerateDataKey*", "kms:DescribeKey" ],
51
+ "Resource" : "*"
52
+ }, {
53
+ "Sid" : "Allow attachment of persistent resources",
54
+ "Effect" : "Allow",
55
+ "Principal" : {
56
+ "AWS" : [ "arn:aws:iam::1234567890:user/test-user", "arn:aws:iam::1234567890:role/test-role" ]
57
+ },
58
+ "Action" : [ "kms:CreateGrant", "kms:ListGrants", "kms:RevokeGrant" ],
59
+ "Resource" : "*",
60
+ "Condition" : {
61
+ "Bool" : {
62
+ "kms:GrantIsForAWSResource" : "true"
63
+ }
64
+ }
65
+ } ]
66
+ }
67
+ DOC
68
+ end
69
+ end
70
+ ```
@@ -18,7 +18,7 @@ end
18
18
 
19
19
  ```ruby
20
20
  describe rds('my-rds') do
21
- it { should belong_to_db_subnet_group('my-db-subnet-group') }
21
+ it { should have_db_parameter_group('my-db-parameter-group') }
22
22
  end
23
23
  ```
24
24
 
@@ -10,11 +10,13 @@
10
10
  | [ec2](#ec2)
11
11
  | [elasticache](#elasticache)
12
12
  | [elasticache_cache_parameter_group](#elasticache_cache_parameter_group)
13
+ | [elasticsearch](#elasticsearch)
13
14
  | [elb](#elb)
14
15
  | [iam_group](#iam_group)
15
16
  | [iam_policy](#iam_policy)
16
17
  | [iam_role](#iam_role)
17
18
  | [iam_user](#iam_user)
19
+ | [kms](#kms)
18
20
  | [lambda](#lambda)
19
21
  | [launch_configuration](#launch_configuration)
20
22
  | [nat_gateway](#nat_gateway)
@@ -520,6 +522,63 @@ end
520
522
  ```
521
523
 
522
524
 
525
+ ## <a name="elasticsearch">elasticsearch</a>
526
+
527
+ Elasticsearch resource type.
528
+
529
+ ### exist
530
+
531
+ ```ruby
532
+ describe elasticsearch('my-elasticsearch') do
533
+ it { should exist }
534
+ end
535
+ ```
536
+
537
+
538
+ ### be_created
539
+
540
+ ```ruby
541
+ describe elasticsearch('my-elasticsearch') do
542
+ it { should be_created }
543
+ end
544
+ ```
545
+
546
+
547
+ ### be_deleted
548
+
549
+ ```ruby
550
+ describe elasticsearch('my-elasticsearch') do
551
+ it { should be_deleted }
552
+ end
553
+ ```
554
+
555
+
556
+ ### have_access_policies
557
+
558
+ ```ruby
559
+ describe elasticsearch('my-elasticsearch') do
560
+ it do
561
+ should have_access_policies <<-policy
562
+ {
563
+ "version": "2012-10-17",
564
+ "statement": [
565
+ {
566
+ "effect": "allow",
567
+ "principal": "*",
568
+ "action": [
569
+ "es:*"
570
+ ],
571
+ "resource": "arn:aws:es:ap-northeast-1:1234567890:domain/my-elasticsearch/*"
572
+ }
573
+ ]
574
+ }
575
+ policy
576
+ end
577
+ end
578
+ ```
579
+
580
+
581
+ ### its(:domain_id), its(:domain_name), its(:arn), its(:created), its(:deleted), its(:endpoint), its(:processing), its(:elasticsearch_version), its(:access_policies), its(:snapshot_options), its(:advanced_options)
523
582
  ## <a name="elb">elb</a>
524
583
 
525
584
  ELB resource type.
@@ -860,6 +919,84 @@ describe iam_user('my-iam-user') do
860
919
  end
861
920
  ```
862
921
 
922
+ ## <a name="kms">kms</a>
923
+
924
+ Kms resource type.
925
+
926
+ ### exist
927
+
928
+ ```ruby
929
+ describe kms('my-kms-key') do
930
+ it { should exist }
931
+ end
932
+ ```
933
+
934
+
935
+ ### be_enabled
936
+
937
+ ```ruby
938
+ describe kms('my-kms-key') do
939
+ it { should be_enabled }
940
+ end
941
+ ```
942
+
943
+
944
+ ### have_key_policy
945
+
946
+ ```ruby
947
+ describe kms('my-kms-key') do
948
+ it { should exist }
949
+ it { should be_enabled }
950
+ it do
951
+ should have_key_policy('default').policy_document(<<-'DOC')
952
+ {
953
+ "Version" : "2012-10-17",
954
+ "Id" : "key-consolepolicy-2",
955
+ "Statement" : [ {
956
+ "Sid" : "Enable IAM User Permissions",
957
+ "Effect" : "Allow",
958
+ "Principal" : {
959
+ "AWS" : "arn:aws:iam::1234567890:root"
960
+ },
961
+ "Action" : "kms:*",
962
+ "Resource" : "*"
963
+ }, {
964
+ "Sid" : "Allow access for Key Administrators",
965
+ "Effect" : "Allow",
966
+ "Principal" : {
967
+ "AWS" : "arn:aws:iam::1234567890:user/test-user"
968
+ },
969
+ "Action" : [ "kms:Create*", "kms:Describe*", "kms:Enable*", "kms:List*", "kms:Put*", "kms:Update*", "kms:Revoke*", "kms:Disable*", "kms:Get*", "kms:Delete*", "kms:ScheduleKeyDeletion", "kms:CancelKeyDeletion" ],
970
+ "Resource" : "*"
971
+ }, {
972
+ "Sid" : "Allow use of the key",
973
+ "Effect" : "Allow",
974
+ "Principal" : {
975
+ "AWS" : [ "arn:aws:iam::1234567890:user/test-user", "arn:aws:iam::1234567890:role/test-role" ]
976
+ },
977
+ "Action" : [ "kms:Encrypt", "kms:Decrypt", "kms:ReEncrypt*", "kms:GenerateDataKey*", "kms:DescribeKey" ],
978
+ "Resource" : "*"
979
+ }, {
980
+ "Sid" : "Allow attachment of persistent resources",
981
+ "Effect" : "Allow",
982
+ "Principal" : {
983
+ "AWS" : [ "arn:aws:iam::1234567890:user/test-user", "arn:aws:iam::1234567890:role/test-role" ]
984
+ },
985
+ "Action" : [ "kms:CreateGrant", "kms:ListGrants", "kms:RevokeGrant" ],
986
+ "Resource" : "*",
987
+ "Condition" : {
988
+ "Bool" : {
989
+ "kms:GrantIsForAWSResource" : "true"
990
+ }
991
+ }
992
+ } ]
993
+ }
994
+ DOC
995
+ end
996
+ end
997
+ ```
998
+
999
+ ### its(:aws_account_id), its(:key_id), its(:arn), its(:creation_date), its(:enabled), its(:description), its(:key_usage), its(:key_state), its(:deletion_date), its(:valid_to), its(:origin), its(:expiration_model)
863
1000
  ## <a name="lambda">lambda</a>
864
1001
 
865
1002
  Lambda resource type.
@@ -1108,7 +1245,7 @@ end
1108
1245
 
1109
1246
  ```ruby
1110
1247
  describe rds('my-rds') do
1111
- it { should belong_to_db_subnet_group('my-db-subnet-group') }
1248
+ it { should have_db_parameter_group('my-db-parameter-group') }
1112
1249
  end
1113
1250
  ```
1114
1251
 
@@ -6,6 +6,7 @@ require 'awspec/generator/spec/security_group'
6
6
  require 'awspec/generator/spec/route53_hosted_zone'
7
7
  require 'awspec/generator/spec/elb'
8
8
  require 'awspec/generator/spec/iam_policy'
9
+ require 'awspec/generator/spec/kms'
9
10
  require 'awspec/generator/spec/cloudwatch_alarm'
10
11
  require 'awspec/generator/spec/cloudwatch_event'
11
12
  require 'awspec/generator/spec/network_acl'
@@ -0,0 +1,17 @@
1
+ module Awspec::Generator
2
+ module Doc
3
+ module Type
4
+ class Elasticsearch < Base
5
+ def initialize
6
+ super
7
+ @type_name = 'Elasticsearch'
8
+ @type = Awspec::Type::Elasticsearch.new('my-elasticsearch')
9
+ @ret = @type.resource_via_client
10
+ @matchers = []
11
+ @ignore_matchers = []
12
+ @describes = []
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ module Awspec::Generator
2
+ module Doc
3
+ module Type
4
+ class Kms < Base
5
+ def initialize
6
+ super
7
+ @type_name = 'Kms'
8
+ @type = Awspec::Type::Kms.new('my-kms-key')
9
+ @ret = @type.resource_via_client
10
+ @matchers = []
11
+ @ignore_matchers = []
12
+ @describes = []
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,38 @@
1
+ module Awspec::Generator
2
+ module Spec
3
+ class ElasticSearch
4
+ include Awspec::Helper::Finder
5
+ def generate_all
6
+ domains = select_all_elasticsearch_domains
7
+ raise 'Not Found alarm' if events.empty?
8
+ ERB.new(domain_spec_template, nil, '-').result(binding).chomp
9
+ end
10
+
11
+ def domain_spec_template
12
+ template = <<-'EOF'
13
+ <% domain.each do |domain| %>
14
+ describe elasticsearch('<%= domain.domain_name %>') do
15
+ it { should exist }
16
+ <% if domain.ebs_options.created %>
17
+ it { should be_created }
18
+ <% end %>
19
+ <% if domain.ebs_options.deleted %>
20
+ it { should be_deleted }
21
+ <% end %>
22
+ its(:elasticsearch_version) { should eq <%= domain.elasticsearch_version %> }
23
+ its('elasticsearch_cluster_config.instance_type') { should eq <%= domain.elasticsearch_cluster_config.instance_type %> }
24
+ its('ebs_options.ebs_enabled') { should eq <%= domain.ebs_options.ebs_enabled %> }
25
+ <% if domain.ebs_options.ebs_enabled %>
26
+ its('ebs_options.volume_type') { should eq <%= domain.ebs_options.ebs_volume_type %> }
27
+ its('ebs_options.volume_size') { should eq <%= domain.ebs_options.ebs_volume_size %> }
28
+ <% end %>
29
+ it do
30
+ should have_access_policies <<-policy
31
+ <%= JSON.pretty_generate(JSON.load(domain.access_policies)) %>
32
+ policy
33
+ EOF
34
+ template
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,26 @@
1
+ module Awspec::Generator
2
+ module Spec
3
+ class Kms
4
+ include Awspec::Helper::Finder
5
+ def generate_all
6
+ aliases = select_all_kms_aliases
7
+ raise 'Not Found alias' if aliases.empty?
8
+ ERB.new(keys_spec_template, nil, '-').result(binding).chomp
9
+ end
10
+
11
+ def keys_spec_template
12
+ template = <<-'EOF'
13
+ <% aliases.each do |kms_alias| %>
14
+ describe kms('<%= kms_alias.alias_name.split('/').last %>') do
15
+ it { should exist }
16
+ <% if find_kms_key(kms_alias.target_key_id).enabled -%>
17
+ it { should be_enable }
18
+ <% end -%>
19
+ end
20
+ <% end %>
21
+ EOF
22
+ template
23
+ end
24
+ end
25
+ end
26
+ end
@@ -11,7 +11,9 @@ require 'awspec/helper/finder/ebs'
11
11
  require 'awspec/helper/finder/elb'
12
12
  require 'awspec/helper/finder/lambda'
13
13
  require 'awspec/helper/finder/iam'
14
+ require 'awspec/helper/finder/kms'
14
15
  require 'awspec/helper/finder/elasticache'
16
+ require 'awspec/helper/finder/elasticsearch'
15
17
  require 'awspec/helper/finder/cloudwatch'
16
18
  require 'awspec/helper/finder/cloudwatch_event'
17
19
  require 'awspec/helper/finder/ses'
@@ -35,7 +37,9 @@ module Awspec::Helper
35
37
  include Awspec::Helper::Finder::Elb
36
38
  include Awspec::Helper::Finder::Lambda
37
39
  include Awspec::Helper::Finder::Iam
40
+ include Awspec::Helper::Finder::Kms
38
41
  include Awspec::Helper::Finder::Elasticache
42
+ include Awspec::Helper::Finder::Elasticsearch
39
43
  include Awspec::Helper::Finder::Cloudwatch
40
44
  include Awspec::Helper::Finder::CloudwatchEvent
41
45
  include Awspec::Helper::Finder::Ses
@@ -54,6 +58,7 @@ module Awspec::Helper
54
58
  elb_client: Aws::ElasticLoadBalancing::Client,
55
59
  lambda_client: Aws::Lambda::Client,
56
60
  iam_client: Aws::IAM::Client,
61
+ kms_client: Aws::KMS::Client,
57
62
  elasticache_client: Aws::ElastiCache::Client,
58
63
  cloudwatch_client: Aws::CloudWatch::Client,
59
64
  cloudwatch_event_client: Aws::CloudWatchEvents::Client,
@@ -61,6 +66,7 @@ module Awspec::Helper
61
66
  directconnect_client: Aws::DirectConnect::Client,
62
67
  cloudfront_client: Aws::CloudFront::Client,
63
68
  elastictranscoder_client: Aws::ElasticTranscoder::Client,
69
+ elasticsearch_client: Aws::ElasticsearchService::Client,
64
70
  cloudtrail_client: Aws::CloudTrail::Client
65
71
  }
66
72
 
@@ -0,0 +1,19 @@
1
+ module Awspec::Helper
2
+ module Finder
3
+ module Elasticsearch
4
+ def find_elasticsearch_domain(id)
5
+ res = elasticsearch_client.describe_elasticsearch_domain(domain_name: id)
6
+ res.domain_status
7
+ rescue
8
+ nil
9
+ end
10
+
11
+ def select_all_elasticsearch_domains
12
+ domain_names = elastisearch_client.list_domain_names
13
+ domain_names.map do |domain_name|
14
+ elasticsearch_client.describe_elasticsearch_domain(domain_name)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,22 @@
1
+ module Awspec::Helper
2
+ module Finder
3
+ module Kms
4
+ def find_kms_key(key_id)
5
+ kms_client.describe_key(key_id: key_id).key_metadata
6
+ rescue
7
+ nil
8
+ end
9
+
10
+ def find_kms_key_by_alias(key_alias_name)
11
+ key = kms_client.list_aliases.aliases.find do |key_alias|
12
+ key_alias.alias_name == "alias/#{key_alias_name}"
13
+ end
14
+ find_kms_key(key.target_key_id)
15
+ end
16
+
17
+ def select_all_kms_aliases
18
+ kms_client.list_aliases.aliases
19
+ end
20
+ end
21
+ end
22
+ end
@@ -5,8 +5,8 @@ module Awspec
5
5
 
6
6
  TYPES = %w(
7
7
  ami autoscaling_group cloudtrail cloudwatch_alarm cloudwatch_event directconnect_virtual_interface
8
- ebs ec2 elasticache elasticache_cache_parameter_group elb iam_group
9
- iam_policy iam_role iam_user lambda launch_configuration nat_gateway
8
+ ebs ec2 elasticache elasticache_cache_parameter_group elasticsearch elb iam_group
9
+ iam_policy iam_role iam_user kms lambda launch_configuration nat_gateway
10
10
  network_acl network_interface rds rds_db_cluster_parameter_group rds_db_parameter_group route53_hosted_zone
11
11
  route_table s3_bucket security_group ses_identity subnet vpc cloudfront_distribution
12
12
  elastictranscoder_pipeline
@@ -40,3 +40,6 @@ require 'awspec/matcher/have_private_ip_address'
40
40
 
41
41
  # CloudFront
42
42
  require 'awspec/matcher/have_origin'
43
+
44
+ # Kms
45
+ require 'awspec/matcher/have_key_policy'
@@ -0,0 +1,9 @@
1
+ RSpec::Matchers.define :have_key_policy do |policy_name|
2
+ match do |key_type|
3
+ key_type.has_key_policy?(policy_name, @document)
4
+ end
5
+
6
+ chain :policy_document do |document|
7
+ @document = document
8
+ end
9
+ end
@@ -0,0 +1,52 @@
1
+
2
+ Aws.config[:elasticsearchservice] = {
3
+ stub_responses: {
4
+ list_domain_names: {
5
+ domain_names: [
6
+ {
7
+ domain_name: 'my-elasticsearch'
8
+ }
9
+ ]
10
+ },
11
+ describe_elasticsearch_domain: {
12
+ domain_status: {
13
+ domain_id: '123456789012/streaming-logs',
14
+ domain_name: 'my-elasticsearch',
15
+ arn: 'arn:aws:es:us-east-1:123456789012:domain/streaming-logs',
16
+ created: true,
17
+ deleted: false,
18
+ endpoint: 'search-streaming-logs-okga24ftzsbz2a2hzhsqw73jpy.us-east-1.es.a9.com',
19
+ processing: false,
20
+ elasticsearch_version: '2.3',
21
+ elasticsearch_cluster_config: {
22
+ instance_type: 't2.micro.elasticsearch',
23
+ instance_count: 3,
24
+ dedicated_master_enabled: true,
25
+ zone_awareness_enabled: false,
26
+ dedicated_master_type: 'm3.medium.elasticsearch',
27
+ dedicated_master_count: 3
28
+ },
29
+ ebs_options: {
30
+ ebs_enabled: true,
31
+ volume_size: 10,
32
+ volume_type: 'gp2'
33
+ },
34
+ access_policies: <<-EOS.gsub(/\n/, '').gsub(/ /, '')
35
+ {
36
+ "version": "2012-10-17",
37
+ "statement": [
38
+ {
39
+ "effect": "allow",
40
+ "principal": "*",
41
+ "action": [
42
+ "es:*"
43
+ ],
44
+ "resource": "arn:aws:es:ap-northeast-1:1234567890:domain/my-elasticsearch/*"
45
+ }
46
+ ]
47
+ }
48
+ EOS
49
+ }
50
+ }
51
+ }
52
+ }
@@ -0,0 +1,71 @@
1
+ Aws.config[:kms] = {
2
+ stub_responses: {
3
+ list_aliases: {
4
+ aliases: [
5
+ {
6
+ alias_arn: 'arn:aws:kms:us-east-1:1234567890:alias/my-kms-key',
7
+ alias_name: 'alias/my-kms-key',
8
+ target_key_id: 'b9989d41-eeaa-401f-8616-00546948aa92'
9
+ }
10
+ ]
11
+ },
12
+ describe_key: {
13
+ key_metadata: {
14
+ key_id: 'b9989d41-eeaa-401f-8616-00546948aa92',
15
+ description: '',
16
+ enabled: true,
17
+ key_usage: 'ENCRYPT_DECRYPT',
18
+ key_state: 'Enabled',
19
+ creation_date: Time.new(2015, 1, 2, 10, 10, 00, '+00:00'),
20
+ arn: 'arn:aws:kms:us-east-1:1234567890:key/b9989d41-eeaa-401f-8616-00546948aa92',
21
+ aws_account_id: '1234567890'
22
+ }
23
+ },
24
+ get_key_policy: {
25
+ policy: <<-DOC
26
+ {
27
+ "Version" : "2012-10-17",
28
+ "Id" : "key-consolepolicy-2",
29
+ "Statement" : [ {
30
+ "Sid" : "Enable IAM User Permissions",
31
+ "Effect" : "Allow",
32
+ "Principal" : {
33
+ "AWS" : "arn:aws:iam::1234567890:root"
34
+ },
35
+ "Action" : "kms:*",
36
+ "Resource" : "*"
37
+ }, {
38
+ "Sid" : "Allow access for Key Administrators",
39
+ "Effect" : "Allow",
40
+ "Principal" : {
41
+ "AWS" : "arn:aws:iam::1234567890:user/test-user"
42
+ },
43
+ "Action" : [ "kms:Create*", "kms:Describe*", "kms:Enable*", "kms:List*", "kms:Put*", "kms:Update*", "kms:Revoke*", "kms:Disable*", "kms:Get*", "kms:Delete*", "kms:ScheduleKeyDeletion", "kms:CancelKeyDeletion" ],
44
+ "Resource" : "*"
45
+ }, {
46
+ "Sid" : "Allow use of the key",
47
+ "Effect" : "Allow",
48
+ "Principal" : {
49
+ "AWS" : [ "arn:aws:iam::1234567890:user/test-user", "arn:aws:iam::1234567890:role/test-role" ]
50
+ },
51
+ "Action" : [ "kms:Encrypt", "kms:Decrypt", "kms:ReEncrypt*", "kms:GenerateDataKey*", "kms:DescribeKey" ],
52
+ "Resource" : "*"
53
+ }, {
54
+ "Sid" : "Allow attachment of persistent resources",
55
+ "Effect" : "Allow",
56
+ "Principal" : {
57
+ "AWS" : [ "arn:aws:iam::1234567890:user/test-user", "arn:aws:iam::1234567890:role/test-role" ]
58
+ },
59
+ "Action" : [ "kms:CreateGrant", "kms:ListGrants", "kms:RevokeGrant" ],
60
+ "Resource" : "*",
61
+ "Condition" : {
62
+ "Bool" : {
63
+ "kms:GrantIsForAWSResource" : "true"
64
+ }
65
+ }
66
+ } ]
67
+ }
68
+ DOC
69
+ }
70
+ }
71
+ }
@@ -0,0 +1,21 @@
1
+ module Awspec::Type
2
+ class Elasticsearch < Base
3
+ def initialize(id)
4
+ super
5
+ @resource_via_client = find_elasticsearch_domain(id)
6
+ @id = @resource_via_client.arn if @resource_via_client
7
+ end
8
+
9
+ def has_access_policies?(policy)
10
+ @resource_via_client.access_policies == policy.gsub(/\n/, '').gsub(/ /, '')
11
+ end
12
+
13
+ def created?
14
+ @resource_via_client.created
15
+ end
16
+
17
+ def deleted?
18
+ @resource_via_client.deleted
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ module Awspec::Type
2
+ class Kms < Base
3
+ def initialize(id)
4
+ super
5
+ @resource_via_client = find_kms_key_by_alias(id)
6
+ @id = @resource_via_client.arn if @resource_via_client
7
+ end
8
+
9
+ def enabled?
10
+ @resource_via_client.enabled
11
+ end
12
+
13
+ def has_key_policy?(policy_name, document = nil)
14
+ res = kms_client.get_key_policy(key_id: @id, policy_name: policy_name)
15
+ return JSON.parse(URI.decode(res.policy)) == JSON.parse(document) if document
16
+ res
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '0.52.4'
2
+ VERSION = '0.54.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.52.4
4
+ version: 0.54.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-08-29 00:00:00.000000000 Z
11
+ date: 2016-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -216,12 +216,14 @@ files:
216
216
  - doc/_resource_types/ec2.md
217
217
  - doc/_resource_types/elasticache.md
218
218
  - doc/_resource_types/elasticache_cache_parameter_group.md
219
+ - doc/_resource_types/elasticsearch.md
219
220
  - doc/_resource_types/elastictranscoder_pipeline.md
220
221
  - doc/_resource_types/elb.md
221
222
  - doc/_resource_types/iam_group.md
222
223
  - doc/_resource_types/iam_policy.md
223
224
  - doc/_resource_types/iam_role.md
224
225
  - doc/_resource_types/iam_user.md
226
+ - doc/_resource_types/kms.md
225
227
  - doc/_resource_types/lambda.md
226
228
  - doc/_resource_types/launch_configuration.md
227
229
  - doc/_resource_types/nat_gateway.md
@@ -261,12 +263,14 @@ files:
261
263
  - lib/awspec/generator/doc/type/ec2.rb
262
264
  - lib/awspec/generator/doc/type/elasticache.rb
263
265
  - lib/awspec/generator/doc/type/elasticache_cache_parameter_group.rb
266
+ - lib/awspec/generator/doc/type/elasticsearch.rb
264
267
  - lib/awspec/generator/doc/type/elastictranscoder_pipeline.rb
265
268
  - lib/awspec/generator/doc/type/elb.rb
266
269
  - lib/awspec/generator/doc/type/iam_group.rb
267
270
  - lib/awspec/generator/doc/type/iam_policy.rb
268
271
  - lib/awspec/generator/doc/type/iam_role.rb
269
272
  - lib/awspec/generator/doc/type/iam_user.rb
273
+ - lib/awspec/generator/doc/type/kms.rb
270
274
  - lib/awspec/generator/doc/type/lambda.rb
271
275
  - lib/awspec/generator/doc/type/launch_configuration.rb
272
276
  - lib/awspec/generator/doc/type/nat_gateway.rb
@@ -287,11 +291,13 @@ files:
287
291
  - lib/awspec/generator/spec/directconnect.rb
288
292
  - lib/awspec/generator/spec/ebs.rb
289
293
  - lib/awspec/generator/spec/ec2.rb
294
+ - lib/awspec/generator/spec/elasticsearch.rb
290
295
  - lib/awspec/generator/spec/elb.rb
291
296
  - lib/awspec/generator/spec/iam_group.rb
292
297
  - lib/awspec/generator/spec/iam_policy.rb
293
298
  - lib/awspec/generator/spec/iam_role.rb
294
299
  - lib/awspec/generator/spec/iam_user.rb
300
+ - lib/awspec/generator/spec/kms.rb
295
301
  - lib/awspec/generator/spec/lambda.rb
296
302
  - lib/awspec/generator/spec/nat_gateway.rb
297
303
  - lib/awspec/generator/spec/network_acl.rb
@@ -317,9 +323,11 @@ files:
317
323
  - lib/awspec/helper/finder/ebs.rb
318
324
  - lib/awspec/helper/finder/ec2.rb
319
325
  - lib/awspec/helper/finder/elasticache.rb
326
+ - lib/awspec/helper/finder/elasticsearch.rb
320
327
  - lib/awspec/helper/finder/elastictranscoder.rb
321
328
  - lib/awspec/helper/finder/elb.rb
322
329
  - lib/awspec/helper/finder/iam.rb
330
+ - lib/awspec/helper/finder/kms.rb
323
331
  - lib/awspec/helper/finder/lambda.rb
324
332
  - lib/awspec/helper/finder/rds.rb
325
333
  - lib/awspec/helper/finder/route53.rb
@@ -344,6 +352,7 @@ files:
344
352
  - lib/awspec/matcher/belong_to_subnet.rb
345
353
  - lib/awspec/matcher/belong_to_vpc.rb
346
354
  - lib/awspec/matcher/have_inline_policy.rb
355
+ - lib/awspec/matcher/have_key_policy.rb
347
356
  - lib/awspec/matcher/have_origin.rb
348
357
  - lib/awspec/matcher/have_private_ip_address.rb
349
358
  - lib/awspec/matcher/have_record_set.rb
@@ -364,12 +373,14 @@ files:
364
373
  - lib/awspec/stub/ec2.rb
365
374
  - lib/awspec/stub/elasticache.rb
366
375
  - lib/awspec/stub/elasticache_cache_parameter_group.rb
376
+ - lib/awspec/stub/elasticsearch.rb
367
377
  - lib/awspec/stub/elastictranscoder_pipeline.rb
368
378
  - lib/awspec/stub/elb.rb
369
379
  - lib/awspec/stub/iam_group.rb
370
380
  - lib/awspec/stub/iam_policy.rb
371
381
  - lib/awspec/stub/iam_role.rb
372
382
  - lib/awspec/stub/iam_user.rb
383
+ - lib/awspec/stub/kms.rb
373
384
  - lib/awspec/stub/lambda.rb
374
385
  - lib/awspec/stub/launch_configuration.rb
375
386
  - lib/awspec/stub/nat_gateway.rb
@@ -398,12 +409,14 @@ files:
398
409
  - lib/awspec/type/ec2.rb
399
410
  - lib/awspec/type/elasticache.rb
400
411
  - lib/awspec/type/elasticache_cache_parameter_group.rb
412
+ - lib/awspec/type/elasticsearch.rb
401
413
  - lib/awspec/type/elastictranscoder_pipeline.rb
402
414
  - lib/awspec/type/elb.rb
403
415
  - lib/awspec/type/iam_group.rb
404
416
  - lib/awspec/type/iam_policy.rb
405
417
  - lib/awspec/type/iam_role.rb
406
418
  - lib/awspec/type/iam_user.rb
419
+ - lib/awspec/type/kms.rb
407
420
  - lib/awspec/type/lambda.rb
408
421
  - lib/awspec/type/launch_configuration.rb
409
422
  - lib/awspec/type/nat_gateway.rb