Class: AwsIamAccessKeys

Inherits:
Object
  • Object
show all
Includes:
AwsPluralResourceMixin
Defined in:
lib/resources/aws/aws_iam_access_keys.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



32
33
34
35
36
37
# File 'lib/resources/aws/aws_iam_access_keys.rb', line 32

def fetch_from_api
  # TODO: this interface should be normalized to match the AWS API
  criteria = {}
  criteria[:username] = @username if defined? @username
  @table = BackendFactory.create(inspec_runner).fetch(criteria)
end

#to_sObject



60
61
62
# File 'lib/resources/aws/aws_iam_access_keys.rb', line 60

def to_s
  'IAM Access Keys'
end

#validate_params(raw_params) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/resources/aws/aws_iam_access_keys.rb', line 13

def validate_params(raw_params)
  recognized_params = check_resource_param_names(
    raw_params: raw_params,
    allowed_params: [:username, :id, :access_key_id, :created_date],
    allowed_scalar_name: :access_key_id,
    allowed_scalar_type: String,
  )

  # id and access_key_id are aliases; standardize on access_key_id
  recognized_params[:access_key_id] = recognized_params.delete(:id) if recognized_params.key?(:id)
  if recognized_params[:access_key_id] and
     recognized_params[:access_key_id] !~ /^AKIA[0-9A-Z]{16}$/
    raise 'Incorrect format for Access Key ID - expected AKIA followed ' \
          'by 16 letters or numbers'
  end

  recognized_params
end