# Infrastructure Template
# Standardized template for data infrastructure design and deployment across the AI Agentic Data Stack Framework

metadata:
  template_id: "infrastructure-tmpl"
  name: "Infrastructure Template"
  version: "1.0.0"
  description: "Comprehensive template for designing and deploying scalable data infrastructure"
  category: "infrastructure"
  tags: ["infrastructure", "cloud", "deployment", "scaling", "monitoring"]
  created_by: "AI Agentic Data Stack Framework"
  created_date: "2025-01-23"
template:
  name: "Infrastructure Template"
  description: "Template for infrastructure implementation and management"
  version: "1.0.0"


# Infrastructure Configuration
infrastructure_config:
  infrastructure_id: "${infrastructure_id}"
  infrastructure_name: "${infrastructure_name}"
  description: "${infrastructure_description}"
  environment: "${environment_type}" # development, staging, production, disaster_recovery
  deployment_model: "${deployment_model}" # cloud, on_premise, hybrid, multi_cloud

# Cloud Configuration
cloud_config:
  # Primary Cloud Provider
  primary_cloud:
    provider: "${primary_cloud_provider}" # aws, azure, gcp, alibaba
    region: "${primary_region}"
    availability_zones: ["${availability_zones}"]
    
  # Multi-Cloud Setup
  multi_cloud:
    enabled: ${multi_cloud_enabled}
    secondary_providers: ["${secondary_cloud_providers}"]
    data_residency_requirements: ["${data_residency_requirements}"]
    
  # Hybrid Cloud
  hybrid_cloud:
    enabled: ${hybrid_cloud_enabled}
    on_premise_connectivity: "${on_premise_connectivity_method}"
    data_synchronization: "${hybrid_data_sync_strategy}"

# Compute Infrastructure
compute_infrastructure:
  # Virtual Machines
  virtual_machines:
    - vm_id: "${vm_id}"
      vm_name: "${vm_name}"
      vm_size: "${vm_size}"
      operating_system: "${vm_operating_system}"
      cpu_cores: ${vm_cpu_cores}
      memory_gb: ${vm_memory_gb}
      storage_gb: ${vm_storage_gb}
      
  # Container Infrastructure
  containers:
    container_orchestration: "${container_orchestration}" # kubernetes, docker_swarm, ecs
    cluster_config:
      cluster_name: "${cluster_name}"
      node_count: ${cluster_node_count}
      node_type: "${cluster_node_type}"
      auto_scaling: ${cluster_auto_scaling_enabled}
      
  # Serverless Computing
  serverless:
    enabled: ${serverless_enabled}
    functions: ["${serverless_functions}"]
    event_triggers: ["${serverless_event_triggers}"]
    resource_limits: ["${serverless_resource_limits}"]

# Storage Infrastructure
storage_infrastructure:
  # Object Storage
  object_storage:
    - storage_id: "${object_storage_id}"
      storage_name: "${object_storage_name}"
      storage_class: "${storage_class}" # standard, cold, archive
      replication_strategy: "${replication_strategy}"
      encryption: ${object_storage_encryption}
      
  # Block Storage
  block_storage:
    - volume_id: "${block_volume_id}"
      volume_name: "${block_volume_name}"
      volume_size_gb: ${block_volume_size}
      volume_type: "${block_volume_type}" # ssd, hdd, provisioned_iops
      
  # Database Storage
  database_storage:
    - database_id: "${database_id}"
      database_name: "${database_name}"
      database_type: "${database_type}" # relational, nosql, time_series, graph
      storage_engine: "${database_storage_engine}"
      backup_strategy: "${database_backup_strategy}"

# Network Infrastructure
network_infrastructure:
  # Virtual Private Cloud
  vpc_config:
    vpc_id: "${vpc_id}"
    vpc_name: "${vpc_name}"
    cidr_block: "${vpc_cidr_block}"
    dns_resolution: ${vpc_dns_enabled}
    
  # Subnets
  subnets:
    - subnet_id: "${subnet_id}"
      subnet_name: "${subnet_name}"
      subnet_type: "${subnet_type}" # public, private, isolated
      cidr_block: "${subnet_cidr_block}"
      availability_zone: "${subnet_availability_zone}"
      
  # Load Balancers
  load_balancers:
    - lb_id: "${load_balancer_id}"
      lb_name: "${load_balancer_name}"
      lb_type: "${load_balancer_type}" # application, network, gateway
      target_groups: ["${lb_target_groups}"]
      
  # Security Groups
  security_groups:
    - sg_id: "${security_group_id}"
      sg_name: "${security_group_name}"
      inbound_rules: ["${inbound_rules}"]
      outbound_rules: ["${outbound_rules}"]

# Security Infrastructure
security_infrastructure:
  # Identity and Access Management
  iam_config:
    identity_provider: "${identity_provider}"
    roles: ["${iam_roles}"]
    policies: ["${iam_policies}"]
    multi_factor_auth: ${mfa_enabled}
    
  # Encryption
  encryption_config:
    key_management_service: "${key_management_service}"
    encryption_at_rest: ${encryption_at_rest_enabled}
    encryption_in_transit: ${encryption_in_transit_enabled}
    key_rotation: ${key_rotation_enabled}
    
  # Network Security
  network_security:
    firewall_enabled: ${firewall_enabled}
    intrusion_detection: ${intrusion_detection_enabled}
    vpn_connectivity: "${vpn_connectivity_config}"
    
  # Compliance
  compliance_config:
    compliance_frameworks: ["${compliance_frameworks}"]
    audit_logging: ${compliance_audit_logging}
    data_classification: "${data_classification_scheme}"

# Monitoring Infrastructure
monitoring_infrastructure:
  # Metrics and Monitoring
  metrics_monitoring:
    monitoring_platform: "${monitoring_platform}" # prometheus, cloudwatch, azure_monitor
    metrics_retention: "${metrics_retention_period}"
    custom_metrics: ["${custom_metrics}"]
    
  # Logging
  logging_config:
    log_aggregation: "${log_aggregation_platform}" # elk, splunk, cloudwatch_logs
    log_retention: "${log_retention_period}"
    log_analysis: ${log_analysis_enabled}
    
  # Alerting
  alerting_config:
    alerting_platform: "${alerting_platform}"
    alert_channels: ["${alert_channels}"]
    escalation_policies: ["${escalation_policies}"]
    
  # Distributed Tracing
  tracing_config:
    tracing_enabled: ${distributed_tracing_enabled}
    tracing_platform: "${tracing_platform}" # jaeger, zipkin, x_ray
    sampling_rate: ${tracing_sampling_rate}

# Backup and Disaster Recovery
backup_disaster_recovery:
  # Backup Strategy
  backup_config:
    backup_enabled: ${backup_enabled}
    backup_frequency: "${backup_frequency}"
    backup_retention: "${backup_retention_period}"
    backup_location: "${backup_storage_location}"
    
  # Disaster Recovery
  disaster_recovery:
    dr_enabled: ${disaster_recovery_enabled}
    recovery_time_objective: "${rto_hours}"
    recovery_point_objective: "${rpo_hours}"
    dr_site_location: "${dr_site_location}"
    
  # High Availability
  high_availability:
    ha_enabled: ${high_availability_enabled}
    failover_strategy: "${failover_strategy}"
    health_checks: ["${ha_health_checks}"]

# Auto-scaling Configuration
auto_scaling_config:
  # Compute Auto-scaling
  compute_scaling:
    auto_scaling_enabled: ${compute_auto_scaling_enabled}
    scaling_policies: ["${compute_scaling_policies}"]
    min_instances: ${min_compute_instances}
    max_instances: ${max_compute_instances}
    
  # Storage Auto-scaling
  storage_scaling:
    auto_scaling_enabled: ${storage_auto_scaling_enabled}
    scaling_threshold: ${storage_scaling_threshold}
    max_storage_size: ${max_storage_size}
    
  # Database Auto-scaling
  database_scaling:
    read_replica_scaling: ${read_replica_scaling_enabled}
    connection_pool_scaling: ${connection_pool_scaling_enabled}

# Cost Optimization
cost_optimization:
  # Resource Optimization
  resource_optimization:
    right_sizing_enabled: ${right_sizing_enabled}
    scheduled_shutdown: ${scheduled_shutdown_enabled}
    reserved_instances: ${reserved_instances_enabled}
    
  # Cost Monitoring
  cost_monitoring:
    cost_tracking: ${cost_tracking_enabled}
    budget_alerts: ${budget_alerts_enabled}
    cost_allocation_tags: ["${cost_allocation_tags}"]
    
  # Optimization Strategies
  optimization_strategies:
    spot_instances: ${spot_instances_enabled}
    storage_tiering: ${storage_tiering_enabled}
    cdn_optimization: ${cdn_optimization_enabled}

# Infrastructure as Code
infrastructure_as_code:
  # IaC Platform
  iac_platform: "${iac_platform}" # terraform, cloudformation, arm, pulumi
  
  # Configuration Management
  config_management:
    state_management: "${state_management_strategy}"
    version_control: "${iac_version_control}"
    environment_promotion: "${environment_promotion_strategy}"
    
  # Deployment Pipeline
  deployment_pipeline:
    ci_cd_platform: "${infrastructure_cicd_platform}"
    automated_testing: ${infrastructure_automated_testing}
    approval_gates: ["${infrastructure_approval_gates}"]

# Performance Optimization
performance_optimization:
  # Resource Performance
  resource_performance:
    cpu_optimization: ${cpu_optimization_enabled}
    memory_optimization: ${memory_optimization_enabled}
    storage_optimization: ${storage_optimization_enabled}
    
  # Network Performance
  network_performance:
    cdn_enabled: ${cdn_enabled}
    edge_locations: ["${edge_locations}"]
    network_acceleration: ${network_acceleration_enabled}
    
  # Caching Strategy
  caching_strategy:
    distributed_caching: ${distributed_caching_enabled}
    cache_layers: ["${cache_layers}"]
    cache_optimization: "${cache_optimization_strategy}"

# Validation Rules
validation_rules:
  required_fields:
    - infrastructure_id
    - infrastructure_name
    - environment_type
    - deployment_model
    - compute_infrastructure
    - storage_infrastructure
    - network_infrastructure

# Template Metadata
template_metadata:
  author: "AI Agentic Data Stack Framework"
  maintainer: "Infrastructure Engineer"
  last_updated: "2025-01-23"

sections:
  - name: "overview"
    description: "Overview and objectives"
    required: true
  - name: "configuration"
    description: "Configuration and setup"
    required: true
  - name: "implementation"
    description: "Implementation details"
    required: true
  - name: "validation"
    description: "Validation and testing"
    required: false
