Learn how to create and manage environments for different deployment stages.
Environments in Embeddable map your logical data sources to actual database connections. This allows you to:
- Use different databases for development, staging, and production
- Switch data sources without changing your Embeddable models
- Manage multi-tenant architectures with different data per environment
- Test changes safely before deploying to production
Each environment contains:
- Name: A unique identifier (e.g., "production", "staging")
- Data Source Mappings: Map logical names to database connections
Environment: "production"
Data Sources:
- main_db → postgres-prod-connection
- analytics → bigquery-prod-connection
- cache → redis-prod-connection
embed env createThis will prompt you for:
- Environment name
- Data source mappings (logical name → database connection)
- Option to set as default environment
Data sources are logical names used in your Embeddable models. For example:
In your Embeddable model:
// Uses logical name "main_db"
const users = Dataset({
name: 'users',
sql: 'SELECT * FROM users',
datasource: 'main_db'
});In your environment:
- Development:
main_db→postgres-dev-connection - Production:
main_db→postgres-prod-connection
embed env listShows all environments with their data source mappings and default status.
embed env set-default <environment-id>The default environment is used for token generation when no specific environment is specified.
embed env remove <environment-id># Development environment
embed env create
# Name: "development"
# main_db → local-postgres
# analytics → local-bigquery-emulator
# Staging environment
embed env create
# Name: "staging"
# main_db → postgres-staging
# analytics → bigquery-staging
# Production environment
embed env create
# Name: "production"
# main_db → postgres-prod
# analytics → bigquery-prod# Tenant A environment
embed env create
# Name: "tenant-a"
# main_db → postgres-tenant-a
# analytics → bigquery-tenant-a
# Tenant B environment
embed env create
# Name: "tenant-b"
# main_db → postgres-tenant-b
# analytics → bigquery-tenant-b# Feature branch environment
embed env create
# Name: "feature-new-analytics"
# main_db → postgres-prod (read-only)
# analytics → bigquery-experimentalSpecify environment when generating tokens:
# Use default environment
embed token <embeddable-id>
# Use specific environment
embed token <embeddable-id> --env staging
# Use production environment
embed token <embeddable-id> --env productionGenerate tokens for different environments:
# Development token (uses dev database)
embed token dashboard-123 --env development
# Production token (uses prod database)
embed token dashboard-123 --env production- Use descriptive names:
production,staging,development - Include tenant/customer info:
customer-a-prod,customer-b-staging - Use consistent patterns across your team
- Use logical names that describe the data:
main_db,analytics,cache - Keep names consistent across environments
- Avoid database-specific names in your models
- Separate credentials for each environment
- Read-only access for production data in non-prod environments
- Network isolation between environments when possible
- Audit access to production environments
- Create environments for each deployment stage
- Test with development/staging environments first
- Deploy to production only after validation
- Monitor environment usage and performance
- Clean up unused environments regularly
# Development
main_db → local-postgres
redis_cache → local-redis
# Production
main_db → aws-rds-postgres
redis_cache → aws-elasticache# Staging
transactional_db → postgres-staging
data_warehouse → snowflake-staging
clickstream → kafka-staging
# Production
transactional_db → postgres-prod
data_warehouse → snowflake-prod
clickstream → kafka-prod# US Region
main_db → postgres-us-east
analytics → bigquery-us
# EU Region
main_db → postgres-eu-west
analytics → bigquery-eu# List available environments
embed env list
# Check environment name spelling
embed env set-default <correct-environment-name>- Ensure data source names match those used in your Embeddable models
- Verify database connections exist and are working
- Check connection permissions for the mapped databases
- Verify the environment exists:
embed env list - Check the default environment is set:
embed config - Ensure all mapped connections are valid:
embed database list
For more troubleshooting help, see the Troubleshooting Guide.
For complete setup examples, see Examples.