public async Task<string> AuthorizeS3ToSendMessageAsync(string queueUrl, string bucket)
{
var getAttributeResponse = await this.GetQueueAttributesAsync(new GetQueueAttributesRequest
{
QueueUrl = queueUrl,
AttributeNames = new List<string> { "All" }
}).ConfigureAwait(false);
Policy policy;
Statement statement;
GetNewPolicyAndStatement(getAttributeResponse, bucket, out policy, out statement);
if (!policy.CheckIfStatementExists(statement))
{
policy.Statements.Add(statement);
var policyString = policy.ToJson();
await this.SetQueueAttributesAsync(new SetQueueAttributesRequest
{
QueueUrl = queueUrl,
Attributes = new Dictionary<string, string>
{
{"Policy", policyString}
}
}).ConfigureAwait(false);
}
return getAttributeResponse.QueueARN;
}
}