<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Sreekesh Iyer</title>
    <description>The latest articles on Forem by Sreekesh Iyer (@sreekeshiyer).</description>
    <link>https://forem.com/sreekeshiyer</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1050168%2F03bad130-1d19-43c7-8201-e64a2d543e92.jpeg</url>
      <title>Forem: Sreekesh Iyer</title>
      <link>https://forem.com/sreekeshiyer</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sreekeshiyer"/>
    <language>en</language>
    <item>
      <title>Getting started with GPU Programming on an EC2!</title>
      <dc:creator>Sreekesh Iyer</dc:creator>
      <pubDate>Tue, 30 Dec 2025 14:00:12 +0000</pubDate>
      <link>https://forem.com/aws-builders/getting-started-with-gpu-programming-on-an-ec2-42ke</link>
      <guid>https://forem.com/aws-builders/getting-started-with-gpu-programming-on-an-ec2-42ke</guid>
      <description>&lt;p&gt;There's a short backstory to this thread, and it starts with a phone call from my undergrad Uni in September '25. It was the Head of the Department of IT at the other end, asking me if I were willing to take a technical knowledge-sharing session for the students. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0esgclueugbw3p62bj54.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0esgclueugbw3p62bj54.jpg" alt="Sreekesh looking at his broken code with a mic in his hand" width="800" height="1200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I was obviously in, I just needed an excuse to go back to the campus. It's been 2 years since I graduated and I dearly miss this place. Having said that, the topic of discussion was open-ended, so they left that on me to decide. I thought about many things - AI, Blockchain, Data Science, etc. but stumbled upon one thing that I had already been exploring lately, and I was almost certain that this was something most of the undergrad engineering students wouldn't have come across yet. &lt;/p&gt;

&lt;p&gt;Such is the world of GPU programming. GPUs - the curiosity that got me into gaming as a kid, exploring the compute prowess they bring to a machine. At the time, my understanding was as simple as - "big GPU, smooth game".&lt;/p&gt;

&lt;p&gt;Thanks to this gift of cloud, access to GPUs is much easier than back in the day. Looking at today's marker, accessing a cloud GPU is much easier than getting hands on an actual one even if you had the money XD&lt;/p&gt;

&lt;h3&gt;
  
  
  Finding a GPU Instance on EC2
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F14ii9u9j5c0rv00qaimr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F14ii9u9j5c0rv00qaimr.png" alt="Catalog of G series instances in Amazon EC2" width="800" height="458"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In just a few clicks, you can find yourself in a shell of a machine that has a powerful Nvidia GPU. &lt;/p&gt;

&lt;p&gt;You might need a service quota approval to get access to the &lt;em&gt;g4dn.xlarge&lt;/em&gt; type of EC2 instance, it's a fairly straightforward thing to request from the Service Quotas Dashboard. &lt;/p&gt;

&lt;p&gt;Once that is done, you can spin up an Ubuntu instance. &lt;/p&gt;

&lt;h3&gt;
  
  
  Installing CUDA
&lt;/h3&gt;

&lt;p&gt;Once you've entered your EC2 Instance on the shell, you can download the latest CUDA Toolkit from its official documentation with the network install. Looks something like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-ubuntu2404.pin
&lt;span class="nb"&gt;sudo mv &lt;/span&gt;cuda-ubuntu2404.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/13.1.0/local_installers/cuda-repo-ubuntu2404-13-1-local_13.1.0-590.44.01-1_amd64.deb
&lt;span class="nb"&gt;sudo &lt;/span&gt;dpkg &lt;span class="nt"&gt;-i&lt;/span&gt; cuda-repo-ubuntu2404-13-1-local_13.1.0-590.44.01-1_amd64.deb
&lt;span class="nb"&gt;sudo cp&lt;/span&gt; /var/cuda-repo-ubuntu2404-13-1-local/cuda-&lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="nt"&gt;-keyring&lt;/span&gt;.gpg /usr/share/keyrings/
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get update
&lt;span class="nb"&gt;sudo &lt;/span&gt;apt-get &lt;span class="nt"&gt;-y&lt;/span&gt; &lt;span class="nb"&gt;install &lt;/span&gt;cuda-toolkit-13-1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Following the same instructions on the download page you may need to install Nvidia drivers separately. &lt;/p&gt;

&lt;p&gt;The entire thing takes only a few seconds running commands one after another. Running &lt;code&gt;nvidia-smi&lt;/code&gt; on the terminal showing you this nice little table is a sign that the installation is completed perfectly.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0uoow62v7u40wgy1vac7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0uoow62v7u40wgy1vac7.png" alt="Output of nvidia-smi on the terminal showing the CUDA and the Driver version" width="800" height="365"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Troubleshooting
&lt;/h4&gt;

&lt;p&gt;If &lt;code&gt;nvcc --version&lt;/code&gt; doesn't work, validate that it's there in the local directory and add it to PATH in &lt;code&gt;bashrc&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'export PATH=/usr/local/cuda/bin:$PATH'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.bashrc
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.bashrc
&lt;span class="nb"&gt;source&lt;/span&gt; ~/.bashrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Basics of CUDA
&lt;/h3&gt;

&lt;p&gt;It took me an hour long C++ refresher to get comfortable working with CUDA files. You can get started by cloning my GitHub repository, it has two basic CUDA programs to work with.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/sreekeshiyer/hello-cuda.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The most fundamental idea of working with something like CUDA is that you want to parallelise your compute process to get as many tasks done as possible. I talked in-depth about how CPU and GPU are different and why the GPU is able to complete a lot more tasks in less time purely based on its hardware differences. &lt;/p&gt;

&lt;p&gt;Let's walk through the most basic vector addition program to understand how to work with CUDA. &lt;/p&gt;

&lt;h4&gt;
  
  
  Vector addition walkthrough
&lt;/h4&gt;

&lt;p&gt;When you start reading through vector_add_simple.cu in the basics directory, you'll realise how similar CUDA is to C++. There are two key differences, however.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight cuda"&gt;&lt;code&gt;&lt;span class="cp"&gt;#define BLOCK_SIZE 256
&lt;/span&gt;
&lt;span class="c1"&gt;// ---------------- Define GPU Kernel ----------------&lt;/span&gt;
&lt;span class="k"&gt;__global__&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;vectorAdd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;B&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;blockIdx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;blockDim&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;threadIdx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// Compute global thread index&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;C&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;A&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;B&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// 5. Launch kernel on GPU&lt;/span&gt;
    &lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"[5] Launching kernel...&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;blocksPerGrid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;N&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;BLOCK_SIZE&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;BLOCK_SIZE&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"    → Grid size: "&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;blocksPerGrid&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;" blocks&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"    → Block size: "&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;BLOCK_SIZE&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;" threads&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="n"&gt;vectorAdd&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;blocksPerGrid&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;BLOCK_SIZE&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d_A&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d_B&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d_C&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;N&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;cout&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="s"&gt;"    ✅ Kernel execution complete.&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I want you to closely observe these two code-blocks. The first one where we define the kernel. The operation, as one would expect, is rather simple - you are adding two one-dimensional vectors. The only difference being that we're going to distribute 1 operation to each thread, which is why we compute the thread-index first. &lt;/p&gt;

&lt;p&gt;After that, we're running this function in blocks and we're pre-defining blocks in a grid. I have a nice article from Nvidia that covers these terminologies in depth, you might want to &lt;a href="https://developer.nvidia.com/blog/cuda-refresher-cuda-programming-model/" rel="noopener noreferrer"&gt;take a look&lt;/a&gt;. I spent about 5-10 minutes on the whiteboard in the class trying to explain the concept of threads, blocks and grids. &lt;/p&gt;

&lt;h4&gt;
  
  
  Compiling the CUDA Program
&lt;/h4&gt;

&lt;p&gt;It's quite easy to run a CUDA program. You first compile it using &lt;code&gt;nvcc&lt;/code&gt; and you can run the outfile that gets generated as a result.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;### The flag -o is to mention the outFile name as 00&lt;/span&gt;
nvcc &lt;span class="nt"&gt;-o&lt;/span&gt; 00 vector_add_simple.cu
&lt;span class="c"&gt;### You can `ls` in the directory and find this outFile once compiled. &lt;/span&gt;
&lt;span class="c"&gt;### Then you can open this outFile as an executable which eventually runs your program. &lt;/span&gt;
./00
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We're essentially adding million-sized vector arrays and you'll notice that the entire operation completes in an instant. But that doesn't tell us much unless we compare it to a regular CPU-based program. &lt;/p&gt;

&lt;h3&gt;
  
  
  Comparing Results with a CPU
&lt;/h3&gt;

&lt;p&gt;We explored the capabilities of parallel computing with a GPU using a  simple vector addition program. But how does it actually fair against a CPU? This is what the students in the class were the most curious about. I've added another file &lt;code&gt;vector_add_benchmark.cu&lt;/code&gt; in the same folder for this very purpose. It basically runs the entire thing on a CPU (single-threaded) and then on the GPU to compare the time difference. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnao4uuq9z64hx3m5g5k9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnao4uuq9z64hx3m5g5k9.png" alt="Difference in the speeds of the CPU and GPU running the same operation" width="800" height="205"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You'll notice a stark difference (2600x in my case, results may vary but you can expect a general trend). While 32ms doesn't look huge, you can try playing around and expanding the array size, at which point you'll see the difference expanding as the CPU takes longer and longer. &lt;/p&gt;

&lt;p&gt;--&lt;/p&gt;

&lt;p&gt;I don't expect this article to be a "Welcome to CUDA", and I apologise if you expected it to be. I just wanted to walk through and document the little session I took in my university as a good habit. Overall, I had very positive feedback for the session. Feel free to reach out to me if you want to take a look at the deck ( PS - I make good decks &lt;em&gt;wink-wink&lt;/em&gt; )&lt;/p&gt;

&lt;p&gt;Thanks for reading, hope you're having a lovely time with your friends and family in the holiday season. I'll see you again in 2026 :D &lt;/p&gt;

