User guide

var iam = new IdentityManagementService();
try
{
var user = iam.GetUserByName("DemoUser");
var accessKey = user.CreateAccessKey();
Console.WriteLine("For user {0}:", user.Name);
Console.WriteLine(" Access key = {0}", accessKey.Id);
// This is the only time that the secret access key will be displayed.
Console.WriteLine(" Secret access key = {0}", accessKey.SecretAccessKey);
}
catch (NoSuchEntityException)
{
Console.WriteLine("User 'DemoUser' does not exist.");
}
catch (LimitExceededException)
{
Console.WriteLine("You can have only 2 access keys per user.");
}
Create a Login Profile for a User Account
The following example creates a login profile for a user account.
The following example doesn't use the AWS Resource APIs for .NET, as the resource APIs currently
don't support creating a login profile for a user account. However, this example is presented for
completeness:
// using Amazon.IdentityManagement;
// using Amazon.IdentityManagement.Model;
var client = new AmazonIdentityManagementServiceClient();
var request = new CreateLoginProfileRequest
{
UserName = "DemoUser",
Password = "ksdD9JHm",
PasswordResetRequired = true
};
try
{
client.CreateLoginProfile(request);
}
catch (NoSuchEntityException)
{
Console.WriteLine("User 'DemoUser' doesn't exist.");
}
Create an Instance Profile
The following example creates an instance profile.
The following example doesn't use the AWS Resource APIs for .NET, as the resource APIs currently
don't support creating an instance profile. However, this example is presented for completeness:
Version v2.0.0
106
AWS SDK for .NET Developer Guide
IAM Resource API Examples