serverless-s3-notifications
v2.0.5
Published
[](http://www.serverless.com) [](https://www.npmjs.com/package/serverless-s3-notifications) [ and roles are already in place!
- Firstly, we add lambda.addPermission for the Lambda on the custom parameter notification_bucket. Some basic checks are in place to check if a permissions already exists.
- Secondly, we loop through the custom parameter notification_folders and do a s3.putBucketNotificationConfiguration for each folder. You can run the serverless deploy command multiple times to add/remove folders.Installing and configuring the plugin
Run the following command;
$ npm install serverless-s3-notificationsAdd these custom parameter to your serverless.yml
custom:
# serverless-s3-notifications plugin parameters
notification_bucket: your_event_s3_bucket_name # S3 bucket name where are placing the event notifications
notification_type: "s3:ObjectCreated:*" # type of action you want to trigger the event notification
notification_folders: ['myfolder1/', 'myfolder2/'] # specify any number of folders`s that you want the event to trigger
aws_account_id: "1234567890" # aws account id where the notification_bucket resides
lambda_name: "${self:service}-${self:stage, 'dev'}-helloworld" # service-stage-functionname
functions:
helloworld:
handler: helloworld.lambda_handler
timeout: 10
memorySize: 128
plugins:
- serverless-s3-notificationsDeploying your Lambda and event notifications
Deploy
$ export http_proxy="http://yourproxy" # provide a proxy address
$ export assume_role="assume_role_arn" # haven't found a way of fetching this from serverless.yml (yet)
$ serverless deploy --profile your_aws_profileRemove
$ serverless remove