This article discusses critical FinOps strategies for managing and attributing AI/ML inference costs on AWS, particularly with services like Bedrock. It highlights the challenges of unpredictable AI model costs and the necessity of robust cost attribution using IAM role tagging and policy enforcement. The core components include SQL queries for identifying untagged spend, OPA/Rego policies for preventing anonymous role creation, and leveraging AWS Budgets for proactive cost control.
Read original on The New StackManaging costs for AI/ML inference, especially with services like AWS Bedrock, presents unique challenges. Unlike traditional compute, AI model usage can be highly unpredictable, with repeated runs of the same task differing significantly in token consumption and cost. This makes forecasting difficult and reactive attribution the primary control mechanism. When multiple AI agents share an IAM role, attributing specific spend to a responsible entity becomes even more complex, akin to a communal corporate credit card without individual accountability. The article emphasizes that FinOps principles are crucial for bringing visibility and control to these emergent costs.
The article proposes a multi-pronged approach to address AI cost attribution on AWS, focusing on identification, prevention, and proactive budgeting.
Key FinOps Principle
The article highlights that "If neither the task nor the model can say what a run will cost, budgets become aspirational. Attribution after the fact is the only control left." This underscores the importance of granular cost allocation tags and strong governance in dynamic cloud environments, particularly for AI/ML workloads.
deny contains msg if { some rc in resource_changes principal_types[rc.type] writes(rc) not owner_of(rc) msg := sprintf("%s: IAM identity needs an owner tag so its spend has a name", [rc.address]) } deny contains msg if { some rc in resource_changes principal_types[rc.type] writes(rc) o := owner_of(rc) not regex.match(email_pattern, sprintf("%v", [o])) msg := sprintf("%s: owner must be a person's email, got %v", [rc.address, o]) }This Rego snippet demonstrates how to enforce the presence and format of an `owner` tag on IAM roles and users during Terraform plan evaluation. This policy is critical for integrating cost accountability directly into the CI/CD pipeline, ensuring that resources are properly tagged before deployment.