You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.

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

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):



61
62
63
64
65
# File 'lib/aws/iam/signing_certificate.rb', line 61

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



56
57
58
# File 'lib/aws/iam/signing_certificate.rb', line 56

def contents
  @contents
end

#idString (readonly)

Returns the signing certificate's ID.

Returns:

  • (String)

    Returns the signing certificate's ID.



68
69
70
# File 'lib/aws/iam/signing_certificate.rb', line 68

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



56
57
58
# File 'lib/aws/iam/signing_certificate.rb', line 56

def status
  @status
end

#upload_dateTime (readonly)

Returns the current value of upload_date

Returns:

  • (Time)

    the current value of upload_date



56
57
58
# File 'lib/aws/iam/signing_certificate.rb', line 56

def upload_date
  @upload_date
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.



74
75
76
# File 'lib/aws/iam/signing_certificate.rb', line 74

def user
  @user
end

Instance Method Details

#activate!nil

Activates this signing cerificate.

Examples:

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

Returns:

  • (nil)


121
122
123
124
# File 'lib/aws/iam/signing_certificate.rb', line 121

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.



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

def active?
  status == :active
end

#deactivate!nil

Deactivates this signing cerificate.

Examples:

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

Returns:

  • (nil)


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

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

#deleteObject

Deletes the signing certificate.



140
141
142
143
# File 'lib/aws/iam/signing_certificate.rb', line 140

def delete
  client.delete_signing_certificate(resource_options)
  nil
end

#exists?Boolean

Returns true if the resource exists.

Returns:

  • (Boolean)

    Returns true if the resource exists.



146
147
148
149
150
151
152
153
154
155
# File 'lib/aws/iam/signing_certificate.rb', line 146

def exists?
  exists = false
  SigningCertificateCollection.new(:config => config).each do |cert|
    if cert.id == self.id
      exists = true
      break
    end
  end
  exists
end

#inactive?Boolean

Returns true if this signing certificate is inactive.

Returns:

  • (Boolean)

    Returns true if this signing certificate is inactive.



109
110
111
# File 'lib/aws/iam/signing_certificate.rb', line 109

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.



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

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