Class: Fog::AWS::IAM::Role

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/aws/models/iam/role.rb

Instance Method Summary collapse

Instance Method Details

#attach(policy_or_arn) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/aws/models/iam/role.rb', line 23

def attach(policy_or_arn)
  requires :rolename

  arn = if policy_or_arn.respond_to?(:arn)
          policy_or_arn.arn
        else
          policy_or_arn
        end

  service.attach_role_policy(self.rolename, arn)
end

#attached_policiesObject



47
48
49
50
51
# File 'lib/fog/aws/models/iam/role.rb', line 47

def attached_policies
  requires :rolename

  service.managed_policies(:role_name => self.rolename)
end

#destroyObject



58
59
60
61
62
63
# File 'lib/fog/aws/models/iam/role.rb', line 58

def destroy
  requires :rolename

  service.delete_role(rolename)
  true
end

#detach(policy_or_arn) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fog/aws/models/iam/role.rb', line 35

def detach(policy_or_arn)
  requires :rolename

  arn = if policy_or_arn.respond_to?(:arn)
          policy_or_arn.arn
        else
          policy_or_arn
        end

  service.detach_role_policy(self.rolename, arn)
end

#instance_profilesObject



53
54
55
56
# File 'lib/fog/aws/models/iam/role.rb', line 53

def instance_profiles
  requires :rolename
  service.instance_profiles.load(service.list_instance_profiles_for_role(self.rolename).body["InstanceProfiles"])
end

#saveObject

Raises:

  • (Fog::Errors::Error)


13
14
15
16
17
18
19
20
21
# File 'lib/fog/aws/models/iam/role.rb', line 13

def save
  raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
  requires :rolename
  requires :assume_role_policy_document

  data = service.create_role(rolename, assume_role_policy_document, path).body["Role"]
  merge_attributes(data)
  true
end