Class: Miasma::Contrib::Aws::Api::Iam

Inherits:
Types::Api
  • Object
show all
Includes:
Miasma::Contrib::AwsApiCore::ApiCommon, Miasma::Contrib::AwsApiCore::RequestUtils
Defined in:
lib/miasma-aws/api/iam.rb

Overview

IAM helper class

Constant Summary collapse

API_SERVICE =

Service name of the API

"iam".freeze
API_VERSION =

Supported version of the IAM API

"2010-05-08".freeze

Instance Method Summary collapse

Methods included from Miasma::Contrib::AwsApiCore::RequestUtils

#all_result_pages

Methods included from Miasma::Contrib::AwsApiCore::ApiCommon

#after_setup, #api_for, #connection, #custom_setup, #endpoint, #extract_creds, #get_credential, #get_region, included, #load_aws_file, #load_ecs_credentials!, #load_instance_credentials!, #make_request, #perform_request_retry, #retryable_allowed?, #signer, #sts_assume_role!, #sts_assume_role_update_required?, #sts_attribute_update_required?, #sts_mfa_session!, #sts_mfa_session_update_required?, #update_request, #uri_escape

Instance Method Details

#connectObject



18
19
20
21
22
23
24
25
# File 'lib/miasma-aws/api/iam.rb', line 18

def connect
  super
  service_name = self.class::API_SERVICE.downcase
  self.aws_host = [
    service_name,
    api_endpoint,
  ].join(".")
end

#user_infoObject

Fetch current user information



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/miasma-aws/api/iam.rb', line 28

def 
  result = request(
    :path => "/",
    :params => {
      "Action" => "GetUser",
    },
  ).get(:body, "GetUserResponse", "GetUserResult", "User")
  Smash.new(
    :user_id => result["UserId"],
    :path => result["Path"],
    :username => result["UserName"],
    :arn => result["Arn"],
    :created => result["CreateDate"],
    :password_last_used => result["PasswordLastUsed"],
    :account_id => result["Arn"].split(":")[4],
  )
end