awspec 0.63.1 → 0.64.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/_resource_types/efs.md +15 -0
- data/doc/resource_types.md +23 -0
- data/lib/awspec/command/generate.rb +3 -3
- data/lib/awspec/generator.rb +1 -0
- data/lib/awspec/generator/doc/type/efs.rb +17 -0
- data/lib/awspec/generator/spec/efs.rb +28 -0
- data/lib/awspec/generator/template.rb +2 -1
- data/lib/awspec/helper/finder.rb +3 -0
- data/lib/awspec/helper/finder/efs.rb +62 -0
- data/lib/awspec/helper/type.rb +1 -1
- data/lib/awspec/stub/efs.rb +33 -0
- data/lib/awspec/type/efs.rb +22 -0
- data/lib/awspec/version.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d070c1be2beec227b12d8cd6a53b0d3ac4aba8d0
|
4
|
+
data.tar.gz: 783e7fe04360753de3e60680ece3a3861f4f8cb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d73b5dbae0739a79209634ed275c35b2625ad05fe5fadbe4075bce94ba32d8ac327c9ff0f17f3114cea4d0cb088ee56b36e920fdc9085cb010be1da6bfc0789d
|
7
|
+
data.tar.gz: aeaa99517adefad8f1929096332883781caa2f492527ad1febd50d2e8d3ff2440090f28757f34efc40705131abc2714c807d3792e5f43fda859b824f4c32d380
|
data/doc/resource_types.md
CHANGED
@@ -14,6 +14,7 @@
|
|
14
14
|
| [ecs_container_instance](#ecs_container_instance)
|
15
15
|
| [ecs_service](#ecs_service)
|
16
16
|
| [ecs_task_definition](#ecs_task_definition)
|
17
|
+
| [efs](#efs)
|
17
18
|
| [elasticache](#elasticache)
|
18
19
|
| [elasticache_cache_parameter_group](#elasticache_cache_parameter_group)
|
19
20
|
| [elasticsearch](#elasticsearch)
|
@@ -521,6 +522,28 @@ EcsTaskDefinition resource type.
|
|
521
522
|
### be_inactive
|
522
523
|
|
523
524
|
|
525
|
+
## <a name="efs">efs</a>
|
526
|
+
|
527
|
+
EFS resource type.
|
528
|
+
|
529
|
+
### exist
|
530
|
+
|
531
|
+
```ruby
|
532
|
+
describe efs('my-efs') do
|
533
|
+
it { should exist }
|
534
|
+
end
|
535
|
+
```
|
536
|
+
|
537
|
+
|
538
|
+
### have_tag
|
539
|
+
|
540
|
+
```ruby
|
541
|
+
describe efs('my-efs') do
|
542
|
+
it { should have_tag('my-key').value('my-value') }
|
543
|
+
end
|
544
|
+
```
|
545
|
+
|
546
|
+
### its(:owner_id), its(:creation_token), its(:file_system_id), its(:creation_time), its(:life_cycle_state), its(:name), its(:number_of_mount_targets), its(:performance_mode)
|
524
547
|
## <a name="elasticache">elasticache</a>
|
525
548
|
|
526
549
|
Elasticache resource type.
|
@@ -25,7 +25,7 @@ module Awspec
|
|
25
25
|
puts Awspec::Generator::Spec::Route53HostedZone.new.generate_by_domain_name(hosted_zone)
|
26
26
|
end
|
27
27
|
|
28
|
-
desc 's3_bucket [
|
28
|
+
desc 's3_bucket [bucket_name]', 'Generate s3_bucket spec from S3 bucket name. if NO args, Generate all.'
|
29
29
|
def s3_bucket(bucket_name = nil)
|
30
30
|
Awsecrets.load(profile: options[:profile], region: options[:region], secrets_path: options[:secrets_path])
|
31
31
|
if bucket_name
|
@@ -36,8 +36,8 @@ module Awspec
|
|
36
36
|
end
|
37
37
|
|
38
38
|
types_for_generate_all = %w(
|
39
|
-
cloudwatch_alarm cloudwatch_event directconnect
|
40
|
-
|
39
|
+
cloudwatch_alarm cloudwatch_event directconnect ebs efs
|
40
|
+
elasticsearch iam_group iam_policy iam_role iam_user kms lambda
|
41
41
|
)
|
42
42
|
|
43
43
|
types_for_generate_all.each do |type|
|
data/lib/awspec/generator.rb
CHANGED
@@ -4,6 +4,7 @@ require 'awspec/generator/spec/rds'
|
|
4
4
|
require 'awspec/generator/spec/vpc'
|
5
5
|
require 'awspec/generator/spec/security_group'
|
6
6
|
require 'awspec/generator/spec/route53_hosted_zone'
|
7
|
+
require 'awspec/generator/spec/efs'
|
7
8
|
require 'awspec/generator/spec/elb'
|
8
9
|
require 'awspec/generator/spec/iam_policy'
|
9
10
|
require 'awspec/generator/spec/kms'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Doc
|
3
|
+
module Type
|
4
|
+
class Efs < Base
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@type_name = 'EFS'
|
8
|
+
@type = Awspec::Type::Efs.new('my-efs')
|
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,28 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Spec
|
3
|
+
class Efs
|
4
|
+
include Awspec::Helper::Finder
|
5
|
+
def generate_all
|
6
|
+
file_systems = select_all_file_systems
|
7
|
+
raise 'EFS not found' if file_systems.empty?
|
8
|
+
specs = file_systems.map do |file_system|
|
9
|
+
file_system.name = get_name_by_id(file_system.file_system_id)
|
10
|
+
content = ERB.new(file_system_spec_template, nil, '-').result(binding).gsub(/^\n/, '')
|
11
|
+
end
|
12
|
+
specs.join("\n")
|
13
|
+
end
|
14
|
+
|
15
|
+
def file_system_spec_template
|
16
|
+
template = <<-'EOF'
|
17
|
+
describe efs('<%= file_system.name %>') do
|
18
|
+
it { should exist }
|
19
|
+
its(:number_of_mount_targets) { should eq <%= file_system.number_of_mount_targets %> }
|
20
|
+
its(:life_cycle_state) { should eq '<%= file_system.life_cycle_state %>' }
|
21
|
+
its(:performance_mode) { should eq '<%= file_system.performance_mode %>' }
|
22
|
+
end
|
23
|
+
EOF
|
24
|
+
template
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -87,9 +87,10 @@ EOF
|
|
87
87
|
def self.put_message
|
88
88
|
content = <<-"EOF"
|
89
89
|
|
90
|
-
|
90
|
+
Generate #{@type.camelize} template files.
|
91
91
|
|
92
92
|
* !! AND add '#{@type.underscore}' to Awspec::Helper::Type::TYPES in lib/awspec/helper/type.rb *
|
93
|
+
* !! AND add '#{@type.underscore}' client to lib/awspec/helper/finder.rb *
|
93
94
|
|
94
95
|
EOF
|
95
96
|
end
|
data/lib/awspec/helper/finder.rb
CHANGED
@@ -5,6 +5,7 @@ require 'awspec/helper/finder/subnet'
|
|
5
5
|
require 'awspec/helper/finder/ec2'
|
6
6
|
require 'awspec/helper/finder/ecr'
|
7
7
|
require 'awspec/helper/finder/ecs'
|
8
|
+
require 'awspec/helper/finder/efs'
|
8
9
|
require 'awspec/helper/finder/security_group'
|
9
10
|
require 'awspec/helper/finder/rds'
|
10
11
|
require 'awspec/helper/finder/route53'
|
@@ -35,6 +36,7 @@ module Awspec::Helper
|
|
35
36
|
include Awspec::Helper::Finder::Ec2
|
36
37
|
include Awspec::Helper::Finder::Ecr
|
37
38
|
include Awspec::Helper::Finder::Ecs
|
39
|
+
include Awspec::Helper::Finder::Efs
|
38
40
|
include Awspec::Helper::Finder::SecurityGroup
|
39
41
|
include Awspec::Helper::Finder::Rds
|
40
42
|
include Awspec::Helper::Finder::Route53
|
@@ -61,6 +63,7 @@ module Awspec::Helper
|
|
61
63
|
ec2_client: Aws::EC2::Client,
|
62
64
|
ecr_client: Aws::ECR::Client,
|
63
65
|
ecs_client: Aws::ECS::Client,
|
66
|
+
efs_client: Aws::EFS::Client,
|
64
67
|
rds_client: Aws::RDS::Client,
|
65
68
|
route53_client: Aws::Route53::Client,
|
66
69
|
s3_client: Aws::S3::Client,
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Awspec::Helper
|
2
|
+
module Finder
|
3
|
+
module Efs
|
4
|
+
def find_efs(id)
|
5
|
+
begin
|
6
|
+
res = efs_client.describe_file_systems({
|
7
|
+
file_system_id: id,
|
8
|
+
max_items: 1
|
9
|
+
})
|
10
|
+
rescue
|
11
|
+
# Aws::EFS::Errors::BadRequest (invalid file system ID: my-efs)
|
12
|
+
file_system_id = get_id_by_name_tag(id)
|
13
|
+
res = efs_client.describe_file_systems({
|
14
|
+
file_system_id: file_system_id,
|
15
|
+
max_items: 1
|
16
|
+
})
|
17
|
+
end
|
18
|
+
res.file_systems.single_resource(id)
|
19
|
+
end
|
20
|
+
|
21
|
+
def find_tags(id, tag_key)
|
22
|
+
begin
|
23
|
+
tag_set = efs_client.describe_tags({ file_system_id: id })
|
24
|
+
rescue
|
25
|
+
# Aws::EFS::Errors::BadRequest (invalid file system ID: my-efs)
|
26
|
+
file_system_id = get_id_by_name_tag(id)
|
27
|
+
tag_set = efs_client.describe_tags({
|
28
|
+
file_system_id: file_system_id
|
29
|
+
})
|
30
|
+
end
|
31
|
+
tag_query = tag_set.tags.find { |tag| tag.key == tag_key }
|
32
|
+
return tag_query if tag_query
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_id_by_name_tag(name)
|
36
|
+
# takes a name tag and iterates inventory and returns file_system obj
|
37
|
+
inventory = efs_client.describe_file_systems
|
38
|
+
inventory.file_systems.each do |fs|
|
39
|
+
tag_query = efs_client.describe_tags({
|
40
|
+
file_system_id: fs.file_system_id
|
41
|
+
})
|
42
|
+
name_tag = tag_query.find { |tag| tag.key == 'Name' }
|
43
|
+
return fs.file_system_id if name_tag.value == name
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def get_name_by_id(id)
|
48
|
+
tag_query = efs_client.describe_tags({
|
49
|
+
file_system_id: id
|
50
|
+
})
|
51
|
+
name_tag = tag_query.tags.find { |tag| tag.key == 'Name' }
|
52
|
+
return name_tag.value if name_tag
|
53
|
+
end
|
54
|
+
|
55
|
+
def select_all_file_systems
|
56
|
+
file_systems_query = efs_client.describe_file_systems
|
57
|
+
file_systems = file_systems_query.file_systems
|
58
|
+
file_systems
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/awspec/helper/type.rb
CHANGED
@@ -6,7 +6,7 @@ module Awspec
|
|
6
6
|
TYPES = %w(
|
7
7
|
alb ami autoscaling_group cloudtrail cloudwatch_alarm cloudwatch_event directconnect_virtual_interface
|
8
8
|
ebs ec2 ecr_repository ecs_cluster ecs_container_instance ecs_service ecs_task_definition
|
9
|
-
elasticache elasticache_cache_parameter_group elasticsearch elb iam_group
|
9
|
+
efs elasticache elasticache_cache_parameter_group elasticsearch elb iam_group
|
10
10
|
iam_policy iam_role iam_user kms lambda launch_configuration nat_gateway
|
11
11
|
network_acl network_interface rds rds_db_cluster_parameter_group rds_db_parameter_group route53_hosted_zone
|
12
12
|
route_table s3_bucket security_group ses_identity subnet vpc cloudfront_distribution
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Aws.config[:efs] = {
|
2
|
+
stub_responses: {
|
3
|
+
describe_file_systems: {
|
4
|
+
file_systems: [
|
5
|
+
{
|
6
|
+
size_in_bytes: {
|
7
|
+
timestamp: Time.new(2017, 1, 2, 10, 0, 0, '+00:00'),
|
8
|
+
value: 6144
|
9
|
+
},
|
10
|
+
creation_token: 'console-1234abcd-1234-abcd-1234-abcd56789012',
|
11
|
+
creation_time: Time.new(2017, 1, 2, 10, 0, 0, '+00:00'),
|
12
|
+
file_system_id: 'fs-5678acdc',
|
13
|
+
number_of_mount_targets: 1,
|
14
|
+
life_cycle_state: 'available',
|
15
|
+
owner_id: '123456789012',
|
16
|
+
performance_mode: 'generalPurpose'
|
17
|
+
}
|
18
|
+
]
|
19
|
+
},
|
20
|
+
describe_tags: {
|
21
|
+
tags: [
|
22
|
+
{
|
23
|
+
value: 'my-value',
|
24
|
+
key: 'my-key'
|
25
|
+
},
|
26
|
+
{
|
27
|
+
value: 'my-efs',
|
28
|
+
key: 'Name'
|
29
|
+
}
|
30
|
+
]
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Awspec::Type
|
2
|
+
class Efs < Base
|
3
|
+
def initialize(file_system_id)
|
4
|
+
super
|
5
|
+
@display_name = file_system_id
|
6
|
+
end
|
7
|
+
|
8
|
+
def resource_via_client
|
9
|
+
@resource_via_client ||= find_efs(@display_name)
|
10
|
+
end
|
11
|
+
|
12
|
+
def id
|
13
|
+
@id ||= resource_via_client.file_system_id if resource_via_client
|
14
|
+
end
|
15
|
+
|
16
|
+
def has_tag?(tag_key, tag_value)
|
17
|
+
tag = find_tags(@display_name, tag_key)
|
18
|
+
return nil if tag.value != tag_value
|
19
|
+
tag
|
20
|
+
end
|
21
|
+
end
|
22
|
+
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.64.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-01-
|
11
|
+
date: 2017-01-19 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/directconnect_virtual_interface.md
|
217
217
|
- doc/_resource_types/ebs.md
|
218
218
|
- doc/_resource_types/ec2.md
|
219
|
+
- doc/_resource_types/efs.md
|
219
220
|
- doc/_resource_types/elasticache.md
|
220
221
|
- doc/_resource_types/elasticache_cache_parameter_group.md
|
221
222
|
- doc/_resource_types/elasticsearch.md
|
@@ -273,6 +274,7 @@ files:
|
|
273
274
|
- lib/awspec/generator/doc/type/ecs_container_instance.rb
|
274
275
|
- lib/awspec/generator/doc/type/ecs_service.rb
|
275
276
|
- lib/awspec/generator/doc/type/ecs_task_definition.rb
|
277
|
+
- lib/awspec/generator/doc/type/efs.rb
|
276
278
|
- lib/awspec/generator/doc/type/elasticache.rb
|
277
279
|
- lib/awspec/generator/doc/type/elasticache_cache_parameter_group.rb
|
278
280
|
- lib/awspec/generator/doc/type/elasticsearch.rb
|
@@ -306,6 +308,7 @@ files:
|
|
306
308
|
- lib/awspec/generator/spec/directconnect.rb
|
307
309
|
- lib/awspec/generator/spec/ebs.rb
|
308
310
|
- lib/awspec/generator/spec/ec2.rb
|
311
|
+
- lib/awspec/generator/spec/efs.rb
|
309
312
|
- lib/awspec/generator/spec/elasticsearch.rb
|
310
313
|
- lib/awspec/generator/spec/elb.rb
|
311
314
|
- lib/awspec/generator/spec/iam_group.rb
|
@@ -340,6 +343,7 @@ files:
|
|
340
343
|
- lib/awspec/helper/finder/ec2.rb
|
341
344
|
- lib/awspec/helper/finder/ecr.rb
|
342
345
|
- lib/awspec/helper/finder/ecs.rb
|
346
|
+
- lib/awspec/helper/finder/efs.rb
|
343
347
|
- lib/awspec/helper/finder/elasticache.rb
|
344
348
|
- lib/awspec/helper/finder/elasticsearch.rb
|
345
349
|
- lib/awspec/helper/finder/elastictranscoder.rb
|
@@ -400,6 +404,7 @@ files:
|
|
400
404
|
- lib/awspec/stub/ecs_container_instance.rb
|
401
405
|
- lib/awspec/stub/ecs_service.rb
|
402
406
|
- lib/awspec/stub/ecs_task_definition.rb
|
407
|
+
- lib/awspec/stub/efs.rb
|
403
408
|
- lib/awspec/stub/elasticache.rb
|
404
409
|
- lib/awspec/stub/elasticache_cache_parameter_group.rb
|
405
410
|
- lib/awspec/stub/elasticsearch.rb
|
@@ -446,6 +451,7 @@ files:
|
|
446
451
|
- lib/awspec/type/ecs_container_instance.rb
|
447
452
|
- lib/awspec/type/ecs_service.rb
|
448
453
|
- lib/awspec/type/ecs_task_definition.rb
|
454
|
+
- lib/awspec/type/efs.rb
|
449
455
|
- lib/awspec/type/elasticache.rb
|
450
456
|
- lib/awspec/type/elasticache_cache_parameter_group.rb
|
451
457
|
- lib/awspec/type/elasticsearch.rb
|