</description>
      <category>cuda</category>
      <category>gpu</category>
      <category>aws</category>
      <category>nvidia</category>
    </item>
    <item>
      <title>Kiro - The New Agentic AI IDE from AWS</title>
      <dc:creator>Sreekesh Iyer</dc:creator>
      <pubDate>Mon, 14 Jul 2025 18:38:09 +0000</pubDate>
      <link>https://forem.com/aws-builders/kiro-the-new-agentic-ai-ide-from-aws-5311</link>
      <guid>https://forem.com/aws-builders/kiro-the-new-agentic-ai-ide-from-aws-5311</guid>
      <description>&lt;p&gt;Meet Kiro, a developer sitting inside an IDE to literally breeze you through projects from scratch and ship things faster than ever before.&lt;/p&gt;

&lt;p&gt;I've been using Kiro for the last few days for my side projects and it's worked an absolute charm. Let me take you on a little tour of this AI-powered IDE. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Spoiler alert: It's a lot more than &lt;em&gt;just&lt;/em&gt; code. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9jdteqmg4mktcd0vsnr4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9jdteqmg4mktcd0vsnr4.png" alt="Kiro Home Page" width="800" height="469"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Opening the app makes it seem like you're in a themed version of VSCode - and you're not entirely wrong. It's essentially VSCode with a few additions that make it an entirely different beast.&lt;/p&gt;

&lt;p&gt;I want you to look at two key features of this screen that'll allow me to give you an overview of what Kiro offers out of the box. &lt;/p&gt;

&lt;h3&gt;
  
  
  The Kiro Sidebar
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxxhekb3juahod0ii1zyi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxxhekb3juahod0ii1zyi.png" alt="A screenshot of the Kiro Sidebar" width="732" height="1128"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This panel houses the key features of Kiro - Specs, Agent Hooks, Agent Steering and the MCP Servers. I'll talk each one of them in detail in upcoming blogs. &lt;/p&gt;

&lt;h3&gt;
  
  
  The Chat Panel
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fksoj8m3i6ozrcauli37o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fksoj8m3i6ozrcauli37o.png" alt="Kiro Chat Window" width="800" height="1476"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's a classic chat window with two interesting modes - &lt;em&gt;Vibe Coding&lt;/em&gt; and &lt;em&gt;Code With Spec&lt;/em&gt;. I like how 'Vibe Coding' is the default version of the chat. &lt;/p&gt;

&lt;p&gt;When you have a very open-ended idea of what you want to build and have no real constraints, this &lt;strong&gt;&lt;em&gt;vibe coding&lt;/em&gt;&lt;/strong&gt; mode allows Kiro to 'go crazy' on your prompts and do its thing. &lt;/p&gt;

&lt;p&gt;On the other hand, if you know exactly what you're building, you can leverage the &lt;strong&gt;&lt;em&gt;spec&lt;/em&gt;&lt;/strong&gt; mode to describe the entire flow of things. Kiro creates 3 files - &lt;code&gt;requirements.md&lt;/code&gt;, &lt;code&gt;design.md&lt;/code&gt; and &lt;code&gt;tasks.md&lt;/code&gt; and it will keep modifying those files as documentation while it asks you clarifying questions about what you want to build. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft64l2nj5ucb6ptzr33fz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft64l2nj5ucb6ptzr33fz.png" alt="Enabling Agent Steering" width="800" height="122"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A layer of top of this is &lt;strong&gt;Agent Steering&lt;/strong&gt;. When you enable agent steering for your &lt;em&gt;project&lt;/em&gt;, you're providing Kiro added context about your project by default for &lt;em&gt;every prompt&lt;/em&gt;. You can enable it from the Command Pallette. It creates 3 files - &lt;code&gt;tech.md&lt;/code&gt;, &lt;code&gt;structure.md&lt;/code&gt; and &lt;code&gt;product.md&lt;/code&gt; that houses a proper outline of what you're building along with its nitty-gritty features that can be narrowed down to even variable naming styles. I feel that this gives you maximum control of your project. &lt;/p&gt;

&lt;p&gt;--&lt;/p&gt;

&lt;p&gt;I can't wait to experiment more with Kiro and unlock its full potential.&lt;/p&gt;

&lt;p&gt;Hope that was a good initial preview on what Kiro can bring to the table, and I'm sure there's a lot more on the way. There's no point in waiting, try it for yourself at &lt;a href="https://kiro.dev" rel="noopener noreferrer"&gt;kiro.dev&lt;/a&gt;! I'll see you in the next one:) &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Setting up a Queue Ingestion system for S3 to Redshift Transfer</title>
      <dc:creator>Sreekesh Iyer</dc:creator>
      <pubDate>Sat, 21 Dec 2024 09:19:42 +0000</pubDate>
      <link>https://forem.com/aws-builders/setting-up-a-queue-ingestion-system-for-s3-to-redshift-transfer-2l9h</link>
      <guid>https://forem.com/aws-builders/setting-up-a-queue-ingestion-system-for-s3-to-redshift-transfer-2l9h</guid>
      <description>&lt;p&gt;I've always been curious about data pipelines and how we are able to work with data engineering in the middle of everything in my company.&lt;/p&gt;

&lt;p&gt;Literally one object moves in 500 different formats through 500 different systems for perhaps 500 different purposes.&lt;/p&gt;

&lt;p&gt;The base object is a transaction that has all the raw L0 data stored in Object Storage. However we cannot pull out Object reads all day for analytics, so this needs to be moved into a separate database. Let me correct myself - moved into &lt;strong&gt;multiple&lt;/strong&gt; databases in different forms, for different reasons - Confirmations, Regulatory Reporting, etc.&lt;/p&gt;

&lt;p&gt;I was trying to see if I could develop a PoC of sorts, that can simulate this pipeline with the help of our friends in AWS.&lt;/p&gt;

&lt;p&gt;Here's what we have -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Amazon S3:&lt;/strong&gt; Object Storage&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Amazon SQS:&lt;/strong&gt; Message Queue&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Amazon Redshift:&lt;/strong&gt; SQL-ish database for preserving transformed data for further analysis. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AWS Lambda:&lt;/strong&gt; Compute for performing business logic to enrich the base data, push this to SQS and then pull it from SQS again to send it out to Redshift.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;--&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fms949ssf87vpyldr766k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fms949ssf87vpyldr766k.png" alt="Architecture" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let me bring up the architecture diagram from the cover image again.&lt;br&gt;
We're storing the initial piece of information in S3. This is where our first Lambda function gets triggered.&lt;/p&gt;

&lt;p&gt;We take the baseline object and perform some analysis and transformation on it. Consider this as your business logic that you'd perform at L1 before the data is sent further downstream.  &lt;/p&gt;

&lt;p&gt;The transformed object is then sent out via the SQS Queue. This message gets fetched by the 2nd Lambda which is virtually polling the queue. Finally, this message is transformed into an SQL Query and the data is inserted into a database in Redshift serverless.&lt;/p&gt;

&lt;p&gt;Now that we have a better picture, let's hop into action.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up the Queue
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuj8z4nqmmfg6s3ygd71a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuj8z4nqmmfg6s3ygd71a.png" alt="FIFO Queue in Amazon SQS" width="800" height="119"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can setup a simple FIFO Queue in Amazon SQS to ensure ordered delivery of messages. I'll walk you through the code separately where we avoid message duplication.&lt;/p&gt;

&lt;h2&gt;
  
  
  The 1st Lambda Function
&lt;/h2&gt;

&lt;p&gt;We're writing a function that is waiting for an object to be loaded into S3 so that it can be processed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3xo9s1txz9qg4bszolvb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3xo9s1txz9qg4bszolvb.png" alt="Lambda Visuals" width="800" height="485"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I didn't find an exact method to set the SQS queue as the destination, I am not sure if it's a permission issue because I wouldn't be able to touch it via boto3 either, but I was. Here, the S3 is our trigger and SQS is our programmatic destination. &lt;/p&gt;

&lt;p&gt;The code is available on &lt;a href="https://github.com/sreekeshiyer/s3-redshift-transfer" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here's where the business logic for our transactions goes in. Given that this is serverless and decoupled fully, this can be as complex as it can get. I've attached a simplified version below -&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feshaedfpswmqmtfgggck.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feshaedfpswmqmtfgggck.png" alt="Business Logic for Transactions" width="800" height="470"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Object Storage via S3
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flthl9ar95jt9e0qzdiuy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flthl9ar95jt9e0qzdiuy.png" alt="S3 Bucket Visuals" width="800" height="247"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It can be a standard bucket in the same region, just make sure you add this event notification in the S3 Properties to invoke the Lambda we just created.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpch0wot0drkcvtva109n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpch0wot0drkcvtva109n.png" alt="Event Notification in S3 Properties" width="800" height="165"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The 2nd Lambda Function
&lt;/h2&gt;

&lt;p&gt;We're now inside the analytics side of things where it'a all about ETL and further processing in Redshift. For starters, we need a function that can trigger from an SQS message and subsequently pass it on to Amazon Redshift. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxa6dldnwpk1w0q2syk1b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxa6dldnwpk1w0q2syk1b.png" alt="SQS Response to Redshift Lambda Function" width="800" height="508"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's what this function looks like. Waits for a message in the SQS queue, performs a validation and pushes it to Redshift. Since we are using a FIFO Queue, we get access to a &lt;strong&gt;Deduplication value&lt;/strong&gt; from the SQS Message which we can use to filter out duplicate messages.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcqmxok75xp3n33e3ygci.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcqmxok75xp3n33e3ygci.png" alt="Deduplication Logic" width="800" height="261"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can also perform type-validations easily because "thanks Python!"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5w4xcrrvfmd9i5mghbt5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5w4xcrrvfmd9i5mghbt5.png" alt="Validations" width="800" height="490"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Redshift - the last checkpoint
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0k11s8kcnyhvln7cf2ts.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0k11s8kcnyhvln7cf2ts.png" alt="Redshift Query Editor" width="800" height="187"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can make use of the default workgroup in Redshift serverless and the base "dev" database where you can create a new table "transactions" to insert all of this data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8agvu7ogarx11eg4jtz4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8agvu7ogarx11eg4jtz4.png" alt="Object Sample" width="800" height="544"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After that, all you need to do is upload a JSON file to the S3 Bucket that looks like this and see the magic:)&lt;/p&gt;

&lt;p&gt;I hope you found this thread informative. The core idea was to decouple compute and storage which we are able to achieve here. &lt;/p&gt;

&lt;p&gt;Do follow the blog for more. Until next time - Cheers, Happy Holidays! &lt;/p&gt;

