Amazon AWS SDK Guide de l'utilisateur Page 107

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 155
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 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
Vue de la page 106
1 2 ... 102 103 104 105 106 107 108 109 110 111 112 ... 154 155

Commentaires sur ces manuels

Pas de commentaire