in Storage/Glacier/SampleApplication/Program.cs [96:134]
static void SetVaultAccessPolicy(IAmazonGlacier glacier)
{
// note - the actual account ID is required in the arn being constructed
// here; it should have been set by modifying the sample code before running
// or, if left as '-' by default, by the vault creation logic.
var jsonPolicy = @"{
""Version"":""2012-10-17"",
""Statement"":[
{
""Sid"": ""glacier-perm"",
""Principal"": {""AWS"":""arn:aws:iam::" + _accountId + @":root""},
""Effect"": ""Allow"",
""Action"": [
""glacier:*""
],
""Resource"": [
""arn:aws:glacier:us-west-2:" + _accountId + @":vaults/" + VaultName + @"""
]
}
]
}";
var req = new SetVaultAccessPolicyRequest
{
VaultName = VaultName,
Policy = new VaultAccessPolicy
{
Policy = jsonPolicy
}
};
Task<SetVaultAccessPolicyResponse> res = glacier.SetVaultAccessPolicyAsync(req);
Task.WaitAll(res);
if (res.IsCompletedSuccessfully)
{
Console.WriteLine($"Vault access policy set successfully on vault {VaultName}");
}
}