</description>
    </item>
    <item>
      <title>Simplifying Reinforcement Learning Terminologies - AWS DeepRacer Edition</title>
      <dc:creator>Sreekesh Iyer</dc:creator>
      <pubDate>Sun, 01 Dec 2024 16:37:55 +0000</pubDate>
      <link>https://forem.com/aws-builders/simplifying-reinforcement-learning-terminologies-aws-deepracer-edition-57ip</link>
      <guid>https://forem.com/aws-builders/simplifying-reinforcement-learning-terminologies-aws-deepracer-edition-57ip</guid>
      <description>&lt;p&gt;If you’re new to machine learning, reinforcement learning, especially, then it’s completely okay to have a hard time understanding these fancy jargons in front of you. Here’s my attempt to simplify these while we work on a little robo-car :)&lt;/p&gt;

&lt;h3&gt;
  
  
  About AWS DeepRacer
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frbtgib5g177wver44dsh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frbtgib5g177wver44dsh.png" alt="Deepracer Dashboard" width="800" height="487"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A contest that is discontinued after this year, unfortunately, DeepRacer is arguably the most entertaining service available on the AWS Console today. This is the arena where you can train a virtual car to run through a racetrack, and the challenge is to complete 3 laps as quickly as possible without going off-road.&lt;/p&gt;

&lt;p&gt;—&lt;/p&gt;

&lt;p&gt;Before I get to the jargons, let’s first try to understand&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Reinforcement Learning?
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Reinforcement learning&lt;/strong&gt; (&lt;strong&gt;RL&lt;/strong&gt;) is an interdisciplinary area of &lt;a href="https://en.wikipedia.org/wiki/Machine_learning" rel="noopener noreferrer"&gt;machine learning&lt;/a&gt; &lt;a href="https://en.wikipedia.org/wiki/Machine_learning" rel="noopener noreferrer"&gt;and optimal cont&lt;/a&gt;&lt;a href="https://en.wikipedia.org/wiki/Optimal_control" rel="noopener noreferrer"&gt;rol&lt;/a&gt; &lt;a href="https://en.wikipedia.org/wiki/Optimal_control" rel="noopener noreferrer"&gt;concerned with&lt;/a&gt; how an &lt;a href="https://en.wikipedia.org/wiki/Intelligent_agent" rel="noopener noreferrer"&gt;intelligent agent&lt;/a&gt; &lt;a href="https://en.wikipedia.org/wiki/Intelligent_agent" rel="noopener noreferrer"&gt;should take actio&lt;/a&gt;&lt;a href="https://en.wikipedia.org/wiki/Action_selection" rel="noopener noreferrer"&gt;ns&lt;/a&gt; &lt;a href="https://en.wikipedia.org/wiki/Action_selection" rel="noopener noreferrer"&gt;in a dynamic&lt;/a&gt; environment in order to &lt;a href="https://en.wikipedia.org/wiki/Reward-based_selection" rel="noopener noreferrer"&gt;maximize a reward&lt;/a&gt; &lt;a href="https://en.wikipedia.org/wiki/Reward-based_selection" rel="noopener noreferrer"&gt;signal&lt;/a&gt; ~ Wikipedia&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;While I barely made it through that sentence, let’s imagine reinforcement learning as training a dog to fetch the ball for you. Every time the doggo fetches the ball, you give the little guy some treats. You’re giving him &lt;em&gt;positive reinforcement&lt;/em&gt;, or as we call it &lt;strong&gt;incentive&lt;/strong&gt;, to perform that &lt;strong&gt;action&lt;/strong&gt;. This is basically what we do in RL as well. We give a reward to our &lt;em&gt;intelligent agents&lt;/em&gt; based on their actions to get a desired result.&lt;/p&gt;

&lt;p&gt;In case of AWS DeepRacer, the agent is a car, and the desired result is for it to complete the track without going off-track, as quickly as possible. This means that our rewards need to account for the speed of the car, the nature of the track, the turns and more.&lt;/p&gt;




&lt;p&gt;Now that we have an understanding of what RL is, let’s try to understand the &lt;em&gt;hyperparameters&lt;/em&gt; for our model that may have an impact on our end-results.&lt;/p&gt;

&lt;h3&gt;
  
  
  Batch Size
&lt;/h3&gt;

&lt;p&gt;Models based on Neural Network train in iterations, meaning they update themselves after every round of learning. This hyperparameter gives you control over &lt;strong&gt;how much&lt;/strong&gt; your model learns in every iteration. Keep in mind that all hyperparameters have their benefits and trade-offs. In this case, a larger batch size (say 128 over 64) would mean that the model would have a wider set of experiences to learn through, and generate a steady output, however, over iterations, it would take more memory and time.&lt;/p&gt;

&lt;p&gt;In Deepracer context, the batch size can essentially decide on the exploration that your model will &lt;em&gt;remember&lt;/em&gt; across various iterations of its training. Larger batch sizes can delay the convergence times but with every iteration, it’ll get your model closer to the optimal path.&lt;/p&gt;

&lt;h3&gt;
  
  
  Entropy
&lt;/h3&gt;

&lt;p&gt;I heard about this term for the first time in Chemistry, and very simply - it’s a measure of randomness. Think about &lt;em&gt;how much&lt;/em&gt; you want your model to &lt;em&gt;explore&lt;/em&gt; while training. The possibilities it can figure out to eventually find out an optimal result. In case of your robo-car, it can find different ways to cover a track, for example. taking fast, shorter turns, taking slow, longer turns, etc. and it eventually finds out the best option based on the incentive it gets.&lt;/p&gt;

&lt;p&gt;You might want to reduce the entropy with time as the model matures, as you’d figure out it’s closer to the optimal path, you wouldn’t want it to diverge from that.&lt;/p&gt;

&lt;h3&gt;
  
  
  Discount factor
&lt;/h3&gt;

&lt;p&gt;A value that ranges between 0 and 1, it signifies the importance your model gives to short term gains over the long term rewards. Discounting Factor closer to 1 means that you prefer future success over immediate high rewards on that particular action on the iteration. Whereas a factor closer to 0 means that it’ll prioritise the incentives it just received. In DeepRacer, it’s critical that the car has a long-term foresight so as to ensure it doesn’t land itself is bad positions around curves or turns that can lead to crashes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Learning rate
&lt;/h3&gt;

&lt;p&gt;This parameter basically controls how quickly your model reaches the point of convergence. However, with higher learning rates, you run the risk of overshooting, wherein you might get to an optimal path quicker and immediately diverge from it in the next iteration. The key, like most other parameters, is balance. You can adjust the learning rate based on observation of the patterns that your model creates while training. In DeepRacer, this can potentially define how quickly your model is able to adapt to changes, eg. sharp turns after a straight road, where your car is initially intending to run at full speed, but then has to slow down and turn 140 degrees.&lt;/p&gt;

&lt;h3&gt;
  
  
  Number of epochs
&lt;/h3&gt;

&lt;p&gt;Epoch - can be defined as a collective batch of experiences combined by various episodes in a training window. Your complete process can have many &lt;strong&gt;different&lt;/strong&gt; batches, meaning the model has to move on from one set to another. The number of epochs signifies the amount of time your model spends on one such set. This can essentially refine how your model thinks over a certain set of experiences. Longer epochs naturally mean longer training times and compute usage.&lt;/p&gt;




&lt;h2&gt;
  
  
  My Experience with DeepRacer
&lt;/h2&gt;

&lt;p&gt;[Update Feb 2025]&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8x4a0m6e8isqw4kx8moq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8x4a0m6e8isqw4kx8moq.png" alt="DeepRacer Achievement" width="800" height="635"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's really sad to see DeepRacer go, as of writing this article I was completely unaware of the news that we just had the last year of the AWS DeepRacer competition. I worked with a lot of my colleagues in my firm to come up with solid reward functions to go further in the comp.&lt;/p&gt;

&lt;p&gt;As a small achievement, I received an Asia Top 50 Regional award along with a 100$ Amazon Gift Card :)&lt;/p&gt;

&lt;p&gt;Hope this was a good read to cover various Deep Learning jargons and simplify your experience working with neural networks going forward. Thank you for reading:)&lt;/p&gt;

</description>
      <category>aws</category>
      <category>deepracer</category>
      <category>deeplearning</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Setting up a REST API in Python for DynamoDB</title>
      <dc:creator>Sreekesh Iyer</dc:creator>
      <pubDate>Fri, 15 Nov 2024 06:30:00 +0000</pubDate>
      <link>https://forem.com/aws-builders/setting-up-a-rest-api-in-python-for-dynamodb-3l9g</link>
      <guid>https://forem.com/aws-builders/setting-up-a-rest-api-in-python-for-dynamodb-3l9g</guid>
      <description>&lt;p&gt;Dynamo DB is AWS's NoSQL offering in the vast set of managed databases as a service that they provide. Like most other services, it's fully serverless, flexible and easy to scale.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Data Model
&lt;/h2&gt;

&lt;p&gt;As we're working on NoSQL here, there's no real restriction on the structure of data. We can operate with key-value pairs as the &lt;em&gt;attributes&lt;/em&gt; for each &lt;em&gt;item&lt;/em&gt; in a &lt;em&gt;table.&lt;/em&gt; Let's look at these keywords again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Table&lt;/strong&gt; - a fairly familiar term, it is essentially a collection of data, in this case, items. It is also the starting point of working with DynamoDB on the console.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Item&lt;/strong&gt; - an entry in a table. You could consider it a row in an SQL-equivalent database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Attribute&lt;/strong&gt; - The datapoints that constitute an item. It could contain item-specific attributes, metadata, or virtually anything that can be associated with an item.&lt;/p&gt;

&lt;p&gt;You could think of a JSON array as an equivalent to a table in DynamoDB. I'm sure things will get clearer as we create our own table.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up the database
&lt;/h2&gt;

&lt;p&gt;It's literally a piece of cake to create a new table in DynamoDB from the AWS Console. All you need is a name and a partition key, which is your primary key in this case. This will help you search for items in the table.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb25w43848mgvxyrohxnj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb25w43848mgvxyrohxnj.png" alt="DB setup" width="800" height="588"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm creating a table for all the games that I've played, and I will rate them out of 10 :)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjtu0ddsqd96a1pxq09z1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjtu0ddsqd96a1pxq09z1.png" alt="Dashboard overview of the DB on the AWS Dynamo DB Console" width="800" height="314"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can mess with the table directly from the console, let's try adding a new item to see what it looks like.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvzn5zlvjy98el8flyw0s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvzn5zlvjy98el8flyw0s.png" alt="Creating a new item for the DB via the console" width="800" height="326"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My first entry has to be my favourite RPG (role-playing) game - The Witcher 3. I will add a new attribute for &lt;em&gt;rating&lt;/em&gt; and it's going to be a solid 9.8 from me :)&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up an API
&lt;/h2&gt;

