Class: AWS::IAM::AccessKey
- Inherits:
-
Resource
- Object
- Resource
- Resource
- AWS::IAM::AccessKey
- Defined in:
- lib/aws/iam/access_key.rb
Instance Attribute Summary collapse
-
#id ⇒ String
(also: #access_key_id)
readonly
Returns the access key id.
-
#status ⇒ Symbol
readonly
The status of this access key.
-
#user ⇒ User?
readonly
Returns the user this access key belongs to.
Instance Method Summary collapse
-
#activate! ⇒ nil
Activates this access key.
-
#active? ⇒ Boolean
Returns true if this access key is active.
-
#credentials ⇒ Hash
Returns a hash that should be saved somewhere safe.
-
#deactivate! ⇒ nil
Deactivates this access key.
-
#delete ⇒ Object
Deletes the access key.
-
#inactive? ⇒ Boolean
Returns true if this access key is inactive.
-
#initialize(access_key_id, options = {}) ⇒ AccessKey
constructor
A new instance of AccessKey.
-
#secret ⇒ String
(also: #secret_access_key)
Returns the secret access key.
-
#user_name ⇒ String?
Returns the name of the user this access key belogns to.
Constructor Details
#initialize(access_key_id, options = {}) ⇒ AccessKey
Returns a new instance of AccessKey.
30 31 32 33 34 35 |
# File 'lib/aws/iam/access_key.rb', line 30 def initialize access_key_id, = {} @id = access_key_id [:secret_value] = nil unless .has_key?(:secret_value) @user = [:user] @user ? super(@user, ) : super() end |
Instance Attribute Details
#id ⇒ String (readonly) Also known as: access_key_id
Returns the access key id.
43 44 45 |
# File 'lib/aws/iam/access_key.rb', line 43 def id @id end |
#status ⇒ Symbol (readonly)
The status of this access key. Status may be :active
or :inactive
.
23 24 25 |
# File 'lib/aws/iam/access_key.rb', line 23 def status @status end |
#user ⇒ User? (readonly)
Returns the user this access key belongs to. Returns nil
if this access key belongs to the AWS account and not a specific user.
40 41 42 |
# File 'lib/aws/iam/access_key.rb', line 40 def user @user end |
Instance Method Details
#activate! ⇒ nil
Activates this access key.
112 113 114 115 |
# File 'lib/aws/iam/access_key.rb', line 112 def activate! self.status = 'Active' nil end |
#active? ⇒ Boolean
Returns true if this access key is active.
95 96 97 |
# File 'lib/aws/iam/access_key.rb', line 95 def active? status == :active end |
#credentials ⇒ Hash
150 151 152 |
# File 'lib/aws/iam/access_key.rb', line 150 def credentials { :access_key_id => id, :secret_access_key => secret } end |
#deactivate! ⇒ nil
Deactivates this access key.
126 127 128 129 |
# File 'lib/aws/iam/access_key.rb', line 126 def deactivate! self.status = 'Inactive' nil end |
#delete ⇒ Object
Deletes the access key.
132 133 134 135 |
# File 'lib/aws/iam/access_key.rb', line 132 def delete client.delete_access_key() nil end |
#inactive? ⇒ Boolean
Returns true if this access key is inactive.
100 101 102 |
# File 'lib/aws/iam/access_key.rb', line 100 def inactive? status == :inactive end |
#secret ⇒ String Also known as: secret_access_key
Returns the secret access key.
You can only access the secret for newly created access keys. Calling secret
on existing access keys raises an error.
81 82 83 |
# File 'lib/aws/iam/access_key.rb', line 81 def secret secret_value or raise 'secret is only available for new access keys' end |
#user_name ⇒ String?
Returns the name of the user this access key belogns to. If the access key belongs to the account, nil
is returned.
90 91 92 |
# File 'lib/aws/iam/access_key.rb', line 90 def user_name @user ? @user.name : nil end |