Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LOG-5184: fix and refactor the script for setting up S3 ingestion #125

Merged
merged 6 commits into from Aug 19, 2019

fix adding bucket ARN to queue policy

  • Loading branch information
MichalChomo committed Aug 16, 2019
commit f5bdee17b846cd948ff17c9ace09e5f1e542ddcc
@@ -103,13 +103,12 @@ def add_statement_or_resource(self, action, resource, statement_to_add):
self.add_statement(statement_to_add)
else:
# Required action is contained in a statement, check resource.
statement, index = self.get_statement(action, resource)
if not statement:
if not self.get_statement(action, resource)[0]:
# Required resource is missing, add it to the statement with the required action.
self.add_resource_to_statement(resource, index)

def add_statement(self, statement, index=None):
if index:
if index is not None:
self._policy_document['Statement'][index] = statement
else:
self._policy_document['Statement'].append(statement)
@@ -231,7 +230,7 @@ def _add_bucket_to_queue_policy(self, policy_document):
# A statement with 'sqs:sendmessage' action and some ARN condition already exists,
# just append the bucket ARN to its condition.
bucket_arn += ',arn:aws:s3:::' + self._bucket.name
statement['Condition']['ArnLike']['aws:SourceArn'] = bucket_arn.split()
statement['Condition']['ArnLike']['aws:SourceArn'] = bucket_arn.split(',')
policy_document.add_statement(statement, index)
self._queue.set_attributes(Attributes={'Policy': json.dumps(policy_document.get_policy())})

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.