&lt;p&gt;Right, it's now time to write some Python code to do all of this without the GUI ;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;## app.py
&lt;/span&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;flask&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;jsonify&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;boto3.dynamodb.conditions&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Key&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;uuid&lt;/span&gt;  &lt;span class="c1"&gt;# Import uuid module for generating UUIDs
&lt;/span&gt;
&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Initialize DynamoDB client
&lt;/span&gt;&lt;span class="n"&gt;dynamodb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;boto3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;dynamodb&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;region_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ap-south-1&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Replace with your region
## Do keep in mind to save your AWS credentials file in the root directory
&lt;/span&gt;&lt;span class="n"&gt;table&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dynamodb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Table&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;games&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Replace with your table name
&lt;/span&gt;
&lt;span class="c1"&gt;# Route to get all games
&lt;/span&gt;&lt;span class="nd"&gt;@app.route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;/games&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;methods&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;GET&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_games&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;scan&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;games&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Items&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;jsonify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;games&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;games&lt;/span&gt;&lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;jsonify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;error&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)}),&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;debug&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The beauty of Python is that you can setup a full-fledged API in just a few lines of code. This chunk of code is now sufficient for us to access the table and fetch the data from it. We use the &lt;code&gt;scan&lt;/code&gt; function to fetch items from the games table.&lt;/p&gt;

&lt;p&gt;You can start the app by using &lt;code&gt;python3 app.py&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8cvl610dy9erbjvqwbfa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8cvl610dy9erbjvqwbfa.png" alt="Console response from the API" width="359" height="183"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And you can expect a response that looks like this when you curl for the &lt;code&gt;/games&lt;/code&gt; endpoint.&lt;/p&gt;

&lt;h3&gt;
  
  
  Routes for creating and updating an entry
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Route to create a new game
&lt;/span&gt;&lt;span class="nd"&gt;@app.route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;/games&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;methods&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;POST&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;create_game&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;game_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;game_data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;rating&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;game_data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;rating&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;hours&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;game_data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;hours&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="c1"&gt;# Generate a random UUID for the new game
&lt;/span&gt;        &lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uuid&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;uuid4&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;rating&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;jsonify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;error&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Missing required fields&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="mi"&gt;400&lt;/span&gt;

        &lt;span class="c1"&gt;# Store the game in DynamoDB
&lt;/span&gt;        &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put_item&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Item&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;id&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;rating&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rating&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;hours&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;hours&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;

        &lt;span class="c1"&gt;# Return the created game with the generated UUID
&lt;/span&gt;        &lt;span class="n"&gt;created_game&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;id&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;rating&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rating&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;jsonify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;message&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Game added successfully&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;game&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;created_game&lt;/span&gt;&lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="mi"&gt;201&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;jsonify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;error&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)}),&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;

&lt;span class="c1"&gt;# Route to update an existing game
&lt;/span&gt;&lt;span class="nd"&gt;@app.route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;/games/&amp;lt;int:id&amp;gt;&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;methods&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;PUT&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;update_game&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;game_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get_json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;game_data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;rating&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;game_data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;rating&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;hours&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;game_data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;hours&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;rating&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;jsonify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;error&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Nothing to update&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="mi"&gt;400&lt;/span&gt;

        &lt;span class="n"&gt;update_expression&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;SET &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
        &lt;span class="n"&gt;expression_attribute_values&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;update_expression&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; #n = :n,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
            &lt;span class="n"&gt;expression_attribute_values&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;:n&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;rating&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;update_expression&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; #r = :r,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
            &lt;span class="n"&gt;expression_attribute_values&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;:r&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;rating&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;hours&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;update_expression&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt; #h = :h,&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
            &lt;span class="n"&gt;expression_attribute_values&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;:h&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;hours&lt;/span&gt;

        &lt;span class="n"&gt;update_expression&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;update_expression&lt;/span&gt;&lt;span class="p"&gt;[:&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;  &lt;span class="c1"&gt;# remove trailing comma
&lt;/span&gt;        &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update_item&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;Key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;id&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="n"&gt;UpdateExpression&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;update_expression&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;ExpressionAttributeNames&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;#n&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;name&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;#r&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;rating&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;#h&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;hours&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
            &lt;span class="n"&gt;ExpressionAttributeValues&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;expression_attribute_values&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;ReturnValues&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;UPDATED_NEW&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;updated_game&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Attributes&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{})&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;jsonify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;updated_game&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;jsonify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;error&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)}),&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, we are using &lt;code&gt;put_item&lt;/code&gt; to add an item to the table. For updating a record, we use the function &lt;code&gt;update_item&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you observe carefully, we are using &lt;strong&gt;&lt;em&gt;UpdateExpression&lt;/em&gt;&lt;/strong&gt; where we specify the attributes that we're updating. This allows us to control exactly which attribute gets changed and avoid accidental overwrites.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F196q6rbhyuwl180mqboy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F196q6rbhyuwl180mqboy.png" alt="API Response for Updates" width="362" height="262"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And to delete the record, you can go with something like this -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;table&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;delete_item&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;Key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;id&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="n"&gt;ReturnValues&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;ALL_OLD&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;  &lt;span class="c1"&gt;# Optional: returns the item that was deleted
&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Well, there you have it, you just setup a REST API with CRUD Functionality for DynamoDB in a matter of minutes thanks to Python.&lt;/p&gt;

</description>
      <category>flask</category>
      <category>python</category>
      <category>aws</category>
      <category>dynamodb</category>
    </item>
    <item>
      <title>Integrated AWS Workflows with SageMaker Notebooks</title>
      <dc:creator>Sreekesh Iyer</dc:creator>
      <pubDate>Sat, 09 Nov 2024 11:13:17 +0000</pubDate>
      <link>https://forem.com/aws-builders/integrated-aws-workflows-with-sagemaker-notebooks-h89</link>
      <guid>https://forem.com/aws-builders/integrated-aws-workflows-with-sagemaker-notebooks-h89</guid>
      <description>&lt;p&gt;I was recently a part of a corporate hackathon and was found searching for good Jupyter environments on the cloud to be able to work on my ML Project.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Far7d0x2hp6w48cv5igsx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Far7d0x2hp6w48cv5igsx.png" alt="Sagemaker Notebooks landing page" width="800" height="258"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Soon enough, I found myself here. However, it took me a while to figure out how powerful it truly can be.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flww4cj7513pnbqqbw3t3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flww4cj7513pnbqqbw3t3.png" alt="Repository settings for Sagemaker Notebooks" width="800" height="634"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For starters, I was able to hook it up to any Repository within seconds. So I did not have to worry about versioning or sharing it with teammates.&lt;/p&gt;

&lt;h3&gt;
  
  
  Direct access to GPU instances
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fposssg6178sfmchlq0ii.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fposssg6178sfmchlq0ii.png" alt="Raising access to GPU Notebook instances" width="800" height="235"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You’ll need to get an additional approval to make use of the ml.g-series of instances in SageMaker Notebooks, but it didn’t take longer than a minute for me. And just like that, I have access to a Jupyter notebook with TensorFlow and a GPU.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F49jdipqsupmlhh9lyplr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F49jdipqsupmlhh9lyplr.png" alt="Me running the simplest tensorflow code on Jupyter light mode" width="800" height="464"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Integrations with other AWS Services
&lt;/h3&gt;

&lt;p&gt;This is not a Sagemaker feature as much as it is an AWS IAM feature, but when you get hold of the IAM Role that is being used by the Sagemaker Notebook, you can basically open up your Python shell to have access to literally any AWS service via client libraries like boto3.&lt;/p&gt;

&lt;p&gt;You can control EC2 instances, invoke Lambda functions, send emails via SES, perform operations on S3 objects and so many other things programmatically through the same Jupyter notebook.&lt;/p&gt;

&lt;p&gt;—&lt;/p&gt;

&lt;p&gt;So far, it’s been fun watching folks work on Sagemaker Notebooks trying out different ways to automate workflows on AWS using raw Python. Looks like I’ve found my new provider for easy-access Cloud Notebooks.&lt;/p&gt;

</description>
      <category>sagemaker</category>
      <category>aws</category>
      <category>jupyter</category>
    </item>
    <item>
      <title>My experience with the AWS Community 'New Voices' Program</title>
      <dc:creator>Sreekesh Iyer</dc:creator>
      <pubDate>Wed, 27 Dec 2023 17:09:44 +0000</pubDate>
      <link>https://forem.com/aws-builders/my-experience-with-the-aws-community-new-voices-program-1042</link>
      <guid>https://forem.com/aws-builders/my-experience-with-the-aws-community-new-voices-program-1042</guid>
      <description>&lt;p&gt;Hi folks!&lt;/p&gt;

&lt;p&gt;The New Year is just around the corner and that means that the applications for the &lt;a href="https://aws.amazon.com/developer/community/community-builders/" rel="noopener noreferrer"&gt;AWS Community Builder Program&lt;/a&gt; are soon going to open up!&lt;/p&gt;

&lt;p&gt;As a Community Builder this year, I'd like to take you through some of my best experiences - becoming a part of the AWS New Voices Cohort.&lt;/p&gt;

&lt;h2&gt;
  
  
  About AWS New Voices
&lt;/h2&gt;

&lt;p&gt;The New Voices Program is a very new, building idea of gathering potential speakers from the pool of AWS Community Builders and honing their speaking skills under the guidance of experienced speakers from the community who chip in as coaches.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Overall Setup
&lt;/h2&gt;

&lt;p&gt;Set up in July 2023, we had a total of 4 sessions (once in a week) in which we had to prepare a small talk of 3-4 minutes where we described how we solved a problem using technology (not necessarily related to AWS)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjj99k9uazl8tw4t1n8l3.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjj99k9uazl8tw4t1n8l3.JPG" alt="A snippet from one of the learning sessions where I was speaking" width="800" height="337"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Every new session, a different twist was added to the same topic of discussion to bring in the quality of range to our speaking skills.&lt;/p&gt;

