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



36
37
38
39
40
41
# File 'lib/resources/aws/aws_iam_access_keys.rb', line 36

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



62
63
64
# File 'lib/resources/aws/aws_iam_access_keys.rb', line 62

def to_s
  "IAM Access Keys"
end

#validate_params(raw_params) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/resources/aws/aws_iam_access_keys.rb', line 17

def validate_params(raw_params)
  recognized_params = check_resource_param_names(
    raw_params: raw_params,
    allowed_params: %i{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] &&
      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