ruby/example_code/iam/iam-ruby-example-access-keys.rb
# Deactivates an access key in AWS Identity and Access Management (IAM).
#
# Prerequisites:
# - A user in IAM.
# - An access key for that user.
#
# @param iam [Aws::IAM::Client] An initialized IAM client.
# @param user_name [String] The name of the user.
# @param access_key_id [String] The ID of the access key.
# @return [Boolean] true if the access key was deactivated;
#   otherwise, false.
# @example
#   exit 1 unless access_key_deactivated?(
#     Aws::IAM::Client.new,
#     'my-user',
#     'AKIAIOSFODNN7EXAMPLE'
#   )

Deactivates an access key in AWS Identity and Access Management (IAM).
Prerequisites:
A user in IAM.
An access key for that user.
Deactivates an access key in AWS Identity and Access Management ( IAM ) . Prerequisites : A user in IAM . An access key for that user .
def access_key_deactivated?(iam, user_name, access_key_id)
  iam.update_access_key(
    user_name: user_name,
    access_key_id: access_key_id,
    status: 'Inactive'
  )
  return true
rescue StandardError => e
  puts "Error deactivating access key: #{e.message}"
  return false
end
def access_key_deactivated? ( iam , user_name , access_key_id ) iam . update_access_key ( user_name : user_name , access_key_id : access_key_id , status : 'Inactive' ) return true rescue StandardError => e puts "Error deactivating access key: #{e.message}" return false end
Deactivates an access key in AWS Identity and Access Management (IAM).
Deactivates an access key in AWS Identity and Access Management ( IAM ) .
true if the access key was deactivated; otherwise, false.
true if the access key was deactivated ; otherwise false .
Boolean
iam
An initialized IAM client.
An initialized IAM client .
user_name
The name of the user.
The name of the user .
access_key_id
The ID of the access key.
The ID of the access key .
example
exit 1 unless access_key_deactivated?( Aws::IAM::Client.new, 'my-user', 'AKIAIOSFODNN7EXAMPLE' )
exit 1 unless access_key_deactivated? ( Aws :: IAM :: Client . new ' my - user ' ' AKIAIOSFODNN7EXAMPLE ' )