Skip to content

Commit 958f638

Browse files
authored
Update examples for Brainstore (#26)
Example code updated with relevant brainstore configs and docs
2 parents f423ad4 + 6646c0e commit 958f638

File tree

7 files changed

+58
-17
lines changed

7 files changed

+58
-17
lines changed

assets/Brainstore-License-Key.png

347 KB
Loading
Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,35 @@
1-
A standard Braintrust data plane deployment. Copy this directory to a new directory in your own repository and modify the files to match your environment.
1+
This is an example of a standard Braintrust data plane deployment. Copy this directory to a new directory in your own repository and modify the files to match your environment.
22

3+
## Configure Terraform
34
* `provider.tf` should be modified to use your AWS account and region.
45
* `terraform.tf` should be modified to use the remote backend that your company uses. Typically this is an S3 bucket and DynamoDB table.
56
* `main.tf` should be modified to meet your needs for the Braintrust deployment. The defaults are sensible only for a small development deployment.
7+
* Brainstore requires a license key which you can find in the Braintrust UI under Settings > API
8+
![Brainstore License Key](../../assets/Brainstore-License-Key.png)
9+
* It isn't recommended that you commit this license key to your git repo. You can safely pass this key into terraform multiple ways:
10+
* Set `TF_VAR_brainstore_license_key=your-key` in your terraform environment
11+
* Pass it into terraform as a flag `terraform apply -var 'brainstore_license_key=your-key'`
12+
* Add it to an uncommitted `terraform.tfvars` or `.auto.tfvars` file.
613

7-
After applying this configuration, you will have a Braintrust data plane deployed in your AWS account. You can then run `terraform output` to get the API URL you need to enter into the Braintrust UI for your Organization.
14+
## Pointing your Organization to your data plane
815

9-
If you are testing, it is HIGHLY recommended that you create a new Braintrust Organization for testing purposes. If you change your live Organization's API URL, you might break users who are currently using it.
16+
After applying this configuration you will have a Braintrust data plane deployed in your AWS account. You can then run `terraform output` to get the API URL you need to enter into the Braintrust UI for your Organization.
17+
```
18+
❯ terraform output
19+
api_url = "https://dx6ntff6gocr6.cloudfront.net"
20+
```
1021

1122
To configure your Organization to use your new data plane, click your user icon on the top right > Settings > API URL.
1223

24+
> [!WARNING]
25+
> If you are testing, it is HIGHLY recommended that you create a new Braintrust Organization for testing purposes. If you change your live Organization's API URL, you might break users who are currently using it.
26+
1327
![Setting the API URL in Braintrust](/assets/Braintrust-API-URL.png)
1428

1529
Paste the API URL into the text field and click Save. Click to copy the test ping command and run it in your terminal to verify that your data plane is working.
1630

1731
![Verifying the API URL in Braintrust](/assets/Braintrust-API-URL-2.png)
32+
33+
Copy the Brainstore license key.
34+
35+

examples/braintrust-data-plane/main.tf

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# tflint-ignore-file: terraform_module_version
1+
# tflint-ignore-file: terraform_module_pinned_source
22

33
locals {
44
# This is primarily used for tagging and naming resources in your AWS account.
@@ -7,18 +7,12 @@ locals {
77
}
88

99
module "braintrust-data-plane" {
10-
source = "braintrustdata/data-plane/braintrust"
11-
# Uncomment the version line to lock to a specific version of the module.
12-
# version = "1.1.0"
10+
source = "github.com/braintrustdata/terraform-braintrust-data-plane"
11+
# Append '?ref=<version_tag>' to lock to a specific version of the module.
1312

1413
deployment_name = local.deployment_name
1514
braintrust_org_name = "" # Add your organization name from the Braintrust UI here
1615

17-
## Additional optional parameters:
18-
19-
# The number API Handler instances to provision and keep alive. This reduces cold start times and improves latency, with some increase in cost.
20-
# api_handler_provisioned_concurrency = 0
21-
2216
### Postgres configuration
2317
# The default is small for development and testing purposes. Recommended db.r8g.2xlarge for production.
2418
# postgres_instance_type = "db.t4g.xlarge"
@@ -40,6 +34,21 @@ module "braintrust-data-plane" {
4034
# PostgreSQL engine version for the RDS instance.
4135
# postgres_version = "15.7"
4236

37+
### Brainstore configuration
38+
# Enable Brainstore for faster analytics
39+
enable_brainstore = false
40+
41+
# The license key for the Brainstore instance. You can get this from the Braintrust UI in Settings > API URL.
42+
brainstore_license_key = var.brainstore_license_key
43+
44+
# The instance type to use for the Brainstore. Must be a Graviton instance type. Preferably with 16GB of memory and a local SSD for cache data.
45+
# The default value is for tiny deployments. Recommended for production deployments is c7gd.8xlarge.
46+
# brainstore_instance_type = "c7gd.xlarge"
47+
48+
# The number of Brainstore instances to provision
49+
# brainstore_instance_count = 1
50+
51+
4352
### Redis configuration
4453
# Default is acceptable for small production deployments. Recommended cache.m7g.large for larger deployments.
4554
# redis_instance_type = "cache.t4g.small"
@@ -56,6 +65,9 @@ module "braintrust-data-plane" {
5665
# quarantine_vpc_cidr = "10.176.0.0/16"
5766

5867
### Advanced configuration
68+
# The number API Handler instances to provision and keep alive. This reduces cold start times and improves latency, with some increase in cost.
69+
# api_handler_provisioned_concurrency = 0
70+
5971
# List of origins to whitelist for CORS
6072
# whitelisted_origins = []
6173

@@ -77,4 +89,5 @@ module "braintrust-data-plane" {
7789

7890
# Enable the Quarantine VPC to run user defined functions in an isolated environment. If disabled, user defined functions will not be available.
7991
# enable_quarantine_vpc = true
92+
8093
}

examples/braintrust-data-plane/terraform.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
# backend "s3" {
44
# # Example: "us-east-1"
55
# region = "<your AWS region>"
6-
# # Example: "terraform-state-lock"
7-
# dynamodb_table = "<your-dynamodb-table-name>"
6+
87
# # Example: "yourcompany-terraform-state"
98
# bucket = "<s3-bucket-name>"
9+
# use_lockfile = true
1010
# # The path in S3 to store the state of this terraform directory.
11-
# key = "braintrust"
11+
# # Change this for each environment you deploy to.
12+
# key = "braintrust.tfstate"
1213
# }
1314
# }
1415

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
variable "brainstore_license_key" {
2+
description = "The license key for the Brainstore instance. You can get this from the Braintrust UI in Settings > API URL."
3+
type = string
4+
validation {
5+
condition = var.brainstore_license_key != null && var.brainstore_license_key != ""
6+
error_message = "The brainstore_license_key must be set."
7+
}
8+
}
9+

examples/braintrust-data-plane/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
terraform {
2-
required_version = ">= 1.9.0"
2+
required_version = ">= 1.10.0"
33
required_providers {
44
aws = {
55
source = "hashicorp/aws"

modules/services/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
output "api_url" {
22
description = "The primary endpoint for the dataplane API. This is the value that should be entered into the braintrust dashboard under API URL."
3-
value = aws_cloudfront_distribution.dataplane.domain_name
3+
value = "https://${aws_cloudfront_distribution.dataplane.domain_name}"
44
}
55

66
output "ai_proxy_url" {

0 commit comments

Comments
 (0)