code: def create_event_permission(self, lambda_name, principal, source_arn):
          
          logger.debug('Adding new permission to invoke Lambda function: {}'.format(lambda_name))
          permission_response = self.lambda_client.add_permission(
              FunctionName=lambda_name,
              StatementId=''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(8)),
              Action='lambda:InvokeFunction',
              Principal=principal,
              SourceArn=source_arn,
          )
  
          if permission_response['ResponseMetadata']['HTTPStatusCode'] != 201:
              print('Problem creating permission to invoke Lambda function')
              return None  # XXX: Raise?
  
          return permission_response
docs: Create permissions to link to an event.
  
          Related: http://docs.aws.amazon.com/lambda/latest/dg/with-s3-example-configure-event-source.html