GenAI Deployment Guide: Dockerizing LLM Apps with AWS ECR & Parameter Store

Analytics Vidhya · Intermediate ·☁️ DevOps & Cloud ·4mo ago

Key Takeaways

This video demonstrates how to deploy a GenAI application using Docker, AWS ECR, and Parameter Store, showcasing a secure and professional deployment process for a Python-based application.

Full Transcript

All right. Now that we know how the application works and we have looked at the front end and the back end, it's now time to deploy the application. To deploy the app, we are going to first package it into a Docker container. Now there are two things that we have to look at. One is thevb file. As we can see the AWS credentials consist of the account ID, the access key ID and the secret access. This is the credentials for my particular user in AWS. This application actually runs in appunner where we would be creating a separate role and giving it access to all these services. So it's a bad practice if I'm going to supply these enviables inside my application which is actually created just for me. And one of the good practice is to actually always use IM roles and policies. And these are the application variables that I have to provide to my application. The default region, the bedrock ID, the OpenAI API key and the OpenAI model. All right. So what I do is I have to now create this as an end toend package. To create the package we are using a docker file. In the docker file we are working with one of the python 3.11 slim which is the smaller base image for python 3.11. We create a working directory at / app. We copy the requirements.txt txt all the packages and then we finally install all the package. Then in terms of code, we just copy the app.py and agent.py file and we then simply run our function using python app.py. So this docker file can then help us to create the docker container and then we'll push it to the docker container registry. So before we do let's quickly have a look at the architecture. So as we can see the docker file would be helping us to create the docker container. Then we'll finally push the docker container up here and the application would then be deployed in appunner. Apprunner would then pull the docker container and run the app. But before that before running it it will also go to parameter store to get all the environment variables that it needs. It will also inject these environment variables. So these would be available to the application. Now to be able to call all these services currently it was using the application in my local was using my AWS credentials but now we would be attaching an IM role to the appunner. What this role does is gives it permission to connect to knowledge basis and also to parameter store to fetch environment variables. It connects to knowledge basis to obviously retrieve all the documents from a given query and parameter store to get the open AI API key so that it can finally use that API key to call open AAI. All right. So to finally start with the deployment part which is the left side of the application um architecture diagram. Let's start with creating our ECR container. So we'll go to the dashboard. We'll mention ECR in search. This takes us to the ECR dashboard. Click on create and we can give it a nice name Chennai bot and that's it. Click on create. Finally, it's created. We can see the push commands. Now, first we have to log into this Docker registry to be able to push things. We'll go back to the code. Now we'll just make sure that source envir all the local my user credentials are loaded so that it doesn't interfere with any other AWS credentials if they are all on this machine. I'm logging into this registry. The login has succeeded. Finally I'll build the image for genib bot using the build command. One thing that I would mention is that I would always append it with platform Linux x64. This is because my machine a MacBook over here it has ARM based platform and just to not interfere with that the type of of image this has to be is going to be x86 and that's why it's a good practice to simply mention that the platform should be Linux x86 and so that the docker container is not created in as an ARM based image. All right. So I just write platform. Okay. It worked nicely. The build is done. I can finally tag it. I can then All right. Now the push is done. This container is now pushed to the AWS ECR. We can go to the dashboard. We can refresh it and we can see that the image is pushed. Now that we have ECR in place, let's also go and set up parameter store. So on the search we will mention parameter store. Here we'll click on create parameter. We'll name our parameter OpenAI API key. We'll mention it as secure string. So it would be encrypted and stored in AWS. And in the value, we would be putting the ENV value that we have just to make sure we don't have any spaces anywhere. All right. So with this this parameter is created. OpenAI API key. It's nice. Now that we had the parameter also stored in OpenAI API key, the value is stored in parameter store. We can finally use Approna to deploy the application.

Original Description

