Managing cloud prices and understanding useful resource utilization could be a daunting job, particularly for organizations with advanced AWS deployments. Whereas the AWS Value and Utilization Report (AWS CUR) gives useful knowledge insights, decoding and querying the uncooked knowledge might be troublesome.
This publish describes an answer that makes use of generative synthetic intelligence (AI) to generate SQL queries from a consumer’s pure language questions. The answer simplifies the method of utilizing SQL question technology to question CUR knowledge saved in an Amazon Athena database, working the queries in Athena, and displaying them in an internet portal for simple understanding.
The answer makes use of Amazon Bedrock, a completely managed service that gives a alternative of high-performance foundational fashions (FMs) from main AI firms similar to AI21 Labs, Anthropic, Cohere, Meta, Mistral AI, Stability AI, and Amazon via a single API, and likewise gives a variety of capabilities for constructing generative AI functions with safety, privateness, and accountable AI.
Points to be resolved
The next challenges can stop organizations from successfully analyzing CUR knowledge, resulting in inefficiencies, overspending, and missed value optimization alternatives: Utilizing generative AI with Amazon Bedrock, we goal to focus on and simplify these challenges:
- SQL Question Complexity – Writing SQL queries to derive insights from CUR knowledge might be sophisticated, particularly for non-technical customers or these unfamiliar with CUR knowledge constructions (except you’re an skilled database administrator).
- Information Accessibility – To achieve insights from the structured knowledge within the database, customers must entry the database, which could be a potential risk to general knowledge safety.
- Ease of use Conventional strategies of analyzing CUR knowledge usually lack user-friendly interfaces, making it troublesome for non-technical customers to faucet into the dear insights hidden within the knowledge.
Answer overview
The answer described here’s a internet utility (chatbot) that permits customers to ask questions on their AWS prices and utilization in pure language. The appliance generates SQL queries based mostly on consumer enter, runs them towards an Athena database containing CUR knowledge, and shows the leads to a user-friendly format. The answer combines the facility of generative AI, SQL technology, database querying, and an intuitive internet interface to supply a seamless expertise for analyzing CUR knowledge.
This resolution makes use of the next AWS companies:
The next diagram exhibits the answer structure:
Determine 1. Answer structure
The info movement consists of the next steps:
- CUR knowledge is saved in Amazon S3.
- Athena is configured to entry and question the CUR knowledge saved in Amazon S3.
- Customers work together with the Streamlit internet utility and submit pure language questions on their AWS prices and utilization.
Determine 2. Exhibiting the chatbot dashboard for asking questions
- The Streamlit utility sends consumer enter to Amazon Bedrock, and the LangChain utility facilitates the general orchestration.
- The LangChain code makes use of LangChain’s BedrockChat class to name FM, which interacts with Amazon Bedrock to generate SQL queries based mostly on the consumer’s enter.
Determine 3. Exhibiting the initialization of the SQL chain
- The generated SQL queries are run towards the Athena database utilizing FM on Amazon Bedrock to question the CUR knowledge saved in Amazon S3.
- The outcomes of the question are returned to the LangChain utility.
Determine 4. Utility output log displaying generated queries
- LangChain sends the SQL question and the question outcomes again to the Streamlit utility.
- The Streamlit utility shows SQL queries and question outcomes to the consumer in a formatted and user-friendly method.
Determine 5. It exhibits the SQL question and the ultimate output displayed within the chatbot internet app, which comprises the question outcomes.
Conditions
To arrange this resolution, you want the next conditions:
Configure the answer
To arrange the answer, comply with these steps:
- Create an Athena database and desk to retailer your CUR knowledge. Be sure that the suitable permissions and settings are in place for Athena to entry the CUR knowledge saved in Amazon S3.
- Configure your compute surroundings to name the Amazon Bedrock API. You’ll want to affiliate an IAM function with this surroundings whose IAM coverage permits entry to Amazon Bedrock.
- As soon as the occasion is up and working, set up the next libraries that shall be used to work inside the surroundings:
- Use the next code to determine a connection to the Athena database utilizing the langchain library and pyathena, and configure the language mannequin to generate SQL queries based mostly on consumer enter utilizing Amazon Bedrock. It can save you this file as cur_lib.py.
- Create a Streamlit internet utility to supply a UI for interacting together with your LangChain utility. Embrace an enter subject for customers to enter pure language questions and think about the generated SQL queries and question outcomes. You possibly can identify this file cur_app.py.
- Name the get_response kind to attach the LangChain utility with the Streamlit internet utility and show the SQL question and leads to the Streamlit internet utility. Add the next code to the applying code above.
- Deploy the Streamlit and LangChain functions to a internet hosting surroundings, similar to Amazon EC2 or a Lambda operate.
cleansing
So long as this resolution doesn’t name Amazon Bedrock, there aren’t any expenses. To keep away from ongoing Amazon S3 storage expenses for storing your CUR experiences, delete your CUR knowledge and S3 bucket. In case you use Amazon EC2 to arrange the answer, be sure you cease or delete the occasion if you’re completed.
benefit
This resolution gives the next advantages:
- Simplified Information Evaluation – Use generative AI to investigate CUR knowledge in pure language, eliminating the necessity for superior SQL information.
- Improved accessibility – Net-based interface permits non-technical customers to entry and achieve insights into CUR knowledge with no need database credentials.
- Save time – Get prompt solutions to your value and utilization questions with out having to manually write advanced SQL queries.
- Improved visibility – This resolution gives visibility into AWS prices and utilization, enabling higher value optimization and useful resource administration choices.
abstract
The AWS CUR Chatbot resolution makes use of Amazon Bedrock’s Anthropic Claude to generate SQL queries, database queries, and a user-friendly internet interface to simplify the evaluation of CUR knowledge. The answer permits you to ask questions in pure language, eradicating boundaries and enabling each technical and non-technical customers to realize useful insights into their AWS prices and useful resource utilization. This resolution helps organizations make extra knowledgeable choices, optimize their cloud spend, and enhance general useful resource utilization. We suggest that you just train due diligence when setting this up, particularly in a manufacturing surroundings. You possibly can select different programming languages and frameworks to set it up relying in your preferences and wishes.
Amazon Bedrock makes it straightforward to construct highly effective generative AI functions. Comply with our fast begin information to speed up your improvement. GitHub You too can use Amazon Bedrock information bases to quickly develop state-of-the-art Retrieval Augmented Era (RAG) options or use Amazon Bedrock brokers to allow your generative AI functions to execute multi-step duties throughout enterprise methods and knowledge sources.
Concerning the Creator
Anuthosh I’m a Options Architect at AWS India. I dive deep into buyer use circumstances and assist them easy their journey on AWS. I take pleasure in serving to clients by constructing options within the cloud. I’m enthusiastic about migration & modernization, knowledge analytics, resiliency, cybersecurity, and machine studying.

