- Newest
- Most votes
- Most comments
Based on the current capabilities of Amazon Textract, here's guidance for your centralized AI Hub architecture:
1. Per-Request Tagging for Cost Allocation
Unfortunately, Amazon Textract does not currently support passing custom cost allocation tags with individual API calls like AnalyzeDocument or StartDocumentAnalysis. Unlike some AWS services that support invocation-level tagging, Textract doesn't have this capability at the request level, so you cannot directly tag each call with environment or project identifiers for automatic cost segregation in AWS Cost Explorer.
2. Recommended Approaches for Cost Segregation
Since per-request tagging isn't available, here are alternative approaches:
-
CloudTrail-Based Cost Attribution: You can build a custom cost attribution system using CloudTrail logs. CloudTrail logs all Textract API calls including AnalyzeDocument, StartDocumentAnalysis, GetDocumentAnalysis, StartDocumentTextDetection, and GetDocumentTextDetection operations. These logs capture the requesting identity, timestamp, source IP address, and request parameters.
-
IAM Role-Based Tracking: The CloudTrail logs contain identity information that shows whether the request was made with root or user credentials, temporary security credentials for a role or federated user, and other identity details. This means you can identify which cross-account role (role-dev, role-staging, role-prod) made each request.
3. Using IAM Roles for Cost Differentiation
While AWS Cost Explorer won't automatically break down costs by the IAM role used in cross-account calls, you can leverage the role information from CloudTrail logs to build your own cost attribution model. The role assumption is logged, allowing you to correlate which environment made each call, but this requires post-processing rather than native cost allocation.
4. CloudTrail Logging Capabilities
Yes, CloudTrail does log the information you need:
- The cross-account role used (captured in the identity information)
- Request parameters, which would include the Adapters parameter specifying which adapter version was used
- Timestamp and other request details
Note that for privacy reasons, certain request parameters like image bytes aren't logged, but the adapter version parameter should be captured.
Building a Custom Solution
To achieve your cost segregation goals, you'll need to:
- Enable CloudTrail logging for your AI Hub account
- Parse CloudTrail logs to extract: the IAM role/identity used, the adapter version from request parameters, and the operation type and timestamp
- Correlate this with AWS Cost and Usage Reports to calculate costs per environment
- Build custom dashboards or reports that attribute costs based on the calling role and adapter version
You can also use CloudWatch metrics to monitor request counts and patterns by operation type, which can supplement your cost analysis, though this won't directly provide cost allocation by environment.
This approach requires more manual effort than native tagging support, but it will give you the detailed cost attribution you need for your centralized AI Hub architecture.
Sources
Logging Amazon Textract API Calls with AWS CloudTrail - Amazon Textract
Monitoring Amazon Textract - Amazon Textract
Relevant content
- AWS OFFICIALUpdated a year ago
