diff --git a/alembic/versions/0892c44b2a58_seed_aws_pricing_data.py b/alembic/versions/0892c44b2a58_seed_aws_pricing_data.py new file mode 100644 index 0000000..94114e5 --- /dev/null +++ b/alembic/versions/0892c44b2a58_seed_aws_pricing_data.py @@ -0,0 +1,136 @@ +"""seed aws pricing data + +Revision ID: 0892c44b2a58 +Revises: e80c6eef58b2 +Create Date: 2026-04-07 13:53:23.116106 + +""" + +from typing import Sequence, Union +from uuid import uuid4 + +from alembic import op + + +# revision identifiers, used by Alembic. +revision: str = "0892c44b2a58" +down_revision: Union[str, Sequence[str], None] = "e80c6eef58b2" +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + """Seed AWS pricing data.""" + # Pricing data for us-east-1 (N. Virginia) + pricing_data = [ + # SQS Pricing + { + "id": str(uuid4()), + "service": "sqs", + "region": "us-east-1", + "tier": "standard", + "price_per_unit": 0.40, + "unit": "per_million_requests", + "description": "Amazon SQS Standard Queue - API requests", + }, + # Lambda Pricing + { + "id": str(uuid4()), + "service": "lambda", + "region": "us-east-1", + "tier": "x86_request", + "price_per_unit": 0.20, + "unit": "per_million_requests", + "description": "AWS Lambda x86 - Request charges", + }, + { + "id": str(uuid4()), + "service": "lambda", + "region": "us-east-1", + "tier": "x86_compute", + "price_per_unit": 0.0000166667, + "unit": "per_gb_second", + "description": "AWS Lambda x86 - Compute charges", + }, + # Bedrock Pricing (Claude 3) + { + "id": str(uuid4()), + "service": "bedrock", + "region": "us-east-1", + "tier": "claude_3_sonnet_input", + "price_per_unit": 0.003, + "unit": "per_1k_tokens", + "description": "Amazon Bedrock - Claude 3 Sonnet Input", + }, + { + "id": str(uuid4()), + "service": "bedrock", + "region": "us-east-1", + "tier": "claude_3_sonnet_output", + "price_per_unit": 0.015, + "unit": "per_1k_tokens", + "description": "Amazon Bedrock - Claude 3 Sonnet Output", + }, + # eu-west-1 (Ireland) - similar pricing + { + "id": str(uuid4()), + "service": "sqs", + "region": "eu-west-1", + "tier": "standard", + "price_per_unit": 0.40, + "unit": "per_million_requests", + "description": "Amazon SQS Standard Queue - API requests", + }, + { + "id": str(uuid4()), + "service": "lambda", + "region": "eu-west-1", + "tier": "x86_request", + "price_per_unit": 0.20, + "unit": "per_million_requests", + "description": "AWS Lambda x86 - Request charges", + }, + { + "id": str(uuid4()), + "service": "lambda", + "region": "eu-west-1", + "tier": "x86_compute", + "price_per_unit": 0.0000166667, + "unit": "per_gb_second", + "description": "AWS Lambda x86 - Compute charges", + }, + { + "id": str(uuid4()), + "service": "bedrock", + "region": "eu-west-1", + "tier": "claude_3_sonnet_input", + "price_per_unit": 0.003, + "unit": "per_1k_tokens", + "description": "Amazon Bedrock - Claude 3 Sonnet Input", + }, + { + "id": str(uuid4()), + "service": "bedrock", + "region": "eu-west-1", + "tier": "claude_3_sonnet_output", + "price_per_unit": 0.015, + "unit": "per_1k_tokens", + "description": "Amazon Bedrock - Claude 3 Sonnet Output", + }, + ] + + # Insert data using bulk insert + for data in pricing_data: + op.execute(f""" + INSERT INTO aws_pricing + (id, service, region, tier, price_per_unit, unit, description, is_active, effective_from) + VALUES + ('{data["id"]}', '{data["service"]}', '{data["region"]}', '{data["tier"]}', + {data["price_per_unit"]}, '{data["unit"]}', '{data["description"]}', + true, CURRENT_DATE) + """) + + +def downgrade() -> None: + """Remove seeded pricing data.""" + op.execute("DELETE FROM aws_pricing WHERE is_active = true;")