Skip to content

Instantly share code, notes, and snippets.

@sampathshivakumar
Last active July 21, 2024 22:18
Show Gist options
  • Save sampathshivakumar/43ad8e638dea58008f98be379ad53272 to your computer and use it in GitHub Desktop.
Save sampathshivakumar/43ad8e638dea58008f98be379ad53272 to your computer and use it in GitHub Desktop.

AWS Event Driven Architecture

Event driven Architecture

What is AWS Event Driven Architecture ?

  • AWS Event-Driven Architecture is an approach that utilizes Amazon Web Services to build scalable and decoupled applications.
  • It relies on events as the primary means of communication between components.
  • The architecture includes event sources that generate events, an event bus for routing events, rules to filter and route events, and targets for actions triggered by events.
  • Event Driven Architecture offers benefits such as scalability, loose coupling, flexibility, and real-time processing.

Prerequisites

Lets start Builing Event Driven Architecture

Create S3 Bucket

1

2

3

Now let's create Lambda

4

5

Set the Time out for Lambda to 5 mins

6

7

Time out has been modified

8

Add DynamoDB full access to Lambda

9

Add print events in Lamda code

10

As of now there are no cloudwatch logs, as Lambda is not triggered

11

12

Now lets Integrate S3 Bucket to Lambda

Go to Properties tab inside your bucket and Create event notification

13

14

You should see this

15

Now what it means is when ever any object is inserted into S3 Bucket it will trigger Lambda function

Lets inssert a simple sample.json file into S3 Bucket

{
  "Name" : "SampathShivaKumar",
  "Role" : "DevOps",
  "Email": "sampathshivakumar@gmail.com"
} 

16

17

Now S3 Bucket should have triggered Lambda Function, Check CloudWatchlogs to verify

18

19

Now we need Lambda to extract content of files and insert it to DynamoDB table

Let's create a DynamoDB Table

20

21

22

Now we have to code Lambda so that it can extract the content of file and send data to DynamoDB

23

Now to trigger Lambda upload file again to S3 Bucket

24

25

Lambda is working fine, now we have to add these record into DynamoDB table

Modify the code for Lambda to insert records into DynamoDB Table

26

As of now you can see no data inside DynamoDB Table

27

Now to trigger Lambda upload file again to S3 Bucket

28

Now Lets see DynamoDB table again,By now s3 should trriger lambda function and lambda should insert data into DynamoDB table

29

AWS Event Driven Architecture is successfully built and is functioning as expected

Note: Special thanks to Amit Nag sir,Code is taken from his GitHub repo https://github.com/nspacer/eventDrivenArchitectureP1 , i have not written the code myself.

Thank you for reading this post! I hope you found it helpful. If you have any feedback or questions,Please connect with me on LinkedIn at https://www.linkedin.com/in/sampathsivakumar-boddeti-1666b810b/. Your feedback is valuable to me. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment