This is an example of deploying Botpress to AWS, using the AWS CDK.
This Botpress has the following characteristics:
- Uses Fargate as its compute engine
- Deploys a publicly-accessible Botpress instance. All backing services (Postgresql database, Redis cache cluster) are private
- Installs the Botpress server, duckling and the Botpress Language Server in a separate containers
- Uses Aurora Postgresql as its database
- Uses Redis (through ElastiCache) as its cache cluster
- Contains 2 Botpress nodes out-of-the box. Can scale horizontally to more nodes
- Uses an Application Load Balancer to balance ingress traffic to all Botpress Server nodes
- Uses AWS WAF to add additional security in front of the Application Load Balancer
From the project's root, simply run:
npm i
Now that dependencies are installed, you're ready to deploy to AWS.
Before deploying, make sure to specify your AWS credentials and region. See here for more information on how to achieve this using the AWS CDK.
From the project's root:
npx cdk deploy -e Botpress-VPC --profile {your AWS profile}
. More information about AWS profiles can be found herenpx cdk deploy -e Botpress-DB --profile {your AWS profile}
npx cdk deploy -e Botpress-Redis --profile {your AWS profile}
- Connect the database (see "Connecting to the database" below)
- Create a Postgresql user (
create user {role name} with password '{role password}'
) grant {role name} to master
- Create the database:
create database {db name} with owner {role name}
npx cdk deploy -e Botpress-Domains --profile {your AWS profile} --parameters DomainName={your top level domain name, e.g. mycompany.com}
. While this stack is being created, you need to update the Name Servers in your domain registrar. First, find the newly created Hosted Zone in Route53. Copy the NS record values, and paste them in your registrar's DNS console. This step is necessary to validate the ACM Certificate.npx cdk deploy -e Botpress-Services --profile {your AWS profile} --parameters License="your botpress license key" --parameters DatabaseURL="postgres://{role name}:{role password}@{the DNS name for your RDS instance, see RDS console to get it}:3306/{db name}"
npx cdk deploy -e Botpress-WAF --profile {your AWS profile}
- Your Botpress instance will be available at
https://botpress.{your top level domain}
- In a terminal, from the
scripts/
directory:AWS_PROFILE={your AWS profile} AWS_DEFAULT_REGION={your AWS region, e.g. us-east-1} ./connect.sh -o 3000 {the DNS name for your RDS instance, see RDS console to get it} 3306
- In another terminal,
psql -h localhost -p 3306 -U master postgres
. The password can be found in AWS Secrets Manager
- Since Fargate does not support Docker Volumes at this time, disk space limits the quantity of languages that can be installed in a single container. A more scalable approach would be to host the language server on an EC2 instance.