Welcome to the Demo YVR DevOps GenAI Project!
This repository contains the source code for a Discord bot and an Issue Creator Lambda function, both of which are designed to showcase the integration of AWS services, Terraform infrastructure as code, and the OpenAI API with an innovative approach to automated GitHub issue creation.
The project is structured into two main components:
- Discord Bot: A Python-based bot that listens to commands and interactions within a Discord server. It's capable of responding to simple commands and is designed to be easily extendable for more complex interactions.
- Issue Creator Lambda Function: An AWS Lambda function that uses the OpenAI API to generate GitHub issues based on error logs captured from the Discord bot and its code. This demonstrates an innovative approach to automated issue creation by using a large language model to interpret error logs.
To get started with this project, you'll need to have the following prerequisites:
- An AWS account
- Terraform installed
- A Discord account and a server where you can add the bot
- An OpenAI API key
- A GitHub account, Personal Access Token (PAT), and a repository where you can create issues
-
Create a Discord Application: Before cloning the repository, you need to create a Discord application for your bot. Go to the Discord Developer Portal, create a new application, and note down the application's public key and token. These will be used later to configure the Discord bot.
-
Clone the Repository: Now, clone this repository to your local machine.
git clone https://github.com/autimo/demo-yvr-devops-genai.git
-
Configure AWS Credentials: Ensure your AWS credentials are configured properly. This can be done by setting up the AWS CLI and running
aws configureor setting theAWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY, andAWS_REGIONenvironment variables. -
Terraform Initialization: Navigate to the
terraformdirectory and runterraform initto initialize the Terraform environment. -
Deploy Infrastructure: Apply the Terraform configuration to deploy the necessary infrastructure to AWS.
terraform apply
Enter the required variables when prompted or create a
terraform.tfvarsfile in theterraformdirectory with your specific values.
In order to successfully deploy and operate the components of this project, certain variables and secrets need to be configured in your GitHub repository's actions. Here's a breakdown of what's required:
DISCORD_APPLICATION_ID: The application ID of your Discord bot. This is required for the bot to authenticate with Discord's API.DISCORD_BOT_TOKEN: The token for your Discord bot. This is used to log in the bot to Discord.DISCORD_GUILD_ID: The ID of the Discord server (guild) where the bot is added. This is necessary for registering bot commands to a specific server.OPENAI_API_KEY: Your OpenAI API key, required for the Issue Creator Lambda function to generate GitHub issues.GH_PAT: A GitHub Personal Access Token with the necessary permissions to create issues in the specified repository.
These are configured as environment variables in the .github/workflows/push.yaml file and are used across different steps in the GitHub Actions workflow:
TF_VERSION: The version of Terraform to use. This project uses1.7.5.PYTHON_VERSION: The version of Python to use for running scripts. This project uses3.12.
Additionally, the following variables are used within the Terraform configuration and are prompted during the terraform apply command, but can also be predefined in a terraform.tfvars file:
AWS_IAM_ROLE_ARN: The ARN of the AWS IAM role that GitHub Actions will assume for deploying resources.AWS_REGION: The AWS region where resources will be deployed.AWS_S3_BUCKET_NAME: The name of the S3 bucket used by Terraform for state storage.AWS_DYNAMODB_TABLE_NAME: The name of the DynamoDB table used by Terraform for state locking.
Ensure these secrets and variables are correctly set up in your GitHub repository and AWS account for the smooth operation of the project.
Contributions are welcome! If you have improvements or bug fixes, please feel free to fork the repository and submit a pull request.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
