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.
Related
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.
I am trying to setup AWS Rekognition using lambda so i have created s3 event trigger for each image uploaded to s3 so when a new image uploaded to s3 it will send an SNS notification > SNS will send to SQS > SQS will trigger lambda to process on that image.
MY main question is how i pass the uploaded Object key name to lambda? if anyone knows or having any idea please let me know
I'am not sure why you are using SNS and SQS to reach to lambda from S3.
You can directly link S3 event to Lambda.You can filter the event to PUT/POST/DEL etc too.This is best approach, instead of using SNS and SQS in between.
S3 event pretty much has all the data required to process.
You may look at
https://docs.aws.amazon.com/lambda/latest/dg/with-s3.html
https://docs.aws.amazon.com/lambda/latest/dg/with-s3-example.html
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.
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.
I created s3 bucket with event enabled for the bucket. When the new object is uploaded to the bucket sns will trigger an event to lambda to extract content from the file.
Is there any way to customize the sns event in generic format.
There is no out-of-box way to customize the notification format (without involving a middleman like Lambda). I would suggest using AWS Lambda as the direct message destination instead of letting the S3 notification flows through SNS. This AWS documentation will be useful for you (https://docs.aws.amazon.com/AmazonS3/latest/dev/notification-walkthrough-2.html).