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.
Related
I'm trying to create SNS Subscription filter policy. I want this filter policy to send the message to user only when cloudformation Resource status is "CREATE_IN_PROGRESS" for s3 bucket and all the other cloudformation resource creation events shouldn't be sent to user. Can anyone with experience with creating SNS Subscription filter policy for Cloudformation events please assist on this.I just want user to receive only notification when ResourceStatus='CREATE_IN_PROGRESS' for ResourceType='AWS::S3::Bucket' and the bucket is Logical Resource Id='TestBucket'
'
I don't think that will work.
From Amazon SNS subscription filter policies - Amazon Simple Notification Service:
A subscription filter policy allows you to specify attribute names and assign a list of values to each attribute name... Each attribute name in a filter policy matches an attribute name assigned to the message.
When AWS CloudFormation sends events, they are sent as a block of JSON. Individual elements (eg Status, Bucket name) are not sent as Amazon SNS Message Attributes. Thus, the rules will not be able to detect these values.
An alternative would be to write an AWS Lambda function that can parse the message and respond accordingly.
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 want to pass trigger to an ecs instance when a file is uploaded to a bucket in s3 and process the uploaded file. so i need to get the bucket and file name into the ecs container.
the ecs instance is not already running. but started when the event occurs
I want to pass trigger an ECS instance when a file is uploaded to a
bucket in s3 and process the uploaded file
First thing, Environment variable load at the boot time of application while the event is not known at the start of application.
So the best way to handle this is SNS or SQS notification on s3 put event. You need
Put the file on S3
Event notification sent to SNS (data enters S3, notification of new data is sent to SNS)
SNS will trigger HTTP endpoint of your ECS container ( I assume that you already expose endpoint to process SNS topic.
Get the Name of the object and S3 bucket Name from SNS topic.
You can also use SQS with SNS but HTTP endpoint seems good,A high-level architecture will look like
Or details diagram
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).