Skip to main content

Deploy on AWS EC2

tip

This guide is for provisioning and deploying agenta on AWS EC2 using Terraform. If you prefer to provision the instance manually, you can use the guide for deploying on a remote machine.

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.

  1. Install Terraform: First, install Terraform.
  2. Configure AWS Credentials: Follow the instructions here to set up your AWS credentials.
  3. 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

caution

There is no security mechanism in place yet. Exercise caution.

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
caution

Provide the remote host without the protocol (http://)

SSH into the instance:

In order to ssh into the instance you need to:

  1. 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
  1. Create a key pair in the AWS console or via:

    ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa_agenta
  2. Rerun

    terraform apply.
  3. 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