Amazon AWS SDK User's Guide Page 101

  • Download
  • Add to my manuals
  • Print
  • Page
    / 155
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 100
}
Console.WriteLine(" Users:");
foreach (var user in group.GetUsers())
{
Console.WriteLine(" {0}", user.Name);
}
}
Get Role Information
The following example displays information about an existing role, including its associated policies and
instance profiles:
// using Amazon.IdentityManagement.Resources;
// using Amazon.IdentityManagement.Model;
var iam = new IdentityManagementService();
try
{
var role = iam.GetRoleByName("DemoEC2");
Console.WriteLine("For role {0}:", role.Name);
Console.WriteLine(" Policies:");
foreach (var policy in role.GetPolicies())
{
Console.WriteLine(" {0}", policy.Name);
}
Console.WriteLine(" InstanceProfiles:");
foreach (var instanceProfile in role.GetInstanceProfiles())
{
Console.WriteLine(" {0}", instanceProfile.Name);
}
}
catch (NoSuchEntityException)
{
Console.WriteLine("Role 'DemoEC2' does not exist.");
}
The following example displays a list of all accessible roles. For each role, its associated policies and
instance profiles are also displayed:
// using Amazon.IdentityManagement.Resources;
var iam = new IdentityManagementService();
var roles = iam.GetRoles();
foreach (var role in roles)
{
Console.WriteLine("For role {0}:", role.Name);
Version v2.0.0
97
AWS SDK for .NET Developer Guide
IAM Resource API Examples
Page view 100
1 2 ... 96 97 98 99 100 101 102 103 104 105 106 ... 154 155

Comments to this Manuals

No comments