GithubHelp home page GithubHelp logo

pj64 / event_sourcing_eventbridge Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 424 KB

In this example Amazon EventBridge rules that are used to invoke Lambda functions when events are added to the EventBus. The EventBus sits behind a HTTP API endpoint, the client application pass a request to the api endpoint which includes a filtering attribute. The EventBus matches the attribute to a rule which then triggers a Lambda target.

JavaScript 3.88% TypeScript 27.71% Jupyter Notebook 55.11% Python 13.30%
aws aws-lambda aws-lambda-python aws-dynamodb aws-apigateway aws-http-api aws-eventbridge

event_sourcing_eventbridge's Introduction

Example

This example is designed for a concept mobile application called Skip the Line, which allows user to pre-order takeaway coffee while they are in transit. Just as the train pulls into the station, the user can order a coffee and pick it up on the way past the coffee shop.

In this example Amazon EventBridge rules that are used to invoke Lambda functions when events are added to the EventBus. The EventBus sits behind a HTTP API endpoint, the client application pass a request to the api endpoint which includes the attribute 'eventtype':[new_order]. The EventBus matches the attribute to a rule which then triggers a Lambda target. The advantage to using this pattern is that the API Gateway is configured with a single API endpoint for the client. The EventBridge handles routing of the request to the Lambda functions using rules. The EventBus rules can be easily created and modified, which simplifies the process of building event-driven architectures

The Amazon DynamoDB table is partitioned on an accountid attribute and also includes a sort key on the vendorid attribute, together they form the primary key. The example also demonstrates using Python to put, update and delete items in Amazon DynamoDB.

architecture

Setup

You will need to download and install Node.js before you can start using the AWS Cloud Development Kit.

This example is developed using the AWS CDK and Typescript, so you will need to install both Typescript and the CDK using the following commands

npm install -g typescript
npm install -g aws-cdk@latest

Since this CDK project uses 'Assests', you might need to run the following command to provision resources the AWS CDK will need to perform the deployment.

cdk bootstrap

The testing scripts can be executed using Jupyter Notebook. There are a few methods for installing Jupyter Notebooks. These instructions will help you get to started with JupyterLab installation.

You can also install Jupyter Notebooks as part of Anaconda installation.

To download this example, you will need to install Git. After installing git follow these instructions to learn how to clone the repository.

After the repository has been cloned set the command prompt path to the cloned directory and run the following command to install the project dependencies.

npm install

cdk synth executes the application which translates the Typescript code into an AWS CloudFormation template.

cdk synth

After the synth command has generated the template use the cdk deploy command to deploy the template to AWS CloudFormation and build the stack. You will be prompted to confirm the deployment with y/n.

cdk deploy

Run the Example

Open the Jupyter Notebook in the jupyter_notebook directory follow the instructions.

Cleanup

From the command prompt execute the following command: cdk destroy

Deployed Resources

Identifier Service Type
EventSourcingEventbridgeS-aws generated name Lambda Function
EventSourcingEventbridgeS-aws generated name IAM Role
event_sourcing_eventbridge DynamoDB Table
event_sourcing_eventbridge_api_role IAM Role
/demo/event_sourcing_eventbridge Logs LogGroup
event_sourcing_eventbridge event_sourcing_eventbridge_logger Events
event_sourcing_eventbridge_put_item Lambda Function
event_sourcing_eventbridge_update_item Lambda Function
event_sourcing_eventbridge_delete_item Lambda Function
event_sourcing_eventbridge_lambda_put IAM Role
event_sourcing_eventbridge_lambda_update IAM Role
event_sourcing_eventbridge_lambda_delete IAM Role
event_sourcing_eventbridge event_sourcing_eventbridge_new_order Events
event_sourcing_eventbridge event_sourcing_eventbridge_update_order Events
event_sourcing_eventbridge event_sourcing_eventbridge_delete_order Events

event_sourcing_eventbridge's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.