Description In this seventh video of our series, we move from development to deployment. We walk through the essential steps of containerizing a Python-based GenAI application and setting up the AWS infrastructure needed for a secure, professional launch. Key highlights in this video: Security Best Practices: Why you should never bake personal AWS credentials into your Docker images and how to use IAM Roles instead. Writing the Dockerfile: Creating a lightweight container using the python:3.11-slim base image for faster deployment. The Mac/ARM Compatibility Fix: A critical tip on using --platform linux/amd64 to ensure Docker images built on MacBooks (M1/M2/M3) work seamlessly on AWS cloud servers. AWS ECR (Elastic Container Registry): Step-by-step guide to creating a repository, authenticating the Docker CLI, and pushing your image. AWS Parameter Store: How to securely store sensitive data like OpenAI API keys as SecureStrings to keep them encrypted and out of your source code. Cloud Architecture Review: A look at how AWS AppRunner pulls the image and fetches secrets at runtime. This video is a must-watch for MLOps engineers and developers looking to deploy AI applications using enterprise-grade security and standards. 🛠 Tech Stack: Docker (Containerization) AWS ECR (Image Registry) AWS Parameter Store (Secret Management) IAM (Cloud Security) Python 3.11
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Analytics Vidhya · Analytics Vidhya · 0 of 60

