The DevOps AI Assistant is a comprehensive tool that automates various aspects of DevOps processes, from generating Dockerfiles (using Finch) to creating infrastructure as code for both ECS and EKS using Terraform and CloudFormation.
This AI-powered assistant streamlines development and deployment workflows by leveraging advanced code generation techniques. It supports multiple container orchestration platforms and aims to minimize manual coding, reduce errors, and enhance the overall efficiency of DevOps practices.
The DevOps AI Assistant follows a modular architecture with AI-powered code generation at its core:
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ User Input │───▶│ Streamlit UI │───▶│ Project Analysis│
│ (Git Repo/Code) │ │ │ │ │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │
▼ ▼
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Generated │◀───│ AWS Bedrock │◀───│ Code Generation │
│ Artifacts │ │ AI Models │ │ Templates │
└─────────────────┘ └──────────────────┘ └─────────────────┘
- Input Processing: User provides Git repository URL or code requirements
- Project Analysis: AI identifies project type, language, and framework
- Template Selection: System selects appropriate generation templates
- AI Code Generation: AWS Bedrock models generate infrastructure code
- Validation: Generated code is validated for syntax and best practices
- Output Display: Results shown in Streamlit UI with syntax highlighting
- Optional Execution: Generated code can be executed (Docker build, Terraform plan)
- Dockerfiles: Optimized container definitions
- Terraform: ECS/EKS infrastructure as code
- CloudFormation: AWS infrastructure templates
- BuildSpec: CI/CD pipeline configurations
- Kubernetes Manifests: Container orchestration definitions
Before using the DevOps AI Assistant, ensure you have:
- Python 3.7+: Runtime environment
- Finch: Container building and testing
- AWS CLI: AWS service interactions
- Git: Repository cloning (optional)
- AWS Account: Active AWS account with appropriate permissions
- AWS CLI Configured: Run
aws configurewith your credentials - Required AWS Permissions:
- Amazon Bedrock access (for AI models)
- ECR access (for container registry)
- ECS/EKS permissions (for infrastructure deployment)
- CloudFormation/Terraform execution permissions
- Internet Connection: Required for AI model access and package installation
- Sufficient Disk Space: For Docker images and generated artifacts
- Port 8501: Available for Streamlit application (default)
git clone <repository-url>
cd automated-devops-ai-toolkit# Create virtual environment
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate # Linux/Mac
# OR
venv\Scripts\activate # Windowspip3 install -r requirements.txt# Configure AWS CLI (if not already done)
aws configure
# Verify AWS access
aws sts get-caller-identitystreamlit run app.py- Open browser to:
http://localhost:8501 - Navigate using sidebar menu
- Start with Dockerfile generation for testing
-
Dockerfile Generation Test:
# Use sample repository Repository URL: https://github.com/<sample-app-code-repository>
- Expected: Generated Dockerfile for Java Spring application or Golang Applicaion etc
- Verify: Dockerfile contains appropriate Java or Golang base image and build steps for example
-
ECS Terraform Test:
- Input: Generated Dockerfile from step 1
- Select: Fargate deployment type
- Expected: Complete Terraform configuration with VPC, ECS cluster, and task definition
-
EKS CloudFormation Test:
- Input: Same Dockerfile
- Select: EKS Fargate deployment
- Expected: CloudFormation template with EKS cluster and Kubernetes manifests
# Test generated Terraform
cd iac/
terraform init
terraform validate
terraform plan
# Test generated CloudFormation
aws cloudformation validate-template --template-body file://template.yaml
# Test generated Docker image
finch build -t test-app . # solution used Finch
finch run --rm test-app. # solution used Finch# Stop Streamlit application
Ctrl+C
# Deactivate virtual environment
deactivate
# Remove virtual environment (optional)
rm -rf venvcd iac/
terraform destroy# List stacks
aws cloudformation list-stacks
# Delete specific stack
aws cloudformation delete-stack --stack-name <stack-name># Remove generated images
docker rmi $(docker images -q)
# Clean up Docker system
docker system prune -a# List repositories
aws ecr describe-repositories
# Delete repository
aws ecr delete-repository --repository-name <repo-name> --force# Remove generated files
rm -rf iac/
rm -rf temp_repo/
rm -f Dockerfileapp/: Main application directorycore/: Core functionality modulesbedrock_definition.py: AWS Bedrock model configurationbuild_docker_image.py: Docker image building logiccustom_logging.py: Logging configurationidentify_project.py: Project identification logicdockerfile_validator.py: Dockerfile validation utilities
generators/: Code generation modulesbuildspec/: BuildSpec generationcloudformation/: CloudFormation template generation (ECS & EKS)docker/: Dockerfile generationterraform/: Terraform configuration generation (ECS & EKS)
pages/: Streamlit pages for different functionalities1_dockerfile_generation.py: Docker container generation2_terraform_generation.py: ECS Terraform infrastructure3_cloudformation_generation.py: ECS CloudFormation infrastructure4_buildspec_generation.py: CI/CD pipeline configuration5_eks_terraform_generation.py: EKS Terraform infrastructure6_eks_cloudformation_generation.py: EKS CloudFormation infrastructure
app.py: Main Streamlit application entry point
We would like to thank the following contributors for their valuable input and work on this project (sorted alphabetically):
• Aditya Ambati
• Anand Krishna Varanasi
• JAGDISH KOMAKULA
• Sarat Chandra Pothula
• T.V.R.L.Phani Kumar Dadi
• Varun Sharma
Prerequisites:
- Python 3.7+
- Docker
- AWS CLI configured with appropriate permissions
Steps:
- Clone the repository:
git clone <repository-url> cd devops-ai-assistant - Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate` - Install dependencies:
pip3 install -r requirements.txt
-
Run the Streamlit application:
streamlit run app.py -
Open your web browser and navigate to the URL displayed in the terminal.
-
Use the sidebar to navigate between different functionalities:
- Dockerfile Generation: Create optimized Docker containers
- ECS Terraform Generation: AWS ECS infrastructure with Terraform
- ECS CloudFormation Generation: AWS ECS infrastructure with CloudFormation
- BuildSpec Generation: CI/CD pipeline configuration
- EKS Terraform Generation: AWS EKS infrastructure with Terraform
- EKS CloudFormation Generation: AWS EKS infrastructure with CloudFormation
- AWS Credentials: Ensure your AWS CLI is configured with the necessary permissions for Bedrock, ECR, and other AWS services used by the application.
- Model Configuration: Adjust the Bedrock model settings in
app/core/bedrock_definition.pyif needed.
-
Dockerfile Generation:
- Input: Git repository URL
- Output: Generated Dockerfile and built Docker image
-
ECS Infrastructure Generation:
- Terraform for ECS: Fargate and EC2 Auto Scaling configurations
- CloudFormation for ECS: Complete ECS infrastructure templates
-
EKS Infrastructure Generation:
- Terraform for EKS: Fargate and EC2 Node Group configurations
- CloudFormation for EKS: Complete EKS infrastructure templates
-
BuildSpec Generation:
- Input: ECR repository name and URI
- Output: BuildSpec YAML file for AWS CodeBuild
- If you encounter issues with AWS services, ensure your AWS CLI is properly configured and you have the necessary permissions.
- For Docker-related issues, make sure Docker/Finch is running and you have the required permissions to build and run containers.
- Check the application logs for detailed error messages and stack traces.
The DevOps AI Assistant processes user inputs through a series of AI-powered generation steps:
- User provides input (e.g., Git repository URL, infrastructure requirements)
- Application identifies project type and structure
- AI model generates appropriate code (Dockerfile, Terraform, CloudFormation, or BuildSpec)
- Generated code is validated and optionally executed
- Results are displayed to the user with error handling and feedback
[User Input] -> [Project Identification] -> [AI Code Generation] -> [Validation] -> [Output Display/Execution]
- Fargate: Serverless container execution
- EC2 Auto Scaling: Managed EC2 instances with auto scaling
- Fargate: Serverless Kubernetes pods
- EC2 Node Groups: Managed EC2 instances for Kubernetes nodes
Key components in the data flow:
- Bedrock AI model: Handles code generation based on prompts and templates
- Dockerfile Validator: Ensures generated Dockerfiles are valid and properly formatted
- Streamlit UI: Manages user interactions and displays results
- Finch: Builds and tests generated Dockerfiles
- AWS services: Interact with ECR, ECS, EKS, and other AWS resources as needed
The solution architecture sample code is provided without any guarantees, and you're not recommended to use it for production-grade workloads. The intention is to provide content to build and learn. Be sure of reading the licensing terms.
MIT-0