Skip to content

OpenAI Chatbot UI on EKS with Jenkins and Terraform

Level:Advanced
Time:3-5 hours
Cost:high
Works locally:No
Cloud creds:Yes
Cleanup:Yes
Reviewed:2026-05-30
Validation:npm --prefix Chatbot-UI test

Chatbot UI with local hardening/test work and EKS deployment materials.

Outcome Passing pipeline run plus scan/deploy evidence
Tools used Next.js, Typescript, Openai Api, Docker, EKS, AWS, Terraform, Jenkins
Best fit Advanced - 3-5 hours
Student workstation Repository files CI/CD pipeline AWS account Validation proof
  • Install or review: Next.js, Typescript, Openai Api, Docker, EKS, AWS, Terraform, Jenkins.
  • Use your own cloud account credentials and keep them out of commits.
  • This project expects cloud resources, so verify budget alerts and cleanup first.
  • Open the safety guide before running commands that create infrastructure.
Cost and credential stance

Cost risk is high. Cloud target: AWS. Cloud credentials needed: Yes. Always use your own account, never commit secrets, and confirm cleanup before creating paid infrastructure.

Use this flow before you run commands:

  1. Read the cost and credential warning above.
  2. Review the validation, troubleshooting, cleanup, and portfolio proof sections below.
  3. Follow the original project guide preserved near the bottom of this page.
  4. Return to the validation and cleanup checks before you capture portfolio evidence.

Run the project validation command before and after meaningful changes:

Terminal window
npm --prefix Chatbot-UI test
  • Run npm --prefix Chatbot-UI test first so local tooling issues are visible early.
  • If a command fails, check tool versions, working directory, and required environment variables.
  • For cloud failures, confirm account identity, region, quotas, and least-privilege IAM.
  • For pipeline failures, check repository secrets, runner permissions, and pinned action versions.

Cleanup is available or expected for this lab. Use the cleanup or destroy steps in the guide below, then confirm that local clusters, containers, cloud resources, buckets, state files, and CI secrets are no longer active.

  • Validation command output: npm --prefix Chatbot-UI test
  • Screenshot or terminal proof: Passing pipeline run plus scan/deploy evidence
  • Notes explaining what changed, what failed, and how you fixed it
  • Cleanup evidence, especially for cloud or Kubernetes resources

The original README content is preserved here for lab-specific commands and context. Headings are intentionally demoted so the page outline stays focused on the standard lab flow.

External image reference text

In today’s digital world, user engagement is key to the success of any application. Implementing DevSecOps practices is essential for ensuring security, reliability, and efficient deployment processes. In this project, we aim to implement DevSecOps for deploying an OpenAI Chatbot UI. We will use Kubernetes (EKS) for container orchestration, Jenkins for Continuous Integration/Continuous Deployment (CI/CD), and Docker for containerization.

What is ChatBOT?

ChatBOT is an AI-powered conversational agent trained on extensive human conversation data. It utilizes natural language processing techniques to understand user queries and provide human-like responses. By simulating natural language interactions, ChatBOT enhances user engagement and provides personalized assistance to users.

Why ChatBOT?

1. Personalized Interactions: ChatBOT enables personalized interactions by understanding user queries and responding in a conversational manner, fostering engagement and satisfaction.

2. 24/7 Availability: Unlike human agents, ChatBOT is available 24/7, ensuring instant responses to user queries and delivering a seamless user experience round the clock.

3. Scalability: With ChatBOT deployed in our application, we can efficiently handle a large volume of user interactions, ensuring scalability as our user base expands.

How We’re Deploying ChatBOT?

1. Containerization with Docker: We’re containerizing the ChatBOT application using Docker, which provides lightweight, portable, and isolated environments for running applications. Docker enables consistent deployment across different environments, simplifying the deployment process and ensuring consistency.

2. Orchestration with Kubernetes (EKS): Kubernetes provides powerful orchestration capabilities for managing containerized applications at scale. We’re leveraging Amazon Elastic Kubernetes Service (EKS) to deploy and manage our Docker containers efficiently. EKS automates container deployment, scaling, and management, ensuring high availability and resilience.

3. CI/CD with Jenkins: Jenkins serves as our CI/CD tool for automating the deployment pipeline. We’ve configured Jenkins to continuously integrate code changes, run automated tests, and deploy the ChatBOT application to EKS. By automating the deployment process, Jenkins accelerates the delivery of updates and enhancements, improving efficiency and reliability.

4. DevSecOps Practices: Throughout the deployment pipeline, we’re integrating security practices into every stage to ensure the security of our ChatBOT application. This includes vulnerability scanning, code analysis, and security testing to identify and mitigate potential security threats early in the development lifecycle.

By implementing DevSecOps practices and leveraging modern technologies like Kubernetes, Docker, and Jenkins, we’re ensuring the secure, scalable, and efficient deployment of ChatBOT, enhancing user engagement and satisfaction.

🛡️ 2026 DevSecOps Enhancements (What You Will Learn)
Section titled “🛡️ 2026 DevSecOps Enhancements (What You Will Learn)”

This repository’s Jenkinsfile and Terraform architectures have been heavily refactored from legacy deployment scripts into a hardened DevSecOps pipeline:

  1. Semantic Branch Versioning & Ephemeral Workloads: We eradicated the dangerous latest Docker tag anti-pattern. Instead of repeatedly pushing over the latest tag (which breaks rollbacks and caching), the registry push and Kubernetes Deployments dynamically use ${BUILD_NUMBER} to ensure immutable, traceable rollouts.
  2. Standardized IaC Provisioning: Previously, this project relied on implicit, undocumented AWS CLI bash scripts to spin up the EKS cluster. During the Sprint 2 infrastructure pass, this was formalized into declarative Terraform code, providing an auditable and reproducible cluster state.

For the architecture diagram, secure configuration checklist, deploy commands, run validation, cost controls, and destroy procedure, see docs/portfolio-runbook.md.

Key artifacts:

Step:1 :- Create Jenkins Server.

  1. Clone the GitHub repository.

GITHUB REPO: Chatbot-UI

git clone https://github.com/devcloudninjas/DevOps-Projects/project-28-openai-chatbot-eks/Chatbot-UI
cd Jenkins-Server-TF

2. Before proceeding to next steps. Do the following things.

i. Create a DynamoDB table named “Lock-Files”.
ii. Create a Key-Pair and download the PEM file.
iii. Create a user and save the access keys.
iv. Create an S3 bucket.
v. Download Terraform and AWS CLI.

#Terraform Installation Script
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg - dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update
sudo apt install terraform -y
#AWSCLI Installation Script
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
sudo apt install unzip -y
unzip awscliv2.zip
sudo ./aws/install

3. Do some modifications to the backend.tf file such as changing the bucket name and DynamoDB table.

External image reference Source image

4. Configure AWS CLI: Run the below command, and add your access keys.

aws configure

5. You have to replace the Pem File name with one that is already created on AWS.

6. Initialize the backend by running the below command.

terraform init
External image reference Source image

7. Run the below command to get the blueprint of what kind of AWS services will be created.

terraform plan -var-file=variables.tfvars
External image reference Source image

8. Now, run the below command to create the infrastructure on AWS Cloud which will take 3 to 4 minutes maximum.

terraform apply -var-file=variables.tfvars --auto-approve
External image reference Source image

9. Upon success,this will create an ec2 server with name “Jenkins-server”.

External image reference Source image

10. Connect to it with SSH.

External image reference Source image

Step:2 :- Configure Jenkins server.

  1. Access jenkins on port 8080 of ec2 public ip.
External image reference Source image

2. Now, run the below command to get the administrator password and paste it on your Jenkins.

sudo cat /var/lib/jenkins/secrets/initialAdminPassword
External image reference Source image

\

3. Install suggested plugins.

External image reference Source image

4. Create user help us customize username and password of Jenkins.

External image reference Source image

5. Save and Continue all the rest.

External image reference Source image

6. Access SonarQube on port 9000 of Same Jenkins server.

Username: admin
Password: admin
External image reference Source image

7. Customize the password.

External image reference Source image

8. Navigate to Security → Users →Administrator.

External image reference Source image

9. Click on Tokens.

External image reference Source image

10. Create one and save it.

External image reference Source image

11. Now go to Configuration → Webhooks →Create

External image reference Source image

12. Then configure webhook and create.

Name: Jenkins
URL : http://<public_ip>:8080/sonarqube-webhook/
External image reference Source image

13. Now in Jenkins Navigate to Manage Jenkins → Plugins →Available Plugins and install the following.

1Eclipse Temurin Installer
2SonarQube Scanner
3NodeJs Plugin
4Docker
5Docker commons
6Docker pipeline
7Docker API
8Docker Build step
9Owasp Dependency Check
10Kubernetes
11Kubernetes CLI
12Kubernetes Client API
13Kubernetes Pipeline DevOps steps
10AWS Credentials
11Pipeline: AWS Steps
External image reference Source image

14. Restart Jenkins after they got installed.

External image reference Source image

14. Go to Manage Jenkins → Tools → Install JDK(17) and NodeJs(19)→ Click on Apply and Save.

External image reference Source image
External image reference Source image

15. Similarly install DP-check, Sonar-Scanner and Docker.

External image reference Source image
External image reference Source image
External image reference Source image

16. Go to Jenkins Dashboard → Manage Jenkins → Credentials. Add

Sonar-token as secret text.

External image reference Source image

Docker credentials.

External image reference Source image

GitHub Credentials.

External image reference Source image

AWS access keys as AWS Credentials.

External image reference Source image

17. Manage Jenkins → Tools → SonarQube Scanner. Then add sonar-server and created sonar-token.

External image reference Source image

Step :3 :- Create Jenkins Pipeline

  1. Up to this Let’s create a pipeline and see if anything gone wrong.
    Click on “New Item” and give it a name selecting pipeline and then ok.
External image reference Source image

2. Under Pipeline section Provide

Definition: Pipeline script from SCM
SCM : Git
Repo URL : Your Github Repo
Credentials: Created GitHub Credentials
Branch: Main
Path: Your Jenkinsfile path in GitHub repo.
External image reference Source image
External image reference Source image

3. Click on “Build”.

Upon successful execution you can see all stages as green.

External image reference Source image

Sonar- Console.

External image reference Source image

Dependency Check:

External image reference Source image

Trivy File scan:

External image reference Source image

Trivy Image Scan:

External image reference Source image

Docker Hub:

External image reference Source image

4. Now access the application on port 3000 of Jenkins public ip.
Note: Make sure you allowed port 3000 in Security Group of Jenkins Server.

External image reference Source image

5. Click on openai.com(Blue in color)
This will take you ChatGPT login page enter email and password.
In API Keys Create Click on new secret key.

External image reference Source image

Give a name and copy it.

External image reference Source image

6. Come back to chatbot UI that we deployed and bottom of the page you will see OpenAI API key and give the Generated key and click on save (RIGHT MARK).

External image reference Source image

UI look like:

External image reference Source image

7. Now, You can ask questions and test it.

External image reference Source image

Step:4 :- Create EKS Cluster withy Jenkins

  1. Click on New item give it a name by choosing pipeline and then click “OK”.
External image reference Source image

2. Under Pipeline section provide:

Definition: Pipeline script from SCM
SCM : Git
Repo URL : Your Github Repo
Credentials: Created GitHub Credentials
Branch: Main
Path: Your EKS Cluster Jenkinsfile path in GitHub repo.
External image reference Source image
External image reference Source image

3. Click on Build and on successful execution Your Jenkins UI resembles:

External image reference Source image

This will create a cluster in AWS:

External image reference Source image

4. Now In the Jenkins server. Give this command to add context.

aws eks update-kubeconfig --name <clustername> --region <region>

5. It will Generate an Kubernetes configuration file.
Navigate to the path of config file and copy it.

cd .kube
cat config

6. Save it in your local file explorer, at your desired location with any name as text file.

External image reference Source image

7. Now in Jenkins Console add this file in Credentials section with id k8s as secret file.

External image reference Source image

Step:5 :- Deployment on EKS

1. Now add this deployment stage in Jenkins file.

stage('Deploy to kubernetes'){
steps{
withAWS(credentials: 'aws-key', region: 'us-east-1'){
script{
withKubeConfig(caCertificate: '', clusterName: '', contextName: '', credentialsId: 'k8s', namespace: '', restrictKubeConfigAccess: false, serverUrl: '') {
sh 'kubectl apply -f k8s/chatbot-ui.yaml'
}
}
}
}
}

2. Now rerun the Jenkins Pipeline again.

Upon Success:

External image reference Source image

This create all the resources in the Cluster:

kubectl get all
External image reference Source image

This will create an Classic Load Balancer on AWS Console:

External image reference Source image

Copy the DNS Name and Paste it on your browser and use it:

Note: Do the same process and add key to get output.

External image reference Source image
External image reference Source image

The Complete Jenkins file:

pipeline{
agent any
tools{
jdk 'jdk17'
nodejs 'node19'
}
environment {
SCANNER_HOME=tool 'sonar-scanner'
}
stages {
stage('Checkout from Git'){
steps{
git branch: 'master', url: 'https://github.com/devcloudninjas/project-28-openai-chatbot-eks/Chatbot-UI.git'
}
}
stage('Install Dependencies') {
steps {
sh "npm install"
}
}
stage("Sonarqube Analysis "){
steps{
withSonarQubeEnv('sonar-server') {
sh ''' $SCANNER_HOME/bin/sonar-scanner -Dsonar.projectName=Chatbot \
-Dsonar.projectKey=Chatbot '''
}
}
}
stage("quality gate"){
steps {
script {
waitForQualityGate abortPipeline: false, credentialsId: 'Sonar-token'
}
}
}
stage('OWASP FS SCAN') {
steps {
dependencyCheck additionalArguments: '--scan ./ --disableYarnAudit --disableNodeAudit', odcInstallation: 'DP-Check'
dependencyCheckPublisher pattern: '**/dependency-check-report.xml'
}
}
stage('TRIVY FS SCAN') {
steps {
sh "trivy fs . > trivyfs.json"
}
}
stage("Docker Build & Push"){
steps{
script{
withDockerRegistry(credentialsId: 'docker', toolName: 'docker'){
sh "docker build -t chatbot ."
sh "docker tag chatbot ProDevOpsGuyTech/chatbot:latest "
sh "docker push ProDevOpsGuyTech/chatbot:latest "
}
}
}
}
stage("TRIVY"){
steps{
sh "trivy image ProDevOpsGuyTech/chatbot:latest > trivy.json"
}
}
stage ("Remove container") {
steps{
sh "docker stop chatbot | true"
sh "docker rm chatbot | true"
}
}
stage('Deploy to container'){
steps{
sh 'docker run -d --name chatbot -p 3000:3000 sreedhar8897/chatbot:latest'
}
}
stage('Deploy to kubernetes'){
steps{
withAWS(credentials: 'aws-key', region: 'us-east-1'){
script{
withKubeConfig(caCertificate: '', clusterName: '', contextName: '', credentialsId: 'k8s', namespace: '', restrictKubeConfigAccess: false, serverUrl: '') {
sh 'kubectl apply -f k8s/chatbot-ui.yaml'
}
}
}
}
}
}
}

Step: 6 :- Clean Up

  1. This is so simple Firstly Delete the EKS Cluster By selecting destroy as the build option.
External image reference Source image

2. Then destroy Jenkins server by running this on Local:

terraform destroy -auto-approve -var-file=variables.tfvars

External image reference Source image

[!Note] Join Our Telegram Community // Follow me for more DevOps & Cloud content.

Use the guide first.

The full learning flow stays on this page. Open GitHub only when a step asks you to inspect code, fork the lab, or download source assets.