- AI-powered agents to manage AWS services (EC2, S3, Lambda) using natural language commands.
- Built with
phidata
andboto3
.
I used Groq (llama-3.3-70b-versatile) which provides a Free API Key.
- EC2 Management: List, start and stop EC2 instances.
- S3 Management: List buckets, upload/download files
- Lambda Management: List and invoke Lambda functions.
- AI Integration: Execute tasks using natural language commands.
-
Permissions Required:
AmazonEC2FullAccess
(for EC2)AmazonS3FullAccess
(for S3)AWSLambda_FullAccess
(for Lambda)
-
Libraries:
pip install boto3 phidata
# Linux/Mac
export AWS_ACCESS_KEY_ID="AKIAXXXXXXXXXXXXXXXX"
export AWS_SECRET_ACCESS_KEY="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
export AWS_REGION= "YOUR REGION"
export GROQ_API_KEY = "YOUR_API_KEY"
# Windows (PowerShell)
$env:AWS_ACCESS_KEY_ID="AKIAXXXXXXXXXXXXXXXX"
$env:AWS_SECRET_ACCESS_KEY="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
$env:AWS_REGION= "YOUR REGION"
$env:GROQ_API_KEY= "YOUR_API_KEY"
Create or edit ~/.aws/credentials
(Linux/Mac) or %USERPROFILE%\.aws\credentials
(Windows):
[default]
aws_access_key_id = AKIAXXXXXXXXXXXXXXXX
aws_secret_access_key = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
region = "YOUR_REGION"
from phi.agent import Agent
from phi.tools.aws_lambda import AWSLambdaTool (comes with phidata)
from ec2tool import EC2Tool
from s3tool import S3Tool
from phi.model.Groq import Groq
from dotenv import load_dotenv
load_dotenv()
ec2_agent = Agent(
tools=[EC2Tool(region_name=YOUR_REGION)],
model=Groq(id="llama-3.3-70b-versatile"),
name="AWS EC2 Agent",
instructions="...", # (I will be posting great Instructions in this repo)
show_tool_calls=True,
)
s3_agent = Agent(
tools=[S3Tool(region_name=YOUR_REGION)],
name="AWS S3 Agent",
model=Groq(id="llama-3.3-70b-versatile"),
instructions="...", # (I will be posting great Instructions in this repo)
show_tool_calls=True,
)
lambda_agent = Agent(
tools=[AWSLambdaTool(region_name=YOUR_REGION)],
model=Groq(id="llama-3.3-70b-versatile"),
name="AWS Lambda Agent",
instructions="...", # (I will be posting great Instructions in this repo)
show_tool_calls=True,
)
# List all EC2 instances
ec2_agent.print_response("List all EC2 instances.")
# Start an EC2 instance
ec2_agent.print_response("Start the EC2 instance with ID i-1234567890abcdef0.")
# List S3 buckets
s3_agent.print_response("List all S3 buckets.")
# Upload a file
s3_agent.print_response("Upload example.txt to the bucket named my-bucket.")
# List Lambda functions
lambda_agent.print_response("List all Lambda functions.")
# Invoke a Lambda function
lambda_agent.print_response("Invoke the Lambda function named my-function.")
-
I am unsure about the
AmazonEC2FullAccess
,AmazonS3FullAccess
, andAmazonLambdaFullAccess
permissions. -
Full Access to some AWS services may not be a great idea.
-
Because in more complex & indirect cases like:
"Download this (if needed tools are given) and load the summary to the related named S3 bucket"
can cause unwanted/meant operations decided by Agent.
-
I have concerns about granting an agent full access to AWS service usage, as it might lead to unexpected costs.
-
Idk when I take some advanced courses and keep learning, Some of these can be fixed.
- Phidata Documentation: https://phidata.com
- boto3 Documentation: boto3 Docs
NOTE: A freshman creates this repository. I believe some great opinions about this repo would lead me to learn & develop more.