Profile
Mukul Jain
Full Stack Enginner | React | Nextjs | Nodejs | Typescript

A tutorial on EC2

Mar 09, 2024

As of May 13th, the Notion had released a public beta preview of their API. This is a long-awaited feature that enables you to further consolidate your activities in one single tool. One particular thing which I always wanted Notion to provide is the integration for my daily RSS feed.

While Notion itself doesn’t have anything out-of-the-box for pulling in your RSS feed, the release of Notion API is something that provides us with the opportunity to leverage a myriad of automation platforms as well as serverless solutions from Cloud providers to implement whatever integration we want.

Before we start

You should know that there are several decent RSS readers like Feedly which do a fine job of aggregating your RSS feeds, so before jumping the gun I recommend checking them out.

Choosing the automation platform

Another thing that you might want to check out is the automate.io. This is one of many automation platforms which promises you to do what you need in just a few clicks.

There is indeed an advertised RSS integration with Notion which I went to test out — only to realize that it’s just not good enough for me. There seems to be a lack of configurability, like the ability to set up multiple RSS feeds, as well as be able to tune trigger logic.

However, we still can build what we need using a bit lower level abstraction — serverless function platforms like AWS Lambda or Azure Functions.

I personally was working with AWS for years and often use it as a platform for my personal projects, so here I’d go with that option. However, there are no AWS-exclusive specifics in the problem we’re about to solve, so any serverless function platform would work for you just fine.

Prerequisite

Here is the list of required stuff before moving forward:

  • NodeJS of version 14+ (comes with its package manager NPM which we’ll need later on)
  • An active AWS account.
  • AWS IAM user with enough permissions to deploy via CDK and use AWS Lambda — AdministratorAccess policy will be enough. Check out this guide for more details.
  • AWS CLI configured with that user credentials — Access Key ID and Access Key Secret. See this guide for examples of how to do it.
  • Make sure you’ve explicitly exported the AWS profile with these credentials:

    % export AWS_PROFILE=your-profile

    AWS CDK will check this variable by default to figure out which account it works with and what IAM user permissions it should leverage.

    The AWS Part

    While you can do all of the needed AWS changes and configurations by hand clicking through AWS Console, I usually go with the infra-as-a-code (IaaC) approach, so I am going to stick with that here.

    AWS CDK is a relatively new way to provision your infrastructure following IaaC even more literally than Cloudformation / Terraform did before — using a programming language like Typescript to create AWS resources.

    I will use AWS CDK here, but you can again achieve the same results with other IaaC options like Cloudformation, Terraform, and others.

    You can find the final source code here

    Deploy your AWS CDK app

    If you never worked with AWS CDK before — no worries, it’s all fairly simple. I recommend checking out this document. Assuming that you have installed node of at least version 14+ run the following snippet:

    % npm i -g aws-cdk

    Next, create your project directory and init the CDK project:

    % mkdir notion-rss-feed && cd $_
    % cdk init sample-app --language=typescript

    As you can see — we explicitly specify the language as typescript. There are many other languages supported for the CDK, however, with Typescript, you'd be able to find most examples for as well as it being the first-class citizen language for the CDK, since all others are just wrappers.

    Assuming cdk init ran without problems you should get the following structure:

    notion-rss-feed % tree -L 1
    .
    ├── README.md
    ├── bin
    ├── cdk.json
    ├── jest.config.js
    ├── lib
    ├── node_modules
    ├── package-lock.json
    ├── package.json
    ├── test
    └── tsconfig.json

    As you can see there is quite a number of files, but don’t worry — you don’t need to deal with most of them. The part you’d be looking into is in the lib folder - all the resource stack definitions will go there. By convention, CDK will create a single file there named notion-rss-feed-stack.ts.

    So let’s go ahead and modify our Stack at notion-rss-feed/lib/notion-rss-feed-stack.ts: