Manual Setup
Manual deployment + advanced configuration
Advanced deployment guide for users who need direct Terraform control, CI/CD integration, or custom infrastructure configurations.
Prerequisites
Section titled “Prerequisites”Required Software
Section titled “Required Software”- Terraform (>= 1.0) - Installation Guide
- AWS CLI (>= 2.15.0) - Installation Guide
- Python (>= 3.13) - Installation Guide
- uv - Installation Guide
- Node.js (>= 24.2.0) & npm (>= 11.4.2) - Installation Guide
AWS Account Requirements
Section titled “AWS Account Requirements”- AWS account with appropriate permissions
- AWS CLI configured:
aws configure
- TwelveLabs API Key - Get your API key
Manual Deployment Process
Section titled “Manual Deployment Process”-
Clone and Prepare Repository
Terminal window git clone https://github.com/kubrick-ai/kubrick.gitcd kubrick -
Build Lambda Packages
Build the serverless functions and layers manually with
Terminal window ./lambda/build-package.shor use your own CI/CD solution.
-
Initialize Terraform
Navigate to the Terraform directory and initialize:
Terminal window cd terraformterraform init -
Configure Variables
Create your
terraform.tfvars
file based on the example:Terminal window cp terraform.tfvars.example terraform.tfvarsEdit
terraform.tfvars
with your configuration:# Required variablesaws_region = "us-east-1" # Your AWS region# Database credentialsdb_username = "postgres" # Your PostgreSQL usernamedb_password = "your-secure-password" # Your PostgreSQL password# API keystwelvelabs_api_key = "your-twelvelabs-api-key" # Your TwelveLabs API key# Optional: Override defaultsaws_profile = "default"secret_name = "kubrick_secret"stage_name = "v1_0" -
Review Deployment Plan
Generate and review the execution plan:
Terminal window terraform planThis shows all resources that will be created, modified, or destroyed.
-
Deploy Infrastructure
Apply the Terraform configuration:
Terminal window terraform applyType
yes
when prompted. Deployment takes 10-15 minutes.
Working with Existing AWS Resources
Section titled “Working with Existing AWS Resources”Importing Existing Secrets
Section titled “Importing Existing Secrets”If you already have a secret named kubrick_secret
in AWS Secrets Manager:
-
Verify Secret Contents
Check your existing secret contains required keys:
Terminal window aws secretsmanager get-secret-value \--secret-id kubrick_secret \--query SecretString --output textRequired keys:
DB_USERNAME
DB_PASSWORD
TWELVELABS_API_KEY
-
Update Secret if Needed
If keys are missing or have different names:
Terminal window aws secretsmanager update-secret \--secret-id kubrick_secret \--secret-string '{"DB_USERNAME": "postgres","DB_PASSWORD": "your-password","TWELVELABS_API_KEY": "your-api-key"}' -
Import Existing Secret
Import the secret into Terraform state:
Terminal window terraform import module.secrets_manager.aws_secretsmanager_secret.kubrick_secret kubrick_secret -
Verify Import
Terminal window terraform plan
Handling Resource Conflicts
Section titled “Handling Resource Conflicts”Common Import Issues
- ResourceExistsException: Follow the secret import steps above
- VPC/Subnet conflicts: Ensure your AWS account doesn’t have conflicting default VPC settings
- IAM role conflicts: Check for existing roles with similar names
Terraform Architecture Overview
Section titled “Terraform Architecture Overview”Core Modules
Section titled “Core Modules”api_gateway
- REST API endpoints for video operationscloudfront
- CDN for global content deliverydynamodb
- Embedding cache for performance optimizationiam
- Roles and policies for service permissionslambda
- Serverless functions and layersrds
- PostgreSQL database for metadatas3
- Storage buckets for videos and static assetss3_notifications
- Event triggers for video processingsecrets_manager
- Secure credential storagesqs
- Message queues for async processingvpc_network
- Network infrastructure and security
Lambda Functions Deployed
Section titled “Lambda Functions Deployed”-
API Handlers:
api_fetch_tasks_handler
- Task status and managementapi_fetch_videos_handler
- Video listing and metadataapi_search_handler
- Semantic search with embeddingsapi_video_upload_link_handler
- Presigned upload URLs
-
Processing Functions:
db_bootstrap
- Database initializations3_delete_handler
- Cleanup on video deletionsqs_embedding_task_consumer
- Process embedding jobssqs_embedding_task_producer
- Create embedding jobs
-
Shared Layers:
config_layer
- Common configuration utilitiesembed_service_layer
- TwelveLabs API integrationresponse_utils_layer
- HTTP response formattings3_utils_layer
- S3 operation utilitiesvector_database_layer
- Vector similarity operations
Verification and Testing
Section titled “Verification and Testing”After deployment completes:
-
Check Terraform Output
Review important outputs:
Terminal window terraform outputKey outputs include:
- CloudFront distribution URL
- API Gateway endpoint
- S3 bucket names
- RDS endpoint
-
Verify AWS Resources
Check resource creation:
Terminal window # Lambda functionsaws lambda list-functions --query 'Functions[?contains(FunctionName, `kubrick`)]'# API Gatewayaws apigateway get-rest-apis --query 'items[?contains(name, `kubrick`)]'# S3 bucketsaws s3 ls | grep kubrick -
Test the Playground
Access the CloudFront URL from the Terraform output to test the web interface.
-
API Health Check
Test API endpoints:
Terminal window curl https://your-api-gateway-url/v1_0/videos
Customization Options
Section titled “Customization Options”Custom AWS Region
Section titled “Custom AWS Region”Update aws_region
in your terraform.tfvars
:
aws_region = "eu-west-1" # Europe (Ireland)
Custom Database Configuration
Section titled “Custom Database Configuration”Modify database settings in terraform.tfvars
:
db_username = "kubrick_admin"db_password = "your-complex-password-here"
API Gateway Stage Names
Section titled “API Gateway Stage Names”Change the API version/stage:
stage_name = "production" # Creates /production/ endpoints
Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”State Management
Section titled “State Management”# Backup stateterraform state pull > kubrick.tfstate.backup
# List resources in stateterraform state list
# Remove problematic resourceterraform state rm aws_s3_bucket.example
Cleanup and Management
Section titled “Cleanup and Management”Destroying Infrastructure
Section titled “Destroying Infrastructure”terraform destroy
Selective Resource Management
Section titled “Selective Resource Management”Remove specific resources:
# Remove CloudFrontterraform destroy -target=module.cloudfront
# Remove RDSterraform destroy -target=module.rds
Advanced Configuration
Section titled “Advanced Configuration”CI/CD Integration
Section titled “CI/CD Integration”Example GitHub Actions workflow:
name: Deploy Kubrickon: push: branches: [main]
jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Setup Terraform uses: hashicorp/setup-terraform@v2 - name: Terraform Deploy run: | cd terraform terraform init terraform apply -auto-approve env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} TF_VAR_twelvelabs_api_key: ${{ secrets.TWELVELABS_API_KEY }}
Multi-Environment Setup
Section titled “Multi-Environment Setup”Create separate .tfvars
files for each environment:
# Developmentterraform apply -var-file="dev.tfvars"
# Productionterraform apply -var-file="prod.tfvars"
IaC File Structure
Section titled “IaC File Structure”Directorykubrick/
- …
Directoryterraform/
Directorymodules/
Directoryapi_gateway/
- …
Directorycloudfront/
- …
Directorydynamodb/
- …
Directoryiam/
- …
Directorylambda/
- …
Directoryrds/
- …
Directorys3/
- …
Directorys3_notifications/
- …
Directorysecrets_manager/
- …
Directorysqs/
- …
Directoryvpc_network/
- …
- main.tf
- variables.tf
- terraform.tfvars.example