Phase 4 — Profile

Ziel: Cost Explorer zeigt pro Bedrock-Call den Caller. Damit wird Phase 5 (Optimize) datengetrieben statt geraten.

Aufwand: ~1.5h Setup, dann 3 Tage Messung.

Vorbedingung: Phase 1 fertig (Caller-Liste). Phase 3 nice-to-have (Notbremsen schon live).

Nachbedingung: AIPs pro Caller, Tags in Billing aktiviert, mind. 3 Tage Daten im Cost Explorer.

Application Inference Profiles — Konzept

Ein Inference Profile ist eine Routing-Ebene oberhalb des Modells: statt anthropic.claude-sonnet-4-6 direkt aufzurufen, ruft der Caller arn:aws:bedrock:eu-central-1:ACCT:application-inference-profile/<name> auf. Das Profile trackt Cost separat und erlaubt Tags.

Drei Typen:

  1. System-defined Inference Profile — z.B. eu.anthropic.claude-sonnet-4-6 (Cross-Region-Routing, schon in Benutzung)
  2. Application Inference Profile — pro Caller eines, referenziert ein System-Profile + traegt eigene Tags
  3. Default (kein Profile) — was wir aktuell nutzen, kein Cost-Tracking pro Caller

Wir bauen Typ 2 fuer jeden Caller.

Schritte

4.1 AIPs anlegen via CloudFormation

Template templates/aip-cloudformation.yaml im Skill-Repo: nimmt Parameter CallerName, BaseModelProfile, Tags{Application, Owner, Env} und legt ein AIP an.

for caller in open-webui-vf mcp-whatsapp mcp-vf-hosted daily-briefing icking-rebuild receptionist; do
  aws cloudformation deploy \
    --stack-name bedrock-aip-${caller} \
    --template-file intern/capabilities/skills/bedrock-cost-optimize/templates/aip-cloudformation.yaml \
    --parameter-overrides \
        CallerName=${caller} \
        BaseModelProfile=arn:aws:bedrock:eu-central-1:ACCT:inference-profile/eu.anthropic.claude-sonnet-4-6-...  \
        Environment=production \
    --profile av-production --region eu-central-1
done

ACCT = av-production Account-ID, in _index dokumentiert.

4.2 Cost-Allocation-Tags in Billing aktivieren

Billing-Console → Cost Allocation Tags → user-defined Tags: Application, Owner, Environment aktivieren. Wirkt nicht rueckwirkend — ab dem Tag der Aktivierung zaehlt’s. Plus 24h Verzoegerung bis Cost-Explorer das anzeigt.

aws ce update-cost-allocation-tags-status \
  --cost-allocation-tags-status '[{"TagKey":"Application","Status":"Active"},{"TagKey":"Owner","Status":"Active"},{"TagKey":"Environment","Status":"Active"}]' \
  --profile av-production --region us-east-1

4.3 AIP-ARN in Caller-Code einbauen

Pro Caller das Bedrock-Modell-Argument auf die AIP-ARN umstellen. Wichtig: AIP-ARN statt System-Inference-Profile-ARN beim Call benutzen, sonst zaehlt’s nicht.

Open-WebUI VF (LiteLLM-Sidecar): model_list in der Config — model_name: claude-sonnet-4-6 mappt jetzt auf bedrock/arn:aws:bedrock:eu-central-1:ACCT:application-inference-profile/open-webui-vf. Container restart.

mcp-whatsapp Brain Lambda: Bedrock-Client-Code (brain.py oder aehnlich) — modelId Parameter auf die AIP-ARN setzen. CDK-Stack redeploy via cdk deploy mcp-whatsapp-brain.

Andere Lambdas in agents-platform: pro Lambda die modelId anpassen. Falls ein gemeinsamer Bedrock-Helper genutzt wird (siehe mcp-eigenbau-bedrock.py-Template): zentralisieren auf Env-Var BEDROCK_AIP_ARN, in jedem Lambda-Stack setzen.

icking-rebuild FastAPI: AsyncBedrockClient-Wrapper, model_id als Konfig — Param-Store oder Env-Var.

4.4 Verifizieren dass AIP wirklich getroffen wird

Nach erstem Test-Call: CloudTrail-Event-Detail anschauen, requestParameters.modelId muss die AIP-ARN enthalten.

aws cloudtrail lookup-events \
  --lookup-attributes AttributeKey=EventName,AttributeValue=InvokeModel \
  --max-results 5 \
  --profile av-production --region eu-central-1 \
  --query 'Events[].CloudTrailEvent' | jq '.[] | fromjson | .requestParameters.modelId'

Wenn da noch eu.anthropic.claude-sonnet-4-6 direkt steht und nicht die AIP-ARN: Caller-Code hat den Switch nicht gezogen.

4.5 Warten + Messen

3 Tage lang nichts aendern. Dann Cost-Explorer-Snapshot:

aws ce get-cost-and-usage \
  --time-period Start=<phase-4-deploy-date>,End=<+3 Tage> \
  --granularity DAILY \
  --metrics UnblendedCost UsageQuantity \
  --filter '{"Dimensions":{"Key":"SERVICE","Values":["Claude Sonnet 4.6 (Amazon Bedrock Edition)"]}}' \
  --group-by Type=TAG,Key=Application \
  --profile av-production --region us-east-1

→ Per-Caller-Kosten. Top-3 in caller-inventar.md aktualisieren.

Definition of Done

  • AIP pro Caller deployed (CFN-Stack pro Caller)
  • Cost-Allocation-Tags aktiviert in Billing
  • Caller-Code referenziert AIP-ARN
  • Verifizierung per CloudTrail (mind. 1 Call pro Caller mit AIP-ARN)
  • 3 Tage gemessen, Top-3-Caller mit echten Daten in caller-inventar.md

Risiken

  • AIP-Umstellung im Caller-Code = Deploy-Risiko: bei Open-WebUI lieber zuerst auf einem zweiten Environment testen (z.B. Staging-Task) bevor Production-Task umgestellt wird.
  • AIP-ARN ist account-spezifisch — wenn wir mal auf Sub-Account migrieren muessen, AIPs neu anlegen. Pattern dokumentieren im Skill-Playbook.
  • Cohere-Embeddings und Titan-Embeddings koennen aktuell nicht ueber AIP gefahren werden (nur Foundation-Model-Calls). Heisst Embedding-Costs bleiben pauschal. Aber: Embeddings sind <$3 in Mai, nicht der Hebel.