public async Task AuthorizeS3ToPublishAsync(string topicArn, string bucket)
{
var attributes = (await this.GetTopicAttributesAsync(new GetTopicAttributesRequest
{
TopicArn = topicArn
}).ConfigureAwait(false)).Attributes;
Policy policy;
Statement newStatement;
GetNewPolicyAndStatementForTopicAttributes(attributes, topicArn, bucket, out policy, out newStatement);
if (!policy.CheckIfStatementExists(newStatement))
{
policy.Statements.Add(newStatement);
var policyString = policy.ToJson();
await this.SetTopicAttributesAsync(new SetTopicAttributesRequest
{
TopicArn = topicArn,
AttributeName = "Policy",
AttributeValue = policyString
}).ConfigureAwait(false);
}
}
}