← Previous Next →
1 The DataHour: Data Science in Retail
The DataHour: Data Science in Retail
Analytics Vidhya
2 The DataHour: Anomaly detection using NLP and Predictive Modeling
The DataHour: Anomaly detection using NLP and Predictive Modeling
Analytics Vidhya
3 The DataHour: Energy Data Science Project from Scratch
The DataHour: Energy Data Science Project from Scratch
Analytics Vidhya
4 The DataHour: Explainable AI Need and Implementation
The DataHour: Explainable AI Need and Implementation
Analytics Vidhya
5 The DataHour: Google Cloud AI/ML
The DataHour: Google Cloud AI/ML
Analytics Vidhya
6 Prediction to Production in Machine Learning #machinelearning #prediction
Prediction to Production in Machine Learning #machinelearning #prediction
Analytics Vidhya
7 Practical Applications of Data science in Ecommerce
Practical Applications of Data science in Ecommerce
Analytics Vidhya
8 How to tackle Overfitting?#machinelearning #overfitting
How to tackle Overfitting?#machinelearning #overfitting
Analytics Vidhya
9 Building Data Pipelines on GCP #googlecloud #datapipelines #data
Building Data Pipelines on GCP #googlecloud #datapipelines #data
Analytics Vidhya
10 Hands-on with A/B Testing #abtesting #datascience
Hands-on with A/B Testing #abtesting #datascience
Analytics Vidhya
11 Efficient Implementations of Transformers #transformers #cnn  #machinelearning
Efficient Implementations of Transformers #transformers #cnn #machinelearning
Analytics Vidhya
12 Modern Deep Learning Architecture #deeplearning  #architecture #deeplearningtutorial
Modern Deep Learning Architecture #deeplearning #architecture #deeplearningtutorial
Analytics Vidhya
13 Key steps for Designing Artificial Neural Network (ANN) for Image classification #machinelearning
Key steps for Designing Artificial Neural Network (ANN) for Image classification #machinelearning
Analytics Vidhya
14 5 things you should know about Azure SQL #azure #sql #datahour #datascience
5 things you should know about Azure SQL #azure #sql #datahour #datascience
Analytics Vidhya
15 AI & ML in the Automotive Industry #machinelearning #ai
AI & ML in the Automotive Industry #machinelearning #ai
Analytics Vidhya
16 Building Machine Learning Models in BigQuery
Building Machine Learning Models in BigQuery
Analytics Vidhya
17 NLP aspects in Telecommunication Industry
NLP aspects in Telecommunication Industry
Analytics Vidhya
18 Practical Time Series Analysis
Practical Time Series Analysis
Analytics Vidhya
19 Fundamentals of Quantum Computing
Fundamentals of Quantum Computing
Analytics Vidhya
20 A DAY IN THE LIFE of a Data Scientist (From waking up to working on algorithms)
A DAY IN THE LIFE of a Data Scientist (From waking up to working on algorithms)
Analytics Vidhya
21 Classification Machine Learning Model from Scratch
Classification Machine Learning Model from Scratch
Analytics Vidhya
22 Knowledge Graph Solutions using Neo4j
Knowledge Graph Solutions using Neo4j
Analytics Vidhya
23 Model Guesstimation (MLOps)
Model Guesstimation (MLOps)
Analytics Vidhya
24 ETL Pipelines in Google Cloud Platform
ETL Pipelines in Google Cloud Platform
Analytics Vidhya
25 Key steps for Designing Convolutional Neural Network(CNN) for Image Classification
Key steps for Designing Convolutional Neural Network(CNN) for Image Classification
Analytics Vidhya
26 Getting Started with AWS EC2 #amazon #aws
Getting Started with AWS EC2 #amazon #aws
Analytics Vidhya
27 How to Use Azure NLP and Graph Databases for Intelligent Knowledge Mining
How to Use Azure NLP and Graph Databases for Intelligent Knowledge Mining
Analytics Vidhya
28 Certified AI & ML BlackBelt Plus Program #shorts
Certified AI & ML BlackBelt Plus Program #shorts
Analytics Vidhya
29 Visualizing Data using Python #machinelearning #visualization #python
Visualizing Data using Python #machinelearning #visualization #python
Analytics Vidhya
30 DCNN for Machine RUL Prediction using Time-series Data #timeseries #machinelearning #datascience
DCNN for Machine RUL Prediction using Time-series Data #timeseries #machinelearning #datascience
Analytics Vidhya
31 M in ML stands for Math & Magic
M in ML stands for Math & Magic
Analytics Vidhya
32 An Unsupervised ML approach using Clustering
An Unsupervised ML approach using Clustering
Analytics Vidhya
33 Customizing Large Language Models GPT3 for Real-life Use Cases #gpt3 #datascience
Customizing Large Language Models GPT3 for Real-life Use Cases #gpt3 #datascience
Analytics Vidhya
34 Model Parameters vs Hyperparameters - Techniques in ML Engineering #machinelearning
Model Parameters vs Hyperparameters - Techniques in ML Engineering #machinelearning
Analytics Vidhya
35 Practical MLOps #mlops #datascience
Practical MLOps #mlops #datascience
Analytics Vidhya
36 Data Engineering with Databricks #dataengineering #databricks
Data Engineering with Databricks #dataengineering #databricks
Analytics Vidhya
37 Multi-Objective Optimisation
Multi-Objective Optimisation
Analytics Vidhya
38 When Airflow Meets Kubernetes
When Airflow Meets Kubernetes
Analytics Vidhya
39 AI in Banking
AI in Banking
Analytics Vidhya
40 Learn Convolutional Neural Network for Image Recognition
Learn Convolutional Neural Network for Image Recognition
Analytics Vidhya
41 Extracting Value from Data
Extracting Value from Data
Analytics Vidhya
42 How to measure Marketing Channel Effectiveness
How to measure Marketing Channel Effectiveness
Analytics Vidhya
43 Transforming Lives | Data Science Immersive Bootcamp
Transforming Lives | Data Science Immersive Bootcamp
Analytics Vidhya
44 Stock Market Analysis - AI driven approach
Stock Market Analysis - AI driven approach
Analytics Vidhya
45 Become a Data Engineering Professional in 2022 | Future Trends + Skills Required
Become a Data Engineering Professional in 2022 | Future Trends + Skills Required
Analytics Vidhya
46 Ensemble Techniques in Machine Learning #machinelearning #ensemble #datascience
Ensemble Techniques in Machine Learning #machinelearning #ensemble #datascience
Analytics Vidhya
47 The Power of Visualization | Tableau Full Course | Analytics Vidhya
The Power of Visualization | Tableau Full Course | Analytics Vidhya
Analytics Vidhya
48 Demand for Data Engineers is on the Rise | Data Engineer | Analytics Vidhya
Demand for Data Engineers is on the Rise | Data Engineer | Analytics Vidhya
Analytics Vidhya
49 Data Visualization in Data Science | DataHour | Analytics Vidhya
Data Visualization in Data Science | DataHour | Analytics Vidhya
Analytics Vidhya
50 Role of Optimization in Machine Learning & Deep Learning | DataHour | Analytics Vidhya
Role of Optimization in Machine Learning & Deep Learning | DataHour | Analytics Vidhya
Analytics Vidhya
51 Solving any Machine Learning Problem | Approach and Steps Involved
Solving any Machine Learning Problem | Approach and Steps Involved
Analytics Vidhya
52 Topic Modeling Explained with Implementation | Using LDA in Python | DataHour by Arpendu Ganguly
Topic Modeling Explained with Implementation | Using LDA in Python | DataHour by Arpendu Ganguly
Analytics Vidhya
53 Data Engineering in E-Commerce | The Best Case Study
Data Engineering in E-Commerce | The Best Case Study
Analytics Vidhya
54 Introduction to Classification using Azure Machine Learning | DataHour | Analytics Vidhya
Introduction to Classification using Azure Machine Learning | DataHour | Analytics Vidhya
Analytics Vidhya
55 Introduction to Federated Learning | DataHour | Analytics Vidhya
Introduction to Federated Learning | DataHour | Analytics Vidhya
Analytics Vidhya
56 Diffusion Models for Generative Arts | DataHour | Analytics Vidhya
Diffusion Models for Generative Arts | DataHour | Analytics Vidhya
Analytics Vidhya
57 Master Google Analytics in 1 Hour | DataHour | Analytics Vidhya
Master Google Analytics in 1 Hour | DataHour | Analytics Vidhya
Analytics Vidhya
58 Learn Hypothesis Testing | DataHour | Analytics Vidhya
Learn Hypothesis Testing | DataHour | Analytics Vidhya
Analytics Vidhya
59 A Practical Approach to Kaggle Competition | DataHour | Analytics Vidhya
A Practical Approach to Kaggle Competition | DataHour | Analytics Vidhya
Analytics Vidhya
60 Making AI work for Business | DataHour | Analytics Vidhya
Making AI work for Business | DataHour | Analytics Vidhya
Analytics Vidhya