&lt;p&gt;Barring the last session, there were no slides. It was all about talking to your audience for a certain period of time, describing how you solved a problem&lt;/p&gt;

&lt;p&gt;At the end of the talk, the host along with the Coaches give you actionable feedback that you can work on before you join the next session.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Power of Acknowledgement
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fykrlu80vfsi6mhuapnro.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fykrlu80vfsi6mhuapnro.png" alt="A picture of me talking on the stage" width="800" height="487"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As someone who comes with a history of sheer social anxiety and nervousness on the stage, to be able to stand in front of a crowd and speak today is a blessing.&lt;/p&gt;

&lt;p&gt;But it's also still very scary. And definitely not easy for everyone. What helps is the acknowledgement of people listening to you, people telling you that you did a good job and they liked your talk.&lt;/p&gt;

&lt;p&gt;This is exactly what I got from this program. At the end of the talk, the host appreciates your effort, talks about the stand-out points in your talk. All the speakers appreciate your work and mention the key highlights where you did well. Everybody &lt;em&gt;jazz hands&lt;/em&gt; at you &lt;em&gt;(refer to the cover image)&lt;/em&gt; acknowledging the solid work that you did.&lt;/p&gt;




&lt;p&gt;I'm not sure about the future of the program, how it's going to be structured in 2024, but I'm exited and super happy to be an AWS New Voices &lt;strong&gt;Graduate&lt;/strong&gt;. Looking forward to more Community Builders joining in Q1 becoming a part of this program as well :)&lt;/p&gt;

&lt;p&gt;Thanks for reading, Happy Holidays!&lt;/p&gt;

</description>
      <category>aws</category>
      <category>speaking</category>
      <category>community</category>
    </item>
    <item>
      <title>Building a Llama2 Langchain powered Simple Chat Bot hosted on Napptive</title>
      <dc:creator>Sreekesh Iyer</dc:creator>
      <pubDate>Sun, 20 Aug 2023 05:40:37 +0000</pubDate>
      <link>https://forem.com/sreekeshiyer/building-a-llama2-langchain-powered-simple-chat-bot-hosted-on-napptive-2h96</link>
      <guid>https://forem.com/sreekeshiyer/building-a-llama2-langchain-powered-simple-chat-bot-hosted-on-napptive-2h96</guid>
      <description>&lt;p&gt;Hey folks! 👋&lt;/p&gt;

&lt;p&gt;Not so long ago, I came across a post from LangChain on the Threads App about how easy it is to create a chat assistant using Llama2.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fduknejn8vd9gp8g56d7u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fduknejn8vd9gp8g56d7u.png" alt="A Screentshot of a langchain.ai post on the Threads App which talks about building a llama2 langchain powered chatbot in less than 20 lines of code. " width="416" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's the tutorial that you can look into, thanks to &lt;a href="https://github.com/Anil-matcha" rel="noopener noreferrer"&gt;Anil-matcha&lt;/a&gt; who shared it on &lt;a href="https://github.com/Anil-matcha/langchain-tutorials" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I've been fascinated by how difficult it generally is to physically host an LLM, but first, let's create an app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a working environment on Napptive
&lt;/h2&gt;

&lt;p&gt;I sneaked into the documentation a bit and found out that the model can work just on the CPU, but it does better if you also have a GPU.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff4i3xf1t807fflc692le.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff4i3xf1t807fflc692le.png" alt="Screenshot of the Jupyter image on the Napptive catalog" width="800" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since this is all &lt;em&gt;Python&lt;/em&gt;, we can create the app on a Jupyter environment as well. The easiest way to create a Jupyter environment on the cloud is by using Napptive.&lt;/p&gt;

&lt;p&gt;To learn more about Napptive and an extensive guide on hosting your Jupyter Lab on Napptive, here's &lt;a href="https://questit-editorial.hashnode.dev/hosting-jupyter-napptive" rel="noopener noreferrer"&gt;one of my old articles&lt;/a&gt; you can refer to.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi9z9d2rk7f8up5bzql56.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi9z9d2rk7f8up5bzql56.png" alt="Screenshot of the napptive/jupyter config file highlighting the code that you need to expose a new port." width="800" height="561"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before you deploy the app though, you'll have to make a couple of changes to the config YAML file. Firstly, expose the port &lt;code&gt;8501&lt;/code&gt; for streamlit and create a &lt;code&gt;napptive-ingress&lt;/code&gt; trait for it. This is because we'll be using Streamlit for the app UI.&lt;/p&gt;

&lt;p&gt;Once that's done, you can deploy the app.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building the App
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgyrccfqz6157rw65lfox.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgyrccfqz6157rw65lfox.png" alt="Jupyter Notebook Launcher Screenshot" width="800" height="525"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you get into the Jupyter environment, create a new terminal, we have a few things to set up before we get going.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install langchain, the llama module and streamlit&lt;/span&gt;
pip &lt;span class="nb"&gt;install &lt;/span&gt;langchain llama-cpp-python streamlit
&lt;span class="c"&gt;# Download Llama2 model from hugging-face&lt;/span&gt;
wget https://huggingface.co/TheBloke/Llama-2-13B-chat-GGML/resolve/main/llama-2-13b-chat.ggmlv3.q4_0.bin

&lt;span class="nb"&gt;mkdir&lt;/span&gt; .streamlit
nano .streamlit/config.toml
&lt;span class="c"&gt;## Add this to the config&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;theme]
&lt;span class="nv"&gt;primaryColor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"#F63366"&lt;/span&gt;
&lt;span class="nv"&gt;backgroundColor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"#111827"&lt;/span&gt;
&lt;span class="nv"&gt;secondaryBackgroundColor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"#6B7280"&lt;/span&gt;
&lt;span class="nv"&gt;textColor&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"#FFFFFF"&lt;/span&gt;
&lt;span class="nv"&gt;font&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"sans serif"&lt;/span&gt;
&lt;span class="c"&gt;## Ctrl + S to save the file, Ctrl + X to exit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The UI for this is inspired by the Streamlit ChatBot tutorial which you can find &lt;a href="https://blog.streamlit.io/how-to-build-an-llm-powered-chatbot-with-streamlit/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Once the config is setup, create a new file &lt;code&gt;app.py&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;streamlit&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;

&lt;span class="c1"&gt;# App title
&lt;/span&gt;&lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set_page_config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page_title&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;💬 LLama2 Langchain ChatBot&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Store LLM generated responses
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;messages&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;session_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;session_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;assistant&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;How may I help you?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}]&lt;/span&gt;

&lt;span class="c1"&gt;# Display chat messages
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;session_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;chat_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]):&lt;/span&gt;
        &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# User-provided prompt
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;prompt&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;chat_input&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;session_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;chat_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Initially, we'll just import streamlit, setup an array to store all chat messages in a streamlit-session and then create the UI for the chat.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.llms&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;LlamaCpp&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.callbacks.manager&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;CallbackManager&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.callbacks.streaming_stdout&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;StreamingStdOutCallbackHandler&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;LLMChain&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;PromptTemplate&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.memory&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ConversationBufferWindowMemory&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll import all the different classes and functions we'll use from Langchain.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;callback_manager&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;CallbackManager&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nc"&gt;StreamingStdOutCallbackHandler&lt;/span&gt;&lt;span class="p"&gt;()])&lt;/span&gt;

&lt;span class="c1"&gt;# Make sure the model path is correct for your system!
&lt;/span&gt;&lt;span class="n"&gt;llm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;LlamaCpp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model_path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;./llama-2-13b-chat.ggmlv3.q4_0.bin&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;temperature&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.75&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;max_length&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;top_p&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="n"&gt;callback_manager&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;callback_manager&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;verbose&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="c1"&gt;# Function for generating LLM response
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;generate_response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt_input&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;

    &lt;span class="n"&gt;template&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;I am a Large Language Model Llama set up on Langchain.
    {history}
    Human: {human_input}
    Assistant:&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

    &lt;span class="n"&gt;prompt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;PromptTemplate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input_variables&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;history&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;human_input&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;chatbot&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;LLMChain&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;llm&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;llm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;verbose&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;memory&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;ConversationBufferWindowMemory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;chatbot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;human_input&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;prompt_input&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="c1"&gt;# Generate a new response if last message is not from assistant
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;session_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;assistant&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;chat_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;assistant&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;spinner&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
            &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;generate_response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
            &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;assistant&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;session_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Further, we initialize the LLM Class with the model that we downloaded, write a function that creates the chain to generate responses and lastly, the UI to showcase those responses.&lt;/p&gt;

&lt;p&gt;Refer to the snippet below for the entire code from the file &lt;code&gt;app.py&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;streamlit&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.llms&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;LlamaCpp&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.callbacks.manager&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;CallbackManager&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.callbacks.streaming_stdout&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;StreamingStdOutCallbackHandler&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;LLMChain&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;PromptTemplate&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;langchain.memory&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;ConversationBufferWindowMemory&lt;/span&gt;

&lt;span class="c1"&gt;# App title
&lt;/span&gt;&lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set_page_config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page_title&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;💬 LLama2 Langchain ChatBot&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Store LLM generated responses
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;messages&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;session_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;session_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;assistant&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;How may I help you?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}]&lt;/span&gt;

&lt;span class="c1"&gt;# Display chat messages
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;session_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;chat_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]):&lt;/span&gt;
        &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

&lt;span class="c1"&gt;# User-provided prompt
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;prompt&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;chat_input&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;session_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;chat_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;user&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;callback_manager&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;CallbackManager&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nc"&gt;StreamingStdOutCallbackHandler&lt;/span&gt;&lt;span class="p"&gt;()])&lt;/span&gt;

&lt;span class="c1"&gt;# Make sure the model path is correct for your system!
&lt;/span&gt;&lt;span class="n"&gt;llm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;LlamaCpp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;model_path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;./llama-2-13b-chat.ggmlv3.q4_0.bin&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;temperature&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.75&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;max_length&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;top_p&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="n"&gt;callback_manager&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;callback_manager&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;verbose&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="c1"&gt;# Function for generating LLM response
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;generate_response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt_input&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;

    &lt;span class="n"&gt;template&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;I am a Large Language Model Llama set up on Langchain.
    {history}
    Human: {human_input}
    Assistant:&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

    &lt;span class="n"&gt;prompt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;PromptTemplate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input_variables&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;history&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;human_input&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;template&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;chatbot&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;LLMChain&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;llm&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;llm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;verbose&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;memory&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;ConversationBufferWindowMemory&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;chatbot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;human_input&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;prompt_input&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="c1"&gt;# Generate a new response if last message is not from assistant
