Class: AWS::IAM::SigningCertificate

Inherits:
Resource
  • Object
show all
Defined in:
lib/aws/iam/signing_certificate.rb

Overview

Signing certificates can be activated and deactivated. By default, newly-uploaded certifictes are active.

certificate = iam.signing_certificates.upload(cert_body)
certificate.status
#=> :active

certificate.deactivate!
certificate.active?
#=> false

Contents

You can access the certificate contents you uploaded:

> puts certificate.contents
-----BEGIN CERTIFICATE-----
MIICdzCCAeCgAwIBAgIFGS4fY6owDQYJKoZIhvcNAQEFBQAwUzELMAkGA1UEBhMC
......
Glli79yh87PRi0vNDlFEoHXNynkvC/c4TiWruZ4haM9BR9EdWr1DBNNu73ui093K
F9TbdXSWdgMl7E0=
-----END CERTIFICATE-----

User

A certificate can also return the user it belongs to. If the certificate belongs to the AWS account, then #user will return nil.

user = iam.users['someuser'].signing_certificates.first
user.name
#=> 'someuser'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#exists?

Constructor Details

#initialize(certificate_id, options = {}) ⇒ SigningCertificate

Returns a new instance of SigningCertificate.

Parameters:

  • certificate_id (String)

    The id of the signing certificate.

  • options (Hash) (defaults to: {})

Options Hash (options):



59
60
61
62
63
# File 'lib/aws/iam/signing_certificate.rb', line 59

def initialize certificate_id, options = {}
  @id = certificate_id
  @user = options[:user]
  @user ? super(@user, options) : super(options)
end

Instance Attribute Details

#contentsString (readonly)

Returns the contents of this signing certificate.

Returns:

  • (String)

    the current value of contents



54
55
56
# File 'lib/aws/iam/signing_certificate.rb', line 54

def contents
  @contents
end

#idString (readonly)

Returns the signing certificate’s ID.

Returns:

  • (String)

    Returns the signing certificate’s ID.



66
67
68
# File 'lib/aws/iam/signing_certificate.rb', line 66

def id
  @id
end

#statusSymbol (readonly)

The status of this signing certificate. Status may be :active or :inactive.

Returns:

  • (Symbol)

    the current value of status



54
55
56
# File 'lib/aws/iam/signing_certificate.rb', line 54

def status
  @status
end

#userUser? (readonly)

Returns the user this cerficiate belongs to.

Returns nil if the cerficiate is a root credential for the account. If the configured credentials belong to an IAM user, then that user is the implied owner.

Returns:

  • (User, nil)

    Returns the user this cerficiate belongs to.

    Returns nil if the cerficiate is a root credential for the account. If the configured credentials belong to an IAM user, then that user is the implied owner.



72
73
74
# File 'lib/aws/iam/signing_certificate.rb', line 72

def user
  @user
end

Instance Method Details

#activate!nil

Activates this signing cerificate.

Examples:

signing_certificate.activate!
signing_certificate.status
# => :active

Returns:

  • (nil)


116
117
118
119
# File 'lib/aws/iam/signing_certificate.rb', line 116

def activate!
  self.status = 'Active'
  nil
end

#active?Boolean

Returns true if this signing certificate is active.

Returns:

  • (Boolean)

    Returns true if this signing certificate is active.



99
100
101
# File 'lib/aws/iam/signing_certificate.rb', line 99

def active?
  status == :active
end

#deactivate!nil

Deactivates this signing cerificate.

Examples:

signing_certificate.deactivate!
signing_certificate.status
# => :inactive

Returns:

  • (nil)


129
130
131
132
# File 'lib/aws/iam/signing_certificate.rb', line 129

def deactivate!
  self.status = 'Inactive'
  nil
end

#deleteObject

Deletes the signing certificate.



135
136
137
138
# File 'lib/aws/iam/signing_certificate.rb', line 135

def delete
  client.delete_signing_certificate(resource_options)
  nil
end

#inactive?Boolean

Returns true if this signing certificate is inactive.

Returns:

  • (Boolean)

    Returns true if this signing certificate is inactive.



104
105
106
# File 'lib/aws/iam/signing_certificate.rb', line 104

def inactive?
  status == :inactive
end

#user_nameString?

Returns the name of the user this certificate belogns to. If the certificate belongs to the account, nil is returned.

Returns:

  • (String, nil)

    Returns the name of the user this certificate belogns to. If the certificate belongs to the account, nil is returned.



94
95
96
# File 'lib/aws/iam/signing_certificate.rb', line 94

def user_name
  @user ? @user.name : nil
end