This video teaches how to deploy a GenAI application using Docker, AWS ECR, and Parameter Store, covering security best practices and AWS infrastructure setup.

Key Takeaways
  1. Create a Dockerfile for the GenAI application
  2. Build and push the Docker image to AWS ECR
  3. Set up Parameter Store for secure storage of environment variables
  4. Configure AppRunner for deployment
  5. Attach an IM role to AppRunner for permission management
💡 Using IM roles and Parameter Store ensures secure and scalable deployment of GenAI applications on AWS

Related Reads

📰
Stop Using 6 Chrome Tabs for Code Reviews—Do It in Your Terminal
Streamline code reviews by using terminal-based tools instead of multiple Chrome tabs
Dev.to · Learn AI Resource
📰
Roadmap for infrastructure/backend development in the .NET ecosystem?
Learn to build infrastructure and backend development projects in the .NET ecosystem with a focus on DevOps tools and technologies
Reddit r/devops
📰
Your NOC Video Wall Is Just a Linux Box Now (Architecture + the 5-Year Math)
Learn how to repurpose a Linux box as a NOC video wall and calculate the 5-year cost savings
Dev.to · Pavel Suchkov
📰
AWS CodePipeline Tutorial: Deploy to EC2 with CodeCommit, CodeBuild & CodeDeploy
Learn to deploy to EC2 using AWS CodePipeline with CodeCommit, CodeBuild, and CodeDeploy in this step-by-step tutorial
Dev.to · Guna SantoshDeep Srivastava
Up next
AWS, Azure, GCP: The One Thing Every Business Gets Wrong
AI Daily
Watch →