Class: Aws::IAM::Role
- Inherits:
-
Object
- Object
- Aws::IAM::Role
- Extended by:
- Deprecations
- Defined in:
- lib/aws-sdk-iam/role.rb
Defined Under Namespace
Classes: Collection
Read-Only Attributes collapse
-
#arn ⇒ String
The Amazon Resource Name (ARN) specifying the role.
-
#assume_role_policy_document ⇒ String
The policy that grants an entity permission to assume the role.
-
#create_date ⇒ Time
The date and time, in [ISO 8601 date-time format], when the role was created.
-
#description ⇒ String
A description of the role that you provide.
- #name ⇒ String (also: #role_name)
-
#path ⇒ String
The path to the role.
-
#role_id ⇒ String
The stable and unique string identifying the role.
Actions collapse
- #attach_policy(options = {}) ⇒ EmptyStructure
- #delete(options = {}) ⇒ EmptyStructure
- #detach_policy(options = {}) ⇒ EmptyStructure
Associations collapse
- #assume_role_policy ⇒ AssumeRolePolicy
- #attached_policies(options = {}) ⇒ Policy::Collection
- #identifiers ⇒ Object deprecated private Deprecated.
- #instance_profiles(options = {}) ⇒ InstanceProfile::Collection
- #policies(options = {}) ⇒ RolePolicy::Collection
- #policy(name) ⇒ RolePolicy
Instance Method Summary collapse
- #client ⇒ Client
-
#data ⇒ Types::Role
Returns the data for this Role.
-
#data_loaded? ⇒ Boolean
Returns ‘true` if this resource is loaded.
-
#initialize(*args) ⇒ Role
constructor
A new instance of Role.
- #load ⇒ self (also: #reload)
Constructor Details
#initialize(name, options = {}) ⇒ Role #initialize(options = {}) ⇒ Role
Returns a new instance of Role.
19 20 21 22 23 24 |
# File 'lib/aws-sdk-iam/role.rb', line 19 def initialize(*args) = Hash === args.last ? args.pop.dup : {} @name = extract_name(args, ) @data = .delete(:data) @client = .delete(:client) || Client.new() end |
Instance Method Details
#arn ⇒ String
The Amazon Resource Name (ARN) specifying the role. For more information about ARNs and how to use them in policies, see [IAM Identifiers] in the *IAM User Guide* guide.
[1]: docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html
65 66 67 |
# File 'lib/aws-sdk-iam/role.rb', line 65 def arn data.arn end |
#assume_role_policy ⇒ AssumeRolePolicy
187 188 189 190 191 192 |
# File 'lib/aws-sdk-iam/role.rb', line 187 def assume_role_policy AssumeRolePolicy.new( role_name: @name, client: @client ) end |
#assume_role_policy_document ⇒ String
The policy that grants an entity permission to assume the role.
82 83 84 |
# File 'lib/aws-sdk-iam/role.rb', line 82 def assume_role_policy_document data.assume_role_policy_document end |
#attach_policy(options = {}) ⇒ EmptyStructure
145 146 147 148 149 |
# File 'lib/aws-sdk-iam/role.rb', line 145 def attach_policy( = {}) = .merge(role_name: @name) resp = @client.attach_role_policy() resp.data end |
#attached_policies(options = {}) ⇒ Policy::Collection
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/aws-sdk-iam/role.rb', line 216 def attached_policies( = {}) batches = Enumerator.new do |y| = .merge(role_name: @name) resp = @client.list_attached_role_policies() resp.each_page do |page| batch = [] page.data.attached_policies.each do |a| batch << Policy.new( arn: a.policy_arn, client: @client ) end y.yield(batch) end end Policy::Collection.new(batches) end |
#create_date ⇒ Time
The date and time, in [ISO 8601 date-time format], when the role was created.
76 77 78 |
# File 'lib/aws-sdk-iam/role.rb', line 76 def create_date data.create_date end |
#data ⇒ Types::Role
Returns the data for this Aws::IAM::Role. Calls Client#get_role if #data_loaded? is ‘false`.
115 116 117 118 |
# File 'lib/aws-sdk-iam/role.rb', line 115 def data load unless @data @data end |
#data_loaded? ⇒ Boolean
123 124 125 |
# File 'lib/aws-sdk-iam/role.rb', line 123 def data_loaded? !!@data end |
#delete(options = {}) ⇒ EmptyStructure
156 157 158 159 160 |
# File 'lib/aws-sdk-iam/role.rb', line 156 def delete( = {}) = .merge(role_name: @name) resp = @client.delete_role() resp.data end |
#description ⇒ String
A description of the role that you provide.
88 89 90 |
# File 'lib/aws-sdk-iam/role.rb', line 88 def description data.description end |
#detach_policy(options = {}) ⇒ EmptyStructure
178 179 180 181 182 |
# File 'lib/aws-sdk-iam/role.rb', line 178 def detach_policy( = {}) = .merge(role_name: @name) resp = @client.detach_role_policy() resp.data end |
#identifiers ⇒ Object
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.
294 295 296 |
# File 'lib/aws-sdk-iam/role.rb', line 294 def identifiers { name: @name } end |
#instance_profiles(options = {}) ⇒ InstanceProfile::Collection
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'lib/aws-sdk-iam/role.rb', line 239 def instance_profiles( = {}) batches = Enumerator.new do |y| = .merge(role_name: @name) resp = @client.list_instance_profiles_for_role() resp.each_page do |page| batch = [] page.data.instance_profiles.each do |i| batch << InstanceProfile.new( name: i.instance_profile_name, data: i, client: @client ) end y.yield(batch) end end InstanceProfile::Collection.new(batches) end |
#load ⇒ self Also known as: reload
Loads, or reloads #data for the current Aws::IAM::Role. Returns ‘self` making it possible to chain methods.
role.reload.data
105 106 107 108 109 |
# File 'lib/aws-sdk-iam/role.rb', line 105 def load resp = @client.get_role(role_name: @name) @data = resp.role self end |
#name ⇒ String Also known as: role_name
29 30 31 |
# File 'lib/aws-sdk-iam/role.rb', line 29 def name @name end |
#path ⇒ String
The path to the role. For more information about paths, see [IAM Identifiers] in the *Using IAM* guide.
[1]: docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html
41 42 43 |
# File 'lib/aws-sdk-iam/role.rb', line 41 def path data.path end |
#policies(options = {}) ⇒ RolePolicy::Collection
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/aws-sdk-iam/role.rb', line 263 def policies( = {}) batches = Enumerator.new do |y| = .merge(role_name: @name) resp = @client.list_role_policies() resp.each_page do |page| batch = [] page.data.policy_names.each do |p| batch << RolePolicy.new( role_name: @name, name: p, client: @client ) end y.yield(batch) end end RolePolicy::Collection.new(batches) end |
#policy(name) ⇒ RolePolicy
284 285 286 287 288 289 290 |
# File 'lib/aws-sdk-iam/role.rb', line 284 def policy(name) RolePolicy.new( role_name: @name, name: name, client: @client ) end |
#role_id ⇒ String
The stable and unique string identifying the role. For more information about IDs, see [IAM Identifiers] in the *Using IAM* guide.
[1]: docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html
53 54 55 |
# File 'lib/aws-sdk-iam/role.rb', line 53 def role_id data.role_id end |