version: 2

seeds:
  - name: account_mapping
    description: |
      Account mapping table for translating cloud account IDs to human-readable names
      and adding business attributes for cost attribution and access control.
      
      **Key Features:**
      - Maps account IDs to display names (essential for Alibaba Cloud)
      - Adds business attributes: cost_center, owner, account_purpose
      - Supports row-level security via access_level field
      - Uses SCD Type 2 pattern for historical attribution tracking
      
      **Maintenance Guide:**
      
      To update an account's cost_center or owner:
      1. Set effective_to to the last day of old attribution (e.g., '2025-12-31')
      2. Add a new row with effective_from as the first day of new attribution
      
      Example:
      ```
      alibaba,123,Prod,Production,infra-team,CC-001,restricted,2025-01-01,2025-12-31
      alibaba,123,Prod,Production,platform-team,CC-002,restricted,2026-01-01,9999-12-31
      ```
      
      **WARNING: Date ranges must NOT overlap!**
      For the same (cloud_provider, account_id), ensure effective_from/effective_to
      ranges do not overlap. Overlapping ranges will be detected by the 
      `assert_no_overlapping_account_mappings` test.
    config:
      column_types:
        cloud_provider: STRING
        account_id: STRING
        account_display_name: STRING
        account_purpose: STRING
        owner: STRING
        cost_center: STRING
        access_level: STRING
        effective_from: DATE
        effective_to: DATE
    columns:
      - name: cloud_provider
        description: Cloud provider identifier (aws, gcp, azure, alibaba)
        tests:
          - not_null
          - accepted_values:
              values: ['aws', 'gcp', 'azure', 'alibaba']
      
      - name: account_id
        description: Original account/project/subscription ID from cloud provider
        tests:
          - not_null
      
      - name: account_display_name
        description: Human-readable display name for the account
        tests:
          - not_null
      
      - name: account_purpose
        description: |
          Account purpose category:
          - 'Production': Production environments
          - 'Development': Development and testing environments  
          - 'Others': Non-R&D accounts (IT, Presales, etc.)
        tests:
          - not_null
          - accepted_values:
              values: ['Production', 'Development', 'Others', 'ProductionInfrastructure']
      
      - name: owner
        description: Team or individual responsible for this account
      
      - name: cost_center
        description: Cost center code for financial reporting
      
      - name: access_level
        description: |
          Access control level for row-level security:
          - 'public': Visible to all company employees
          - 'restricted': Visible only to authorized teams (e.g., FinOps, Infra)
        tests:
          - not_null
          - accepted_values:
              values: ['public', 'restricted']
      
      - name: effective_from
        description: Start date of this mapping (inclusive), format YYYY-MM-DD
        tests:
          - not_null
      
      - name: effective_to
        description: End date of this mapping (inclusive), format YYYY-MM-DD. Use '9999-12-31' for current/active mappings.
        tests:
          - not_null

  - name: tag_exempt_services
    description: |
      Services exempt from tag compliance reporting.

      Account-level AWS services (e.g., CloudTrail, GuardDuty, Config) cannot be
      meaningfully tagged with business owner tags. This seed maintains the list of
      exempt services so the tag compliance dashboard can classify them separately
      from genuinely non-compliant resources.
    columns:
      - name: service
        description: AWS service code (must match product_servicecode values in mart_cost_monthly)
        tests:
          - not_null
          - unique
      - name: exempt_reason
        description: Human-readable reason why this service is exempt from tag compliance
        tests:
          - not_null
