Class: Aws::IAM::InstanceProfile

Inherits:
Object
  • Object
show all
Extended by:
Deprecations
Defined in:
lib/aws-sdk-iam/instance_profile.rb

Defined Under Namespace

Classes: Collection

Read-Only Attributes collapse

Actions collapse

Associations collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ InstanceProfile #initialize(options = {}) ⇒ InstanceProfile

Returns a new instance of InstanceProfile.

Overloads:

  • #initialize(name, options = {}) ⇒ InstanceProfile

    Parameters:

    • name (String)

    Options Hash (options):

  • #initialize(options = {}) ⇒ InstanceProfile

    Options Hash (options):

    • :name (required, String)
    • :client (Client)


19
20
21
22
23
24
# File 'lib/aws-sdk-iam/instance_profile.rb', line 19

def initialize(*args)
  options = Hash === args.last ? args.pop.dup : {}
  @name = extract_name(args, options)
  @data = options.delete(:data)
  @client = options.delete(:client) || Client.new(options)
end

Instance Method Details

#add_role(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


instance_profile.add_role({
  role_name: "roleNameType", # required
})

Parameters:

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

    ({})

Options Hash (options):

  • :role_name (required, String)

    The name of the role to add.

    This parameter allows (per its [regex pattern]) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-

    [1]: wikipedia.org/wiki/regex

Returns:

  • (EmptyStructure)


161
162
163
164
165
# File 'lib/aws-sdk-iam/instance_profile.rb', line 161

def add_role(options = {})
  options = options.merge(instance_profile_name: @name)
  resp = @client.add_role_to_instance_profile(options)
  resp.data
end

#arnString

The Amazon Resource Name (ARN) specifying the instance profile. For more information about ARNs and how to use them in policies, see [IAM Identifiers] in the *Using IAM* guide.

[1]: docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html

Returns:

  • (String)


65
66
67
# File 'lib/aws-sdk-iam/instance_profile.rb', line 65

def arn
  data.arn
end

#clientClient

Returns:



78
79
80
# File 'lib/aws-sdk-iam/instance_profile.rb', line 78

def client
  @client
end

#create_dateTime

The date when the instance profile was created.

Returns:

  • (Time)


71
72
73
# File 'lib/aws-sdk-iam/instance_profile.rb', line 71

def create_date
  data.create_date
end

#dataTypes::InstanceProfile

Returns the data for this Aws::IAM::InstanceProfile. Calls Client#get_instance_profile if #data_loaded? is ‘false`.

Returns:



98
99
100
101
# File 'lib/aws-sdk-iam/instance_profile.rb', line 98

def data
  load unless @data
  @data
end

#data_loaded?Boolean

Returns ‘true` if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.

Returns:

  • (Boolean)

    Returns ‘true` if this resource is loaded. Accessing attributes or #data on an unloaded resource will trigger a call to #load.



106
107
108
# File 'lib/aws-sdk-iam/instance_profile.rb', line 106

def data_loaded?
  !!@data
end

#delete(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


instance_profile.delete()

Parameters:

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

    ({})

Returns:

  • (EmptyStructure)


172
173
174
175
176
# File 'lib/aws-sdk-iam/instance_profile.rb', line 172

def delete(options = {})
  options = options.merge(instance_profile_name: @name)
  resp = @client.delete_instance_profile(options)
  resp.data
end

#exists?(options = {}) ⇒ Boolean

Returns ‘true` if the InstanceProfile exists.

Parameters:

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

    ({})

Returns:

  • (Boolean)

    Returns ‘true` if the InstanceProfile exists.



113
114
115
116
117
118
119
120
121
122
# File 'lib/aws-sdk-iam/instance_profile.rb', line 113

def exists?(options = {})
  begin
    wait_until_exists(options.merge(max_attempts: 1))
    true
  rescue Aws::Waiters::Errors::UnexpectedError => e
    raise e.error
  rescue Aws::Waiters::Errors::WaiterFailed
    false
  end
end

#identifiersObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Deprecated.


219
220
221
# File 'lib/aws-sdk-iam/instance_profile.rb', line 219

def identifiers
  { name: @name }
end

#instance_profile_idString

The stable and unique string identifying the instance profile. For more information about IDs, see [IAM Identifiers] in the *Using IAM* guide.

[1]: docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html

Returns:

  • (String)


53
54
55
# File 'lib/aws-sdk-iam/instance_profile.rb', line 53

def instance_profile_id
  data.instance_profile_id
end

#loadself Also known as: reload

Loads, or reloads #data for the current Aws::IAM::InstanceProfile. Returns ‘self` making it possible to chain methods.

instance_profile.reload.data

Returns:

  • (self)


88
89
90
91
92
# File 'lib/aws-sdk-iam/instance_profile.rb', line 88

def load
  resp = @client.get_instance_profile(instance_profile_name: @name)
  @data = resp.instance_profile
  self
end

#nameString Also known as: instance_profile_name

Returns:

  • (String)


29
30
31
# File 'lib/aws-sdk-iam/instance_profile.rb', line 29

def name
  @name
end

#pathString

The path to the instance profile. For more information about paths, see [IAM Identifiers] in the *Using IAM* guide.

[1]: docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html

Returns:

  • (String)


41
42
43
# File 'lib/aws-sdk-iam/instance_profile.rb', line 41

def path
  data.path
end

#remove_role(options = {}) ⇒ EmptyStructure

Examples:

Request syntax with placeholder values


instance_profile.remove_role({
  role_name: "roleNameType", # required
})

Parameters:

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

    ({})

Options Hash (options):

  • :role_name (required, String)

    The name of the role to remove.

    This parameter allows (per its [regex pattern]) a string of characters consisting of upper and lowercase alphanumeric characters with no spaces. You can also include any of the following characters: _+=,.@-

    [1]: wikipedia.org/wiki/regex

Returns:

  • (EmptyStructure)


196
197
198
199
200
# File 'lib/aws-sdk-iam/instance_profile.rb', line 196

def remove_role(options = {})
  options = options.merge(instance_profile_name: @name)
  resp = @client.remove_role_from_instance_profile(options)
  resp.data
end

#rolesRole::Collection

Returns:



205
206
207
208
209
210
211
212
213
214
215
# File 'lib/aws-sdk-iam/instance_profile.rb', line 205

def roles
  batch = []
  data.roles.each do |r|
    batch << Role.new(
      name: r.role_name,
      data: r,
      client: @client
    )
  end
  Role::Collection.new([batch], size: batch.size)
end

#wait_until_exists(options = {}) ⇒ InstanceProfile

Parameters:

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

    ({})

Options Hash (options):

  • :max_attempts (Integer) — default: 40
  • :delay (Float) — default: 1
  • :before_attempt (Proc)
  • :before_wait (Proc)

Returns:



130
131
132
133
134
135
136
137
138
139
# File 'lib/aws-sdk-iam/instance_profile.rb', line 130

def wait_until_exists(options = {})
  options, params = separate_params_and_options(options)
  waiter = Waiters::InstanceProfileExists.new(options)
  yield_waiter_and_warn(waiter, &Proc.new) if block_given?
  waiter.wait(params.merge(instance_profile_name: @name))
  InstanceProfile.new({
    name: @name,
    client: @client
  })
end