Skip to content

A Python tool that integrates OpenAI's GPT model with AWS CLI, enabling users to execute AWS commands using natural language prompts.

License

Notifications You must be signed in to change notification settings

gianfj/natural-cli-for-aws

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AWS CLI via OpenAI

Overview

This project integrates OpenAI’s GPT capabilities with AWS CLI, enabling users to interact with AWS services using natural language prompts. The tool translates user-friendly prompts into actionable AWS CLI commands and executes them seamlessly.

Disclaimer

Use this tool at your own risk. Automating AWS CLI commands through natural language processing can lead to unintended or unpredictable results. We are not responsible for any data loss, resource misconfiguration, or unexpected costs incurred while using this tool.

Features

  • Natural Language Processing: Leverage OpenAI’s GPT model to interpret user commands.
  • AWS CLI Integration: Automatically execute AWS CLI commands based on generated outputs.
  • Error Handling: Includes checks to ensure environment variables and dependencies are properly configured.
  • Blocklist: Prevent disruptive commands to be run automatically

Prerequisites

Before running the script, ensure the following dependencies and environment variables are set up:

Dependencies

  1. Python 3.8 or newer
  2. openai Python package
  3. AWS CLI configured with valid credentials
  4. pyenv for managing Python versions (optional but recommended)

Environment Variables

  • OPENAI_API_KEY: Your OpenAI API key.
  • AWS credentials: Ensure ~/.aws/credentials is configured correctly.

Installation

  1. Clone the repository:

    git clone https://github.com/<your-username>/<repo-name>.git
    cd <repo-name>
  2. Set up a virtual environment (optional but recommended):

    python3 -m venv venv
    source venv/bin/activate
  3. Install required dependencies:

    pip install -r requirements.txt
  4. Set the necessary environment variables:

    export OPENAI_API_KEY="your-openai-api-key"

Usage

  1. Run the script:

    python aaws.py
  2. Enter natural language prompts to interact with AWS services. For example:

    Create an S3 bucket named "my-bucket"
    
  3. The tool will:

    • Interpret your prompt using OpenAI’s GPT model.
    • Translate it into an AWS CLI command.
    • Execute the command and display the results.

Example

Input:

List all EC2 instances in the us-east-1 region.

Output:

aws ec2 describe-instances --region us-east-1

Result: Displays the list of EC2 instances.

Troubleshooting

  1. Missing API Key: Ensure the OPENAI_API_KEY environment variable is set correctly.

  2. AWS CLI Errors: Verify AWS credentials and CLI configuration using:

    aws configure
  3. Dependency Issues: Reinstall dependencies using:

    pip install -r requirements.txt

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch:
    git checkout -b feature-branch-name
  3. Make your changes and test them thoroughly.
  4. Submit a pull request with a detailed description of your changes.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

  • OpenAI for the GPT model
  • AWS for the CLI tools

About

A Python tool that integrates OpenAI's GPT model with AWS CLI, enabling users to execute AWS commands using natural language prompts.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages