Amazon.SQS.AmazonSQSClient.AuthorizeS3ToSendMessageAsync C# (CSharp) Method

AuthorizeS3ToSendMessageAsync() public method

This is a utility method which updates the policy of a queue to allow the S3 bucket to publish events to it.
public AuthorizeS3ToSendMessageAsync ( string queueUrl, string bucket ) : Task
queueUrl string The queue that will have its policy updated.
bucket string The bucket that will be given access to send messages from.
return Task
        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;
        }
    }
AmazonSQSClient