User guide
var action = new ActionIdentifier("sts:AssumeRole");
var actions = new List<ActionIdentifier>();
actions.Add(action);
var principal = new Principal("ec2.amazonaws.com")
{
Provider = "Service"
};
var principals = new List<Principal>();
principals.Add(principal);
var statement = new Statement(Statement.StatementEffect.Allow)
{
Actions = actions,
Id = "DemoEC2TrustStatement",
Principals = principals
};
var statements = new List<Statement>();
statements.Add(statement);
var policy = new Policy
{
Id = "DemoEC2Trust",
Version = "2012-10-17",
Statements = statements
};
return policy.ToJson();
}
Add a User Account to a Group
The following example adds an existing user account to an existing group and then displays a list of the
group's associated user accounts:
// using Amazon.IdentityManagement.Resources;
// using Amazon.IdentityManagement.Model;
var iam = new IdentityManagementService();
try
{
var group = iam.GetGroupByName("DemoGroup");
group.AddUser("DemoUser");
Console.WriteLine("Users in group {0}:", group.Name);
foreach (var user in group.GetUsers())
{
Console.WriteLine(" {0}", user.Name);
}
Version v2.0.0
100
AWS SDK for .NET Developer Guide
IAM Resource API Examples