I have SNS notification for a S3 bucket. I wanted to push that SNS notification with attachment
We have a S3 bucket namely like SDD-XXX-YYY. Once if any file is getting arrived in that bucket, we have configured SNS to receive email notification.
Now we need email notification with content of the file which we are receiving in S3 or as attachment in our email.
Example: We are receiving some "error.log" file S3, here we need to push the error.log in email or else content of error.log file.
Please help me to achieve it.
Do we need to write lambda here? or we can manage it in SNS itself?
The SNS S3 notification will only give you information about the newly created object.
You can see the structure of the event in Event Message Structure.
If you want to send the file via email you will have to write this logic in a Lambda function: you will use the information from the event (bucket and key) to download the object and then send it via email.
This function could subscribe to SNS or directly to S3.
Related
I have enabled the S3 notification create:* event for SNS sending to my email from AWS CLI in my Windows servers.
However, there are many notification emails received from the SNS after I copied 10000+ local files such as xml, html, jpg to the S3. Because of creating the folder or the files, it is going to send the event with per creating file request to SNS.
I search the topic discussed in Edit event notification prefix and suffix and I think it just partially works on folder and file.
How can just receive one notification email that indicates it's starting the copy job?
How can just receive one notification email that indicates it's starting the copy job?
You can't. This is not how S3 notifications work. You would have to develop custom solution to that. Maybe instead of SNS, have a lambda function to get triggered. The function would somehow verify if this is the first file being uploaded, and send out email only for that file.
I want to send just the name of the S3 bucket created by Cloudformation. If i choose the SNS notification it will send the notification about complete CFT stack creation activity. Can we custom notification to just send the S3 bucket name to user
What are the options available to do this in AWS?
Can we custom notification to just send the S3 bucket name to user
Yes. Send the initial SNS notification to lambda function. The function will use AWS SDK to inspect the stack created, extract the bucket name, and pass it forward as needed.
Is there a direct way after saving something in a S3 bucket to send the content as attachment by SNS (via email) or do i have create a lambda function in order to tell SNS, what i want to send?
S3 bucket -> SNS -> Email (my preferred way, if possible)
or is this not possible without lambda?
The event that S3 sends to Lambda, SNS or SQS only contains a reference to the item that was created, not the actual content.
If you want to pass on the content, you have to download it in whichever code responds to that event and then send it to your destination.
There is no mechanism that sends the content of a newly uploaded object to an SNS topic.
I would like to configure a bucket notification on an S3 bucket so that every time a notification from a file being uploaded, it sends a message to an SNS topic with a pre signed url in the message so that file can be downloaded when consumed from an email.
File gets uploaded -> notification sent to SNS containing presigned url to recently updated object -> to SNS topic -> to email -> to user
I have tried setting up a topic, but couldn't get a presigned url inside the message, is there a way of setting this up without using a lambda or queue or other AWS services as intermediates?
You can't do this without additional services.
S3 is a storage service, as such it doesn't to much computation if any.
The simplest way would be to create a Lambda that gets triggered on S3 put object, generates the presigned url and sends a message to an SQS or SNS topic.
You'll need to use a Lambda for this unfortunately, it shouldn't be too much additional work.
Is there a way to automatically email a user when a certain file is uploaded to S3? We have a spreadsheet with contact information as well as a file name associated with that person. Once a person's file is uploaded, is there a way to send that user an automated email?
Yes. You can use AWS API Gateway to create an endpoint that accepts the file to upload and then, using AWS Lambda, upload it to S3 and trigger an event to send the email using mailchimp or AWS SES. Check this: https://codehabitude.com/2016/04/05/forms-to-emails-using-aws-lambda-api-gateway/
You could:
Configure an Amazon S3 event to trigger a Lambda function when a file is uploaded
Code the AWS Lambda function to lookup who should receive the notification and then send the message via Amazon SES (Simple Email Service)