private static void GetNewPolicyAndStatementForTopicAttributes(Dictionary<string, string> attributes, string topicArn, string bucket, out Policy policy, out Statement statement)
{
if(attributes.ContainsKey("Policy") && !string.IsNullOrEmpty(attributes["Policy"]))
{
policy = Policy.FromJson(attributes["Policy"]);
}
else
{
policy = new Policy();
}
var sourceArn = string.Format(CultureInfo.InvariantCulture, "arn:aws:s3:*:*:{0}", bucket);
statement = new Statement(Statement.StatementEffect.Allow);
statement.Actions.Add(SNSActionIdentifiers.Publish);
statement.Resources.Add(new Resource(topicArn));
statement.Conditions.Add(ConditionFactory.NewSourceArnCondition(sourceArn));
statement.Principals.Add(new Principal("*"));
}
}