in boto3_sample/s3_event_notifications_crawler_setup.py [0:0]
def set_s3_notification_sns(bucket_name, client, topic_arn):
bucket_notification = client.BucketNotification(bucket_name)
try:
response = bucket_notification.put(
NotificationConfiguration={
'TopicConfigurations': [
{
'Id' : crawler_name,
'TopicArn': topic_arn,
'Events': [
's3:ObjectCreated:*',
's3:ObjectRemoved:*',
],
'Filter' : {'Key': {'FilterRules': [{'Name': 'prefix', 'Value': folder_name}]}}
},
]
}
)
return True
except botocore.exceptions.ClientError as e:
print_error(e)
return False