This guide provides instructions for deploying Cohere's Toolkit on AWS using AWS Copilot. AWS Copilot is a CLI tool that simplifies building, releasing, and managing production-ready applications on Amazon ECS with AWS Fargate.
- AWS Copilot does not support deployment using AWS root accounts. You must create an IAM user with the
AdministratorAccess
policy enabled.
Before starting, ensure you have:
- An AWS account
- AWS CLI installed and configured:
- Install AWS CLI
- Run
aws configure
to set up yourAWS Access Key ID
,Secret Access Key
,region
, andoutput format
- Docker installed:
- AWS Copilot installed:
- Cohere's Toolkit repository cloned
- Environment Variables set up in
.env
,configuration.yaml
, andsecrets.yaml
:- Follow the setup guide for configuration details
- Go to the IAM console and click Users.
- Click Create user and enter a username.
- Select Provide user access to the AWS Management Console - optional and choose password settings.
- Click Next: Permissions, then Attach policies directly.
- Search for
AdministratorAccess
, select it, and proceed with Next. - Review and click Create user.
- After creating the user, select it and go to the Security credentials tab.
- Click Create access key, choose
Other
, and proceed. - Copy the
Access key
andSecret access key
and store them securely.
- Run
aws configure
and input theAccess key
,Secret access key
,region
, andoutput format
.
The deployment script uses configuration values from either the .env or configuration.yaml file. Set the following environment variable in the .env file:
DATABASE_URL='postgresql+psycopg2://postgres:postgres@{service name}.{env name}.{app name}.local:5432'
Or, in the configuration.yaml file::
database:
url: postgresql+psycopg2://postgres:postgres@{service name}.{env name}.{app name}.local:5432
For the current deployment, the database URL should be:
postgresql+psycopg2://postgres:[email protected]:5432
- Navigate to the root directory of the cloned repository.
- Run the deployment script:
./aws_copilot_deploy/aws_deploy.sh
- Wait for the deployment to complete. The script will output the URL of the deployed application.
- To delete the deployed application, run:
./aws_copilot_deploy/aws_cleanup.sh
The provided deployment script uses AWS Copilot to set up an application, environment, and services on AWS Fargate. This deployment includes:
- Reverse Proxy: Uses Nginx to route traffic between services, as AWS Copilot supports only one load-balanced service per application.
- Containerized Database: Uses a containerized database by default. You can modify the script to use Amazon RDS by following these instructions for setting up an RDS Aurora Serverless v2 cluster using
copilot storage init
. - Resource Allocation: Adjust service resource settings (e.g.,
cpu
,memory
) in each service'smanifest.yml
file as needed. - Customizing Services: Comment out unnecessary services in
aws_deploy.sh
or delete a service with:Refer to the full AWS Copilot documentation for more commands.copilot svc delete