100 Days of DevOps — Day 7(AWS S3 Event)
Check the updated 101 Days of DevOps Course
Course Registration link: https://www.101daysofdevops.com/register/
Course Link: https://www.101daysofdevops.com/courses/101-days-of-devops/
YouTube link: https://www.youtube.com/user/laprashant/videos
Welcome to Day 7 of 100 Days of DevOps, Let extend the journey of DevOps Monitoring and Alerting with S3 events.
Problem Statement
- Whenever anyone deletes any object in S3 bucket you will get the notification
Solution
This can be achieved via in one of the three ways
- AWS Console
- Terraform
NOTE: This is not the complete list and there are more ways to achieve the same
What is S3 Event?
The Amazon S3 notification feature enables you to receive notifications(SNS/SQS/Lambda) when certain events(mentioned below)happen in your bucket.
Just to re-iterate the same thing S3 events work at the object level, so if something happens to the object, in this case, maybe PUT, POST, COPY or DELETE then the event is generated and that event will be delivered to the target(SNS, SQS or LAMBDA)
To Configure S3 events
- First, go to the SNS topic https://us-west-2.console.aws.amazon.com/sns/v2/home?region=us-west-2#/home
- Click on Topics → Actions → Edit topic policy
- Paste this json policy(We still need permission on SNS topic to allow S3 event system to deliver events to it)
- Go to S3 console https://s3.console.aws.amazon.com/s3/home?region=us-east-1
- Your bucket → Properties → Events
* Give your event a name
* Event type I want to get a notification is (All object delete events) i.e I want to recieve notification when object is deleted from this topic.
* Send to SNS Topic
* SNS(Choose the SNS topic you created earlier)
For more info about SNS
- Now if you try to delete an object from the bucket
NOTE: Delivery of these events happens in almost real-time with no cost involved.
Terraform Code
GitHub link
For more info about supported events type
NOTE: This is not a completely automated solution, you need to go to a particular topic and Create Subscription. For complete info
Looking forward from you guys to join this journey and spend a minimum an hour every day for the next 100 days on DevOps work and post your progress using any of the below medium.
- Twitter: @100daysofdevops OR @lakhera2015
- Facebook: https://www.facebook.com/groups/795382630808645/
- Medium: https://medium.com/@devopslearning
- Slack: https://devops-myworld.slack.com/messages/CF41EFG49/
- GitHub Link:https://github.com/100daysofdevops
Reference