Class: AwsEbsVolumes

Inherits:
Object
  • Object
show all
Includes:
AwsPluralResourceMixin
Defined in:
lib/resources/aws/aws_ebs_volumes.rb

Defined Under Namespace

Classes: Backend

Instance Attribute Summary

Attributes included from AwsPluralResourceMixin

#table

Instance Method Summary collapse

Methods included from AwsPluralResourceMixin

included

Methods included from AwsResourceMixin

#catch_aws_errors, #check_resource_param_names, #initialize, #inspec_runner

Instance Method Details

#fetch_from_apiObject



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/resources/aws/aws_ebs_volumes.rb', line 29

def fetch_from_api
  backend = BackendFactory.create(inspec_runner)
  @table = []
  pagination_opts = {}
  loop do
    api_result = backend.describe_volumes(pagination_opts)
    @table += unpack_describe_volumes_response(api_result.volumes)
    break unless api_result.next_token
    pagination_opts = { next_token: api_result.next_token }
  end
end

#to_sObject



25
26
27
# File 'lib/resources/aws/aws_ebs_volumes.rb', line 25

def to_s
  'EBS Volumes'
end

#unpack_describe_volumes_response(volumes) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/resources/aws/aws_ebs_volumes.rb', line 41

def unpack_describe_volumes_response(volumes)
  volume_rows = []
  volumes.each do |res|
    volume_rows += res.attachments.map do |volume_struct|
      {
        volume_id: volume_struct.volume_id,
      }
    end
  end
  volume_rows
end

#validate_params(resource_params) ⇒ Object



12
13
14
15
16
17
# File 'lib/resources/aws/aws_ebs_volumes.rb', line 12

def validate_params(resource_params)
  unless resource_params.empty?
    raise ArgumentError, 'aws_ebs_volumes does not accept resource parameters.'
  end
  resource_params
end