&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;session_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;assistant&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;chat_message&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;assistant&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;spinner&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
            &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;generate_response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prompt&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
            &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;assistant&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;st&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;session_state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Running the App
&lt;/h2&gt;

&lt;p&gt;To run this file, create a new Terminal window and run the following command -&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;streamlit run app.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx4z7intnw4oivr4tx7mc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx4z7intnw4oivr4tx7mc.png" alt="Screenshot of the output when you get " width="602" height="145"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If the service is up and running, you'll see a similar message in the shell from Streamlit.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc8rb5gbm2fxkizp36jlh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc8rb5gbm2fxkizp36jlh.png" alt="Screenshot of the Jupyter app on the Napptive console highlighting the streamlit URL. " width="800" height="475"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can check the app following the link in the &lt;em&gt;streamlit&lt;/em&gt; endpoint on the Napptive Console.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feq7fo9cl7twq0vr0rzte.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feq7fo9cl7twq0vr0rzte.png" alt="Screenshot of the chatbot UI" width="538" height="232"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1fat0aeputfxboyqopk1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1fat0aeputfxboyqopk1.png" alt="Screenshot of the console output when the LLM chain starts" width="800" height="136"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While you enter the prompts on Chat, you can also check out what it does on the Terminal.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Results
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc2kv3wg8x74sj5ofg0pm.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc2kv3wg8x74sj5ofg0pm.gif" alt="GIF that shows the input and the result shared by the chatbot" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's a demo of what the app looks like.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The app runs fine, but I've come across a few issues, for starters it's very slow (understandably because it's on CPU) and secondly, sometimes it loops itself where after finishing the response it automatically creates a new question and starts answering it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;What could've been better?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I didn't spend too much time on the UI, so you can see that the chatbot just dumps the response instead of streaming it word-by-word as you would see on other bots like ChatGPT.&lt;/p&gt;




&lt;p&gt;That's it for this article, I hope you liked it, stay tuned on this series because I'm pretty sure there's a lot more to come. In the next article, we'll try something similar with the help of AWS Sagemaker :)&lt;/p&gt;

&lt;p&gt;As always, thanks for reading, keep spreading your love, Cheers! 🥂&lt;/p&gt;

</description>
      <category>llm</category>
      <category>ai</category>
      <category>cloudnative</category>
    </item>
    <item>
      <title>The Easiest way to install Docker Engine on a Linux Server</title>
      <dc:creator>Sreekesh Iyer</dc:creator>
      <pubDate>Sun, 30 Jul 2023 14:03:54 +0000</pubDate>
      <link>https://forem.com/sreekeshiyer/the-easiest-way-to-install-docker-engine-on-a-linux-server-lp8</link>
      <guid>https://forem.com/sreekeshiyer/the-easiest-way-to-install-docker-engine-on-a-linux-server-lp8</guid>
      <description>&lt;p&gt;If you're working on a local machine, you can easily download and &lt;a href="https://www.docker.com/products/docker-desktop/" rel="noopener noreferrer"&gt;install Docker Desktop&lt;/a&gt; for your operating system - Windows, Mac or even Linux Desktops these days.&lt;/p&gt;

&lt;p&gt;However, if you're someone like me who does most of the work on the Cloud, or to be specific, remote environments, this may not be the right choice for you.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0kgqvovf70cybuasw3q9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0kgqvovf70cybuasw3q9.png" alt="A man screaming " width="400" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Something that I discovered pretty late is that Docker, for quite some time, has had a super fast solution to install Docker Engine in Linux environments.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyb6wcj3df4h87dak3zcv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyb6wcj3df4h87dak3zcv.png" alt="Screenshot of the website get.docker.com" width="800" height="640"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you check the website &lt;a href="https://get.docker.com" rel="noopener noreferrer"&gt;https://get.docker.com&lt;/a&gt;, you will find out that Docker maintains a script to install Docker Engine on Linux.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;As they mentioned, this method is not intended for production environments, which I assume anyway will be working with a specific Docker version.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The best part about this script is that you need absolutely no package managers to work with.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing Docker using the Script
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Download the script&lt;/span&gt;
curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://get.docker.com &lt;span class="nt"&gt;-o&lt;/span&gt; install-docker.sh

&lt;span class="c"&gt;# Run the script as it tries to figure out the type of Linux&lt;/span&gt;
&lt;span class="c"&gt;# distribution it's dealing with and installs the latest CLI and Engine versions&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;sh install-docker.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Simply running these two commands will install the latest version of the Docker Engine, its CLI and a few other tools/plugins like Compose, Buildx, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  Run Docker without Root access
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo7wk6wl3amncjku08cmu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo7wk6wl3amncjku08cmu.png" alt="Screenshot of the Permission Denied Error when you run docker commands without root access" width="722" height="222"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, if you run any docker command after installing, you'll probably come across a similar error. The quick solution to this is to run the same commands with &lt;em&gt;sudo&lt;/em&gt;, but it has been fairly annoying to me. But there's also a quick 1-command fix to this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-aG&lt;/span&gt; docker &amp;lt;USERNAME&amp;gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;reboot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq0ureqqaigui45ojsz3r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq0ureqqaigui45ojsz3r.png" alt="Screenshot of a working docker container ls command" width="498" height="178"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The flags &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;G&lt;/code&gt; in the command are to add the user to a group, and just by running the command and rebooting your system, you can run &lt;em&gt;docker&lt;/em&gt; commands without root access. Even though this requires one-time super-user access, I feel that it's definitely time-saving.&lt;/p&gt;




&lt;p&gt;Thanks for reading, I hope you have a good day ahead :)&lt;/p&gt;

</description>
      <category>docker</category>
      <category>ubuntu</category>
      <category>linux</category>
    </item>
    <item>
      <title>Self Hosting Supabase on AWS</title>
      <dc:creator>Sreekesh Iyer</dc:creator>
      <pubDate>Thu, 27 Jul 2023 06:44:30 +0000</pubDate>
      <link>https://forem.com/aws-builders/self-hosting-supabase-on-aws-1cdl</link>
      <guid>https://forem.com/aws-builders/self-hosting-supabase-on-aws-1cdl</guid>
      <description>&lt;p&gt;Hi there, folks!&lt;/p&gt;

&lt;p&gt;Supabase is a BaaS (Backend-as-a-service) I've been using for my full-stack projects for almost 2 years. It's an amazing service that is open source, runs on top of Postgres and brings cool features like auth (even third-party auth support for a zillion providers), storage, realtime and much more.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I have a Flask Series in which I use Supabase as a backend. &lt;a rel="noopener noreferrer nofollow" href="https://blog.sreekeshiyer.live/series/flask-dev-to-deployment"&gt;Check it out&lt;/a&gt;!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Why self-host Supabase?
&lt;/h2&gt;

&lt;p&gt;You can totally work with Supabase on the Cloud, as easy as it gets. But if you are on its Free Tier, you have limited access to some of the features of the application. And that's any service, not just Supabase.&lt;/p&gt;

&lt;p&gt;I feel that is why it's great to have the freedom to self-host these service-based applications because you get full control of how they run.&lt;/p&gt;

&lt;p&gt;What this does is that it gives you control over the infrastructure on top of which it runs, so you can take care of the scaling process as and when needed.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Or you don't want to see Ant's emails every week. Yeah, that's about it.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;In this article, I'm going to cover how we can quickly get Supabase up and running self-hosted on an AWS EC2 Instance. Let's get going!&lt;/p&gt;

&lt;p&gt;The Supabase Documentation already mentions &lt;a href="https://supabase.com/docs/guides/self-hosting/docker" rel="noopener noreferrer"&gt;an article&lt;/a&gt; on how you can self-host it using Docker. We're going to follow it as well :)&lt;/p&gt;

&lt;p&gt;Before getting started, let's take a look at the things we are going to need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;An AWS Account&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Preferably a few AWS credits, you may incur a bill&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's start by creating our EC2 instance on AWS!&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up the EC2 Instance
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ztwar3a5ni195ddq5i1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ztwar3a5ni195ddq5i1.png" alt="A screenshot of the AWS EC2 " width="800" height="886"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you're launching a new EC2 instance, make sure you select the &lt;strong&gt;Ubuntu&lt;/strong&gt; AMI, any instance type that has more than &lt;em&gt;4GB&lt;/em&gt; RAM, and preferably &lt;em&gt;20GB&lt;/em&gt; of storage.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;For a more detailed guide on launching an AWS EC2 Instance, check out &lt;a rel="noopener noreferrer nofollow" href="https://blog.sreekeshiyer.live/setting-up-an-apache-web-server-on-aws"&gt;this&lt;/a&gt; blog.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz0xhto5n8m0ktzsqszv0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz0xhto5n8m0ktzsqszv0.png" alt="Screenshot showcasing the inbound rules for a Security Group" width="800" height="149"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another thing is that you need to ensure you have all TCP ports and IP addresses open for inbound connections in your Security Group (&lt;em&gt;not recommended in production, of course)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm2ja416xup1n16zlg552.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm2ja416xup1n16zlg552.png" alt="Screenshot that shows how you can connect to an EC2 instance using SSH" width="667" height="615"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you've launched the instance, you can connect to it on the browser using EC2 Instance Connect, or if you've got a thing for fancy terminals like me, use SSH along with your key-pair to use your good old Terminal. Keep in mind, you use the &lt;em&gt;Public IPv4 address&lt;/em&gt; along with the username &lt;em&gt;ubuntu&lt;/em&gt; to connect.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing all dependencies
&lt;/h2&gt;

&lt;p&gt;Before we start installing dependencies, we're going to update our package list by running &lt;code&gt;sudo apt-get update -y&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After that, we're going to install Docker.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing Docker
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; get.docker.com &lt;span class="nt"&gt;-o&lt;/span&gt; install-docker.sh
&lt;span class="c"&gt;# This scripts installs the latest version of Docker Engine in your Linux machine&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;sh install-docker.sh

&lt;span class="c"&gt;## If you want to use Docker aommands without sudo or admin privileges&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-aG&lt;/span&gt; docker ubuntu
&lt;span class="c"&gt;## After running this command, reboot the instance for it to reflect&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We'll install Docker from its install-docker script on the official Docker website. You can continue using Docker as a super user OR just update the local user group and reboot your EC2 instance. It doesn't take long.&lt;/p&gt;

&lt;p&gt;Next up, we're going to set up Supabase!&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up Supabase
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;## Following from their documentation&lt;/span&gt;
&lt;span class="c"&gt;# Clone their repository&lt;/span&gt;
git clone &lt;span class="nt"&gt;--depth&lt;/span&gt; 1 https://github.com/supabase/supabase

&lt;span class="c"&gt;# Go to the docker folder&lt;/span&gt;
&lt;span class="nb"&gt;cd &lt;/span&gt;supabase/docker

&lt;span class="c"&gt;# Copy the fake env variables&lt;/span&gt;
&lt;span class="nb"&gt;cp&lt;/span&gt; .env.example .env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As mentioned in their documentation, all we need to do is clone the Supabase repository, copy and change the environment variables and get going!&lt;/p&gt;

&lt;p&gt;As good practice, NEVER work with the default environment variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nano .env
&lt;span class="c"&gt;## Once you've made the changes, Ctrl+S to save and Ctrl+X &lt;/span&gt;
&lt;span class="c"&gt;## to quit Nano and return to the shell.&lt;/span&gt;

&lt;span class="c"&gt;## Then run docker compose up command to start the server&lt;/span&gt;
&lt;span class="c"&gt;## This spins up &lt;/span&gt;
docker compose up
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use &lt;em&gt;Nano&lt;/em&gt; to edit the &lt;code&gt;.env&lt;/code&gt; file and make changes to your keys. You can follow the documentation to generate new keys and secrets. Once you've done that, you can run &lt;code&gt;docker compose up&lt;/code&gt; to get things up and running!&lt;/p&gt;

&lt;h2&gt;
  
  
  Check out The Studio
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzmc1hpx79ltv5x3b5xrp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzmc1hpx79ltv5x3b5xrp.png" alt="Screenshot that shows that Supabase is up and running on port 3000" width="800" height="315"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point, you can check out if the Supabase Studio runs on http://&amp;lt;YOUR_PUBLIC_IP&amp;gt;:3000/projects&lt;/p&gt;

&lt;p&gt;If you want to stop the service, you can do so by pressing &lt;code&gt;Ctrl+C&lt;/code&gt; or running &lt;code&gt;docker compose down&lt;/code&gt; if you're on a different shell window.&lt;/p&gt;

&lt;h2&gt;
  
  
  Recommended Cleanup
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjvjy3qn79z8v8i06jkjs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjvjy3qn79z8v8i06jkjs.png" alt="A warning message from AWS that you get when you try to terminate an EC2 instance." width="605" height="341"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Make sure you terminate your EC2 instance after you've stopped using it, or you may have a few unpleasant AWS billing-related emails coming your way.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Are the AWS billing emails worse than Ant shutting down your Supabase projects every week? Debatable. We can talk about it.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;That's it for this article, folks. Hope you liked it, I'll see you in the next one :)&lt;/p&gt;

</description>
      <category>supabase</category>
      <category>docker</category>
      <category>postgres</category>
      <category>ec2</category>
    </item>
    <item>
      <title>Cost Saving in AWS</title>
      <dc:creator>Sreekesh Iyer</dc:creator>
      <pubDate>Tue, 25 Apr 2023 11:30:00 +0000</pubDate>
      <link>https://forem.com/aws-builders/cost-saving-in-aws-4mcm</link>
      <guid>https://forem.com/aws-builders/cost-saving-in-aws-4mcm</guid>
      <description>&lt;p&gt;Cloud services can be funny, they obviously provide you with high-quality services for computing, storage, etc. but can also crank up your bills even before you realize it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhbhdqv2r6d41w54dhrjm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhbhdqv2r6d41w54dhrjm.png" alt="Image description" width="504" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AWS, like most cloud services, asks you for your credit card at sign-up. You're charged based on the time and usage of a service. &lt;/p&gt;

&lt;p&gt;Any piece of code/event that can potentially take a lot of computing power or storage can trigger a massive bill going ahead. To know what we're up against, here are some of the bill-scare stories you might wanna read -&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://chrisshort.net/the-aws-bill-heard-around-the-world/" rel="noopener noreferrer"&gt;Chris Short AWS Bill Shock&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.tomilkieway.com/72k-1/" rel="noopener noreferrer"&gt;Firebase + Cloud Run 72000$ Bill Scare&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I don't know about you but those numbers are scary, especially how quickly they go up. Bills can go up exponentially in a matter of hours. &lt;/p&gt;

&lt;h1&gt;
  
  
  How do you avoid Bill shocks in AWS?
&lt;/h1&gt;

&lt;p&gt;Handling large bills once they are in is a different ball game, but first priority should always be to prevent these bills in the first place. If you are someone like me who is just trying to experience the Cloud for the first time, learning how different services work, you should try not to have any bills at all. &lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Free Tier Limits
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm7xyqnvvlvo325u3a419.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm7xyqnvvlvo325u3a419.png" alt="Image description" width="800" height="293"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AWS has a pretty generous &lt;a href="https://aws.amazon.com/free/" rel="noopener noreferrer"&gt;Free Tier&lt;/a&gt; that lasts for 12 months after creating your account. &lt;/p&gt;

&lt;p&gt;A lot of services like AWS Lambda, Cognito, Cloudwatch, DynamoDB and SNS are free until you reach a threshold limit.&lt;/p&gt;

&lt;p&gt;Whereas, services like EC2, S3, RDS, etc. provide free services until the threshold limits for only 12 months, i.e. until you're a part of the Free Tier.&lt;/p&gt;

&lt;p&gt;On the other hand, there are also services like AWS SageMaker, Redshift and Lightsail that are available on a trial period for 2-3 months with their respective limitations. &lt;/p&gt;

&lt;h2&gt;
  
  
  Set Up Budgets
&lt;/h2&gt;

&lt;p&gt;One solid way to avoid massive bills in AWS or any other cloud service is to set up Budgets and Budget Actions that can alert you when things start to get out of hand.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbxtbr1wq8u0cy4v6znsi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbxtbr1wq8u0cy4v6znsi.png" alt="Image description" width="800" height="196"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Search for Billing in your AWS Console and open up the Billing Dashboard.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx4pbsmxlbxr36lsap7v7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx4pbsmxlbxr36lsap7v7.png" alt="Image description" width="800" height="385"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Billing Dashboard provides a complete overview of all monetary information about your AWS account.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a Budget in AWS
&lt;/h3&gt;

&lt;p&gt;Under Cost Management, click on &lt;em&gt;Budgets&lt;/em&gt; to open up the Budgets page.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkjlov3pt8lzesqzar5jc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkjlov3pt8lzesqzar5jc.png" alt="Image description" width="800" height="265"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now click on Create to start working on a new Budget.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxuf8tvmjc4t7on0glnl9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxuf8tvmjc4t7on0glnl9.png" alt="Image description" width="800" height="279"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Budget Threshold
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fglae1oawuemr9ihpt0wj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fglae1oawuemr9ihpt0wj.png" alt="Image description" width="796" height="524"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We'll go ahead with a Cost Budget and give a name to our new Budget. We'll choose &lt;em&gt;Monthly&lt;/em&gt; as the period for our Budget. Since I am a student and I don't really have any cloud services running, I'll just choose the threshold to be 1$. We can proceed to the next step now.&lt;/p&gt;

&lt;h3&gt;
  
  
  Budget Alerts
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi7cdwpxo6xuap9codvjt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi7cdwpxo6xuap9codvjt.png" alt="Image description" width="800" height="214"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is one of the key steps in creating a Budget, which is to set up an alert that notifies you via email when your bill is close to the budget threshold. Click on Add to create a new Alert.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5acpmt3gicz3g59z52k6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5acpmt3gicz3g59z52k6.png" alt="Image description" width="800" height="666"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, you can configure the percentage of the bill when there is an alert popping up and also a list of emails to notify. You can also use SNS and ChatBot as notifiers.&lt;/p&gt;

&lt;p&gt;So in my case, when the bill reaches 0.75$, I get an email.&lt;/p&gt;

&lt;h3&gt;
  
  
  Forecasted Alerts
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgz7afe2zq4lph1dhlcot.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgz7afe2zq4lph1dhlcot.png" alt="Image description" width="800" height="660"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In one of the stories, you saw how a startup company got a 72000$ bill in a matter of just a few hours. There are possibilities you end up being too late to see the alert. Here's where Forecasted Alerts come into play.&lt;/p&gt;

&lt;p&gt;Every time there is a tiny increment to your bill from 0.00$, a forecasted cost is generated based on your current usage to predict what your bill would be at the end of the month. You can use this metric to create an alert, based on which you can identify if any service is costing you more than usual. Just create a new alert and choose &lt;strong&gt;Forecasted&lt;/strong&gt; instead of &lt;strong&gt;Actual&lt;/strong&gt; in the Trigger parameter.&lt;/p&gt;

&lt;h3&gt;
  
  
  Budget Actions
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv6zx8915xmbtmg0gxfj9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv6zx8915xmbtmg0gxfj9.png" alt="Image description" width="800" height="341"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can have AWS automatically perform certain actions when a budget crosses a certain alert threshold by attaching an IAM Service Role to the alert under Actions.&lt;/p&gt;

&lt;p&gt;With this role, you can target a certain instance of a service or multiple instances and/or services based on your requirements. This would also require the particular role to have all the necessary permissions to perform the said actions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyskzrubrwdgtrxd9tx8z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyskzrubrwdgtrxd9tx8z.png" alt="Image description" width="444" height="98"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And that's all you need to do, to set up your budget.&lt;/p&gt;




&lt;h1&gt;
  
  
  Some Technical Tips to Save Costs
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Write Efficient Code&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Everything on the cloud is event-based and every time there is a new event, it potentially adds to your bill. This is why it's critical to avoid infinite loops in the cloud, where one service is triggered after the other and there is no end.&lt;/p&gt;

&lt;p&gt;Focus on how every time there is a new user, a new record, a new entry, how many extra operations it takes to run the same function. This gives you a good idea of the complexity of your code. Higher the complexity, the larger the bill in the long run.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Follow Proper Security Practices&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use environment variables whenever you're using secret keys or API keys in your code. Use strong passwords and MFA for logging into your AWS account. Make use of IAM Users, Policies and Permissions to access different services. Any vulnerability can be exploited and any misuse can cause serious problems.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Scale only when required&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Auto Scaling is a very useful feature of the Cloud, but it can be dangerous when not controlled. It is recommended that you only scale as much as required. There are maximum thresholds available for all services and they can significantly affect your bills.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Terminate/Delete Services that are not in use&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Just like saving electricity, it's recommended to turn off services that you're not using anymore. This is key especially if you are exploring the Cloud like me. Once done using a certain service, it's best practice to just shut it down to avoid usage costs.&lt;/p&gt;




&lt;h1&gt;
  
  
  BONUS
&lt;/h1&gt;

&lt;p&gt;Here's one last bonus feature I'd like to talk about in AWS that can help you reduce your costs.&lt;/p&gt;

&lt;h2&gt;
  
  
  AWS Cost Anomaly Detection
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffl3ul5ejx4afreohi6wg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffl3ul5ejx4afreohi6wg.png" alt="Image description" width="800" height="294"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AWS Cost Anomaly Detection, as a part of the AWS Cost Explorer API, uses advanced Machine Learning Techniques to identify anomalous costs that can help avoid your bills skyrocketing suddenly. You can set it up and receive alerts on SNS, Emails even periodically. This not only helps you avoid surprise bills but also analyzes the root cause of the hike.&lt;/p&gt;

&lt;p&gt;That's it from me in this thread, I hope it comes in handy in your Cloud journey. Thanks for reading :)&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>CICD in AWS using CodePipeline and EBS</title>
      <dc:creator>Sreekesh Iyer</dc:creator>
      <pubDate>Sun, 26 Mar 2023 11:50:33 +0000</pubDate>
      <link>https://forem.com/aws-builders/cicd-in-aws-using-codepipeline-and-ebs-1gai</link>
      <guid>https://forem.com/aws-builders/cicd-in-aws-using-codepipeline-and-ebs-1gai</guid>
      <description>&lt;p&gt;The Cloud has made a lot of things simpler for developers. In this thread, let's explore how easy it is to set up a CICD Pipeline in AWS using GitHub, AWS CodePipeline and Elastic Beanstalk.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is CI/CD?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj549rici9ase6cc050s0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj549rici9ase6cc050s0.png" alt="Image Representation of CICD" width="450" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;CI/CD is the combined practice of continuous integration (CI) with continuous delivery or continuous deployment (CD). The purpose of CI/CD is to allow developers and teams to deliver code changes more frequently and reliably.&lt;/p&gt;

&lt;p&gt;The reference to the word &lt;em&gt;pipeline&lt;/em&gt; is to explain how all of these processes are executed in a sequence, one after the other. The key to CI/CD is automation. The process can be more and more efficient if there is not a lot of manual involvement. It is crucial to have an efficient pipeline when you're dealing with large codebases in production since a lot of changes are made at different parts of an application. &lt;/p&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;An AWS Account (preferably Free Tier so that you are not charged for using cloud infrastructure)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tools Used
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;GitHub&lt;/li&gt;
&lt;li&gt;AWS CodePipeline&lt;/li&gt;
&lt;li&gt;AWS Elastic Beanstalk&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For this demonstration, we'll use a sample PHP application and deploy it to Elastic Beanstalk.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a Deployment Environment in Elastic Beanstalk
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F48e7vbzvn6t5oixn193r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F48e7vbzvn6t5oixn193r.png" alt="Beanstalk Dashboard" width="800" height="276"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open up &lt;a href="https://console.aws.amazon.com/elasticbeanstalk/home" rel="noopener noreferrer"&gt;Elastic Beanstalk&lt;/a&gt; in the AWS Console and click on &lt;strong&gt;Create Application&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foirmtw2g2pxzj2wntuen.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foirmtw2g2pxzj2wntuen.png" alt="Beanstalk App Configuration" width="800" height="769"&gt;&lt;/a&gt;&lt;br&gt;
Give a name to your application, choose PHP for the platform and &lt;em&gt;Sample Application&lt;/em&gt; for your code type. Now, click on &lt;strong&gt;Create Application&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Wait for a minute, while Beanstalk creates a sample environment for you to deploy your application. By default, it creates an EC2 instance, a security group, an Auto Scaling group, an Amazon S3 Bucket, Amazon CloudWatch alarms and a domain name for your application.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgffkqd4uasix3m5dh5ss.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgffkqd4uasix3m5dh5ss.png" alt="App Status after creation" width="800" height="224"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3zp347qdr0y0mwnryzrx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3zp347qdr0y0mwnryzrx.png" alt="Visiting the website" width="800" height="174"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can click on the URL to visit the application. You'll get a custom PHP welcome page by default.&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting your sample code
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4y5y9seurtszoezjdzlv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4y5y9seurtszoezjdzlv.png" alt="Screenshot of the GitHub repository" width="800" height="461"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A sample application is provided in &lt;a href="https://docs.aws.amazon.com/codepipeline/latest/userguide/tutorials-simple-s3.html#s3-create-s3-bucket" rel="noopener noreferrer"&gt;a tutorial&lt;/a&gt; for creating a simple pipeline in the AWS Documentation. You can either upload those files to your GitHub repository or simply fork my GitHub repository &lt;a href="https://github.com/sreekeshiyer/codepipeline-sample-app.git" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Since we are using GitHub as the source, we do not need the scripts folder, so you can delete it if you want. The scripts folder can come in handy if you are using Amazon S3 as the source for your application :)&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a CodePipeline
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fonvbr3zyf0u8h9su28cj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fonvbr3zyf0u8h9su28cj.png" alt="CodePipeline Dashboard" width="800" height="155"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open up the  &lt;a href="https://console.aws.amazon.com/codesuite/codepipeline/home" rel="noopener noreferrer"&gt;CodePipeline&lt;/a&gt;  Dashboard. In this step, we will create a simple pipeline where we specify our GitHub Repository for the source code and deploy the code to the Beanstalk app we just created.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Step 1&lt;/strong&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fct2iuwegmxvpth9rtfz2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fct2iuwegmxvpth9rtfz2.png" alt="Pipeline Setup 1" width="800" height="502"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enter a name for your pipeline and allow AWS to create a service role for this pipeline.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Step 2&lt;/strong&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabez8a10qf80tnsmnhoq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabez8a10qf80tnsmnhoq.png" alt="Pipeline Setup 2" width="592" height="410"&gt;&lt;/a&gt;&lt;br&gt;
Create a Connection to Connect your pipeline to GitHub.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn8t1gylbf61hhefdjc8l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn8t1gylbf61hhefdjc8l.png" alt="Authorizing AWS Connector for GitHUb" width="800" height="776"&gt;&lt;/a&gt;&lt;br&gt;
Ideally, you should only allow access to the specific GitHub Repository you're currently using. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd3xdn7sf5tehco1aeyib.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd3xdn7sf5tehco1aeyib.png" alt="Adding Source Information" width="757" height="914"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After the connection, choose the repository and the branch and go with the default CodePipeline for Output artifact format. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Step 3&lt;/strong&gt; 
&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvh27v6nl4mb9ctx9xgfu.png" alt="Deploy Stage" width="755" height="648"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Skip the build stage (since we do not have any build command) and fill in the Beanstalk application details in the Deployment Stage and lastly, review the data and click on &lt;strong&gt;Create Pipeline&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  View Pipeline Progress
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff1got2shi1eg8bhammlt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff1got2shi1eg8bhammlt.png" alt="Viewing Pipeline progress" width="800" height="396"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Wait for a few minutes while the Pipeline is executed and you can see that the process was completed. You can click on &lt;strong&gt;AWS Elastic Beanstalk&lt;/strong&gt; which takes you back to the Beanstalk application we created. Now, if you click on the URL, you can see that our application is successfully deployed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1vnxvkgqdjsm7y22bhvk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1vnxvkgqdjsm7y22bhvk.png" alt="Visiting the App" width="800" height="290"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Congratulations, we just deployed our application to AWS Elastic Beanstalk via a pipeline. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Make Changes to re-run the pipeline
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feb0582o7aa4t8shfcdke.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feb0582o7aa4t8shfcdke.png" alt="Viewing the changes on GitHub" width="800" height="278"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open up the pipeline repository on GitHub and make some changes in the &lt;em&gt;index.html&lt;/em&gt; file using the default GitHub text editor. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxgmr7cf4hcvyx76rztlp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxgmr7cf4hcvyx76rztlp.png" alt="Observing changes on CodePipeline" width="800" height="328"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After making the changes, quickly switch back to the pipeline and observe the changes. You can notice that the pipeline is being re-executed on your new commit. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F46lu58mr68lrcrqfiqmc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F46lu58mr68lrcrqfiqmc.png" alt="Visiting updated app" width="800" height="278"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the pipeline execution is complete and successful, go back to the website.&lt;br&gt;
As you can see, our changes were immediately reflected in our application and we didn't have to do anything extra for it. &lt;/p&gt;

&lt;p&gt;You can take this to the next level, where you deploy your Node.js or Python projects to Beanstalk, set up Tests, and run them on every new commit to your production branch. &lt;/p&gt;

&lt;h3&gt;
  
  
  Recommended Cleanup
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqygwm5ezan56ciogzu96.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqygwm5ezan56ciogzu96.png" alt="Deleting the Pipeline" width="551" height="186"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb72r50ndr1hc7db82rqr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb72r50ndr1hc7db82rqr.png" alt="Deleting the Beanstalk App" width="539" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;It is good practice to clean up/delete/terminate all services you have used on AWS (on any Cloud really) so that you are not charged in the future. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Firstly, delete your CodePipeline. Then, go to the Elastic Beanstalk Dashboard and delete your &lt;strong&gt;Application&lt;/strong&gt;. This will also delete and terminate all other services used by the application. &lt;/p&gt;

&lt;p&gt;This was a small demonstration of CICD in AWS. I hope you liked it. If you have used AWS CodePipeline before, do share your experience. &lt;/p&gt;

&lt;p&gt;Thank you for reading :)&lt;/p&gt;

</description>
      <category>aws</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
