Vaultx.Config.Templates (Vaultx v0.7.0)
View SourceEnvironment-specific configuration template generation for VaultX.
This module provides intelligent configuration template generation for different environments and use cases. Templates are optimized for specific deployment scenarios and include best practices for security, performance, and reliability.
Features
- Environment-Specific Templates: Optimized templates for development, testing, staging, and production
- Feature-Based Configuration: Templates can be customized based on required features
- Security Level Adaptation: Different security levels from basic to enterprise-grade
- Best Practice Integration: Templates incorporate industry best practices
- Customizable Options: Flexible template generation with customizable parameters
Template Types
Development Templates
- Optimized for fast iteration and debugging
- Relaxed security settings for local development
- Enhanced logging and debugging features
- Local Vault server configuration
Testing Templates
- Optimized for automated testing
- Minimal external dependencies
- Fast execution and cleanup
- Mock-friendly configuration
Staging Templates
- Production-like configuration with safety nets
- Enhanced monitoring and logging
- Security settings similar to production
- Performance testing optimizations
Production Templates
- Maximum security and reliability
- Optimized performance settings
- Comprehensive monitoring and auditing
- Enterprise-grade security features
Usage
# Generate production template
{:ok, template} = Vaultx.Config.Templates.generate(:production)
# Generate development template with specific features
{:ok, template} = Vaultx.Config.Templates.generate(:development,
features: [:cache, :telemetry],
security_level: :basic
)
Summary
Functions
Generates a configuration template for the specified environment.
Generates a migration template from one environment to another.
Generates multiple templates for comparison or migration planning.
Types
@type environment() :: :development | :testing | :staging | :production
@type feature() ::
:cache | :telemetry | :audit | :metrics | :rate_limiting | :token_renewal
@type security_level() :: :basic | :enhanced | :enterprise
@type template_options() :: [ features: [feature()], security_level: security_level(), vault_version: String.t(), custom_settings: map() ]
Functions
@spec generate(environment(), template_options()) :: map()
Generates a configuration template for the specified environment.
Parameters
environment- Target environment (:development,:testing,:staging,:production)opts- Template generation options
Returns
Generated configuration template as a map.
Examples
# Basic production template
template = Vaultx.Config.Templates.generate(:production)
# Development template with caching
template = Vaultx.Config.Templates.generate(:development,
features: [:cache, :telemetry]
)
# Enterprise production template
template = Vaultx.Config.Templates.generate(:production,
security_level: :enterprise,
features: [:cache, :telemetry, :audit, :metrics]
)
@spec generate_migration(environment(), environment(), template_options()) :: map()
Generates a migration template from one environment to another.
This function analyzes the differences between environments and provides a template that highlights the changes needed for migration.
Parameters
from_env- Source environmentto_env- Target environmentopts- Template options
Returns
Migration template with change annotations.
Examples
migration = Vaultx.Config.Templates.generate_migration(
:development,
:production,
features: [:cache, :audit]
)
@spec generate_multiple([environment()], template_options()) :: map()
Generates multiple templates for comparison or migration planning.
Parameters
environments- List of environments to generate templates foropts- Common template options
Returns
Map with environment names as keys and templates as values.
Examples
templates = Vaultx.Config.Templates.generate_multiple(
[:development, :production],
features: [:cache, :telemetry]
)
dev_template = templates.development
prod_template = templates.production