Amazon AWS SDK Uživatelská příručka Strana 107

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 155
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 106
group.CreatePolicy(policyDoc, "ListDeploymentConfigsPolicy");
Console.WriteLine("Policies for group {0}:", group.Name);
foreach (var policyItem in group.GetPolicies())
{
Console.WriteLine(" {0}", policyItem.Name);
}
}
catch (NoSuchEntityException)
{
Console.WriteLine("Group 'DemoGroup' does not exist.");
}
The preceding example relies on the following example to create the new policy.
The following example doesn't use the AWS Resource APIs for .NET, as the resource APIs currently
don't support creating a policy document. However, this example is presented for completeness:
public static string GenerateGroupPolicyDocument()
{
// using Amazon.Auth.AccessControlPolicy;
// Create a policy that looks like this:
/*
{
"Version" : "2012-10-17",
"Id": "ListDeploymentConfigsPolicy",
"Statement" : [
{
"Sid" : "ListDeploymentConfigsStatement",
"Effect" : "Allow",
"Action" : "codedeploy:ListDeploymentConfigs",
"Resource" : "*"
}
]
}
*/
var action = new ActionIdentifier("codedeploy:ListDeploymentConfigs");
var actions = new List<ActionIdentifier>();
actions.Add(action);
var resource = new Resource("*");
var resources = new List<Resource>();
resources.Add(resource);
var statement = new Statement(Statement.StatementEffect.Allow)
{
Actions = actions,
Id = "ListDeploymentConfigsStatement",
Resources = resources
};
var statements = new List<Statement>();
Version v2.0.0
103
AWS SDK for .NET Developer Guide
IAM Resource API Examples
Zobrazit stránku 106
1 2 ... 102 103 104 105 106 107 108 109 110 111 112 ... 154 155

Komentáře k této Příručce

Žádné komentáře