The author presents the steps used to build a real-time chat on AWS, leveraging the IoT Core service, albeit quite a straightforward method using AWS serverless capabilities effectively. The approach utilizes the AWS IoT Core regional endpoint that enables real-time communication between connected applications. The article shares an architecture for building real-time chat applications, which is easily understandable, accompanied by useful code snippets, and infrastructure written in CDK, which is readily deployable and testable in any AWS environment.
The architecture is based on IoT Core Topics as the backbone for real-time messaging coupled with other AWS serverless services that support things like data persistence and authorization. The REST API supports fetching existing messages per channel.
Clients using the IoT Core service must subscribe to these topics, which is accomplished using IoT Core Topics, facilitating the storage of messages in a DynamoDB table automatically, with other subscribed clients receiving them in real-time. Clients will use the get messages API to obtain previous messages from the database upon connecting.
There are caveats regarding the authorizer, which proved to be difficult while developing this solution, mainly comprising IoT Core granting permission to the lambda authorizer function for it to work, and the authorizer response being of IoTCustomAuthorizerResult type. The article includes a link to the GitHub repository containing the authorizer's complete code, along with the CDK setup and an example client.
The article exempts coverage of pricing, but the involved AWS services have been combined at a cheap cost, and users can process hundreds of thousands of messages before the solution becomes relatively costly.
The architecture laid out in the article provides a good foundation not only for chat systems but for any real-time communication feature envisioned, and it is easy to extend beyond the basic application-level features demonstrated in the article.
The next article will migrate this solution to AppSync Events, explore options to handle the lack of data persistence, and compare its features with those of IoT Core.
In conclusion, the article demonstrates the use of AWS serverless capabilities using the IoT Core service to facilitate the development of real-time chat applications. It offers high scalability, easy deployment, and future extension possibilities.
The article is suitable for developers or architects who are interested in serverless development on the AWS platform.