Skip to main content

Posts

How to run a scheduled job with EventBridge and Lambda

Greetings! Triggering a piece of code by a timer has multiple use cases. Hence I am going to talk about how can we do it using AWS EventBridge. Run daily/monthly reports Send reminders Scheduled data mining Send marketing emails The source code for this article can be found here . Let's learn how we can achieve this architecture using AWS EventBridge and Lambada. EventBridge AWS EventBridge is a serverless event bus service that you can use to connect your applications with data from a variety of sources including AWS services and external services. An event is an indicator of a change in the environment. When an event receives, it applies a rule to route the event to a target. Rules match events to targets based on either an event pattern or on a schedule which is the focus of this article. Let's build the architecture using the serverless framework. Initialize the project Let's initialize the project using serverless cli. mkdir eventbridge-lambda-t

How to secure an API using Lambda authorizer

Greetings! I wrote about creating a CRUD API using API Gateway and Lambda in a previous article. However, I did not talk about how to secure it. In this article, I am going to explain how we can use Lamda Authorizer to secure an API. The complete code is here . Lambda Authorizer Lambda authorizer is an API gateway feature to control access to your API. It uses the provided lambda function to do so. This is useful when we want to implement a custom authorization scheme that uses a bearer token (JWT) or a request parameter. Token authorizer - uses a token to authorize uses. It receives the caller's identity in a bearer token, such as a JSON Web Token (JWT) or an OAuth token Request authorizer - uses parameters, headers, and query strings to pass user identity In this article, we use a token-based authorizer. For simplicity, we expect our token to be "cat". Initialize the project Let's initialize the project using the serverless framework.

Handling file uploads with S3 and Labmda

Greetings File uploading and invoking logic based on that can be a common business scenario. We can categorize a few such use cases as below. Image resizing such as thumbnail creation Read JSON file content and invoke logic Image processing The source code for this article can be found here . Let's learn how we can achieve this architecture using AWS S3 and Lambada. S3 Events We can enable events for a particular S3 bucket for bucket operations such as file added, and updated. When we enable this feature, we need to provide the event recipient such as a lambda function. When the bucket operations occur, the provided target will be invoked. Let's build the architecture using the serverless framework. Initialize the project Let's initialize the project using serverless cli. mkdir s3-lambda-trigger cd s3-lambda-trigger serverless create --template aws-nodejs npm init -y npm install @aws-sdk/client-s3 --save We have installed the S3 dependency

Let's learn redux-saga

Greetings! In a previous article , I talked about redux architecture with reactjs a bit. In this article, I talk about handling side effects with redux-saga. The complete code for this article is here . What is redux-saga? Redux saga is a side effect manager using ES6 generators. Therefore it gives the added benefit of easy testability. What do we build? To demonstrate the architecture, let's create a simple GitHub user application where we fetch GitHub handle for a given username. For example, this gives my GitHub account information. https://api.github.com/users/slmanju Initialize the project create-react-app react-redux-saga-example cd react-redux-saga-example npm install redux react-redux reselect npm install redux-saga npm install axios Util to fetch actual data Let's create a little util for HTTP calls using axios. import axios from "axios"; const withError = (promise) => promise.then((data) => [null, data]).catch((err) => [err]); export const

Getting started with react-redux

Greetings! Redux is described as a predictable state container for JS Apps (in the docs) and a few more features. What we need to realize is that it gives a single source of truth for our JavaScript applications. Instead of saving our global states in multiple places, we manage them in a centralized location. That is it! Let's jump. Single source of truth Share data across multiple places The source code for this article can be found here . The redux architecture It is this redux architecture we need to understand. After that, it is how to accomplish it in reactjs way. view - any part of the user interface action - what sort of thing the user did in the user interface? reducer - this is where the data manipulation happens. It captures the action and acts upon that, updates the store store - this is where the all data is saved just like a database These are the main players we need to know, we need to understand. Next, we will use the react-redux