Deploy on AWS EC2
AWS
We provide a Terraform module to deploy Agenta on AWS. You can find it here. The terraform module will simply create a t2.medium instance, a security group (with the open ports: 80, 8080), an elastic IP and an ebs volume all of them in eu-central-1. You can customize the module according to your needs.
- Install Terraform: First, install Terraform.
- Configure AWS Credentials: Follow the instructions here to set up your AWS credentials.
- Initialize and Apply Terraform: Navigate to the correct directory and run:
cd self-host/aws terraform init terraform apply
Terraform will prompt you for a specific domain. You can specify a domain or leave it blank.
Once Terraform finishes creating the resources, it will display the domain name or IP where Agenta can be accessed. Here’s a sample output:
Open the link below in your browser to access Agenta, but wait a few minutes for the services to start.
Important: If you provided a domain name, ensure that it points to this IP address: x.x.x.x
Link: http://cloud.agenta.ai
Ensure that the domain name points to the IP address given by Terraform if you provided one.
Please note, Agenta might take a few minutes to become accessible as it installs dependencies and initializes. Refer to this script for more details: instance-setup.sh
Serving a Variant to an Instance
After hosting Agenta on an instance, you can serve a variant by running:
agenta init
? Please enter the app name job_classifier
? Where are you running agenta? On a remote machine
? Please provide the IP or URL of your remote host cloud.agenta.ai
? How do you want to initialize your app? Blank App
App initialized successfully
SSH into the instance:
In order to ssh into the instance you need to:
- Uncomment these lines in the security group
ingress {
description = "SSH"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
and also these line in the instance file:
resource "aws_key_pair" "agenta_key" {
key_name = "agenta-key"
public_key = file("~/.ssh/id_rsa_agenta.pub")
}
key_name = aws_key_pair.agenta_key.key_name
-
Create a key pair in the AWS console or via:
ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa_agenta
-
Rerun
terraform apply.
-
Connect using:
ssh -i ~/.ssh/id_rsa_agenta ubuntu@ec2-host-provided-by-aws
Removing All Resources:
To delete all the resources created by Terraform, simply run:
cd self-host/aws
terraform destroy
Was this page helpful?