GenAI in AWS an example

In my opinion, AWS AI is behind what you will find on Azure and some other cloud platforms.  It is an area that AWS needs to address.  It does however offer tools and services around GenAI that you can use to build an application to satisfy GenAI use cases.  For example we can use Amazon Bedrock and ECS Fargate to deploy a simple GenAI app that can summarize text based on your inputs.  This deployment would satisfy a few use cases, including reporting, management information summaries, email analysis, long text summaries, and technical documentation creation. 

Architecture

This simple application will allow us to upload a text file (for example, an email) and generate a summary of its content.

A simple deployment to satisfy some GenAI use cases.

The architecture of the application is as follows:

The front-end is a web interface built with Streamlit, a Python library that allows you to create interactive web applications with minimal code. Streamlit is hosted on AWS ECS Fargate, a serverless compute engine that scales automatically based on demand.

-The back-end is a Generative AI service powered by Amazon Bedrock, a fully managed platform that provides access to pre-trained models for various natural language processing tasks. You can use the Amazon Titan Text Generation 1 (G1) — Express model, which can generate high-quality text from a given prompt or context.

-The application also uses Langchain Bedrock LLM, a middleware layer that preprocesses the input text and passes it to Amazon Bedrock. Langchain Bedrock LLM is a natural language understanding module that can extract the main points, keywords, and sentiment from a text.

The deployment of the application is automated with Terraform, an infrastructure as code tool that allows you to define and provision cloud resources using a declarative language. Terraform creates the ECS Fargate cluster, the task definition, the service, and the security groups. You should also use an AWS Application Load Balancer to route the traffic to the ECS service and provide HTTPS encryption. (Note: The ALB deployment is not included ion the code)

Pre-requisites

  • An AWS account with enough credits to create and run a VPC, ECS cluster, ECR and Amazon Bedrock.
  • A workstation or laptop with Docker Engine installed and running.
  • Terraform CLI is installed

How to use

  1. First, find a Github open source repo for AWS GenAI – you can search and clone the repo
  2. AWS Access Credentials, so that you can use the AWS services that the app depends on, such as S3 and Lambda. You can find more information on how to do that here: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html
  3. Edit the variables in the file called variables.tf, which contains the configuration parameters for the Terraform script that will create the necessary AWS resources for the app. You should change the values according to your own environment and preferences, such as the region, the bucket name, and the domain name.
  4. After that, you will need to initialize Terraform by running the command terraform init in your terminal. This will download the required plugins and modules for the Terraform script.
  5. Next, you will need to perform a Terraform plan by running the command terraform plan in your terminal. This will show you what changes will be made to your AWS account by the Terraform script. You should review them carefully and make sure they are what you expect.
  6. – Finally, if everything looks good, you can deploy the app by running the command terraform apply -auto-approve in your terminal. This will create the AWS resources and deploy the app.