View a markdown version of this page

Cost tracking - AWS App Monetization

Cost tracking

Cost tracking shows what your application costs to run, so that you can compare its costs with its revenue and price your plans for the margin that you want. AWS App Monetization tracks two kinds of cost:

  • Infrastructure costs – Your AWS costs to run the application, by AWS service, by customer, or by day.

  • Third-party costs – Non-AWS costs that you declare for the whole application, such as a vendor API.

You view costs in the Analytics dashboard, or retrieve them with the GetAppInfraCostSummary API operation. For more information, see Infrastructure costs.

Turn on infrastructure cost tracking

Turning on infrastructure cost tracking is optional. If you don't turn it on, your app's infrastructure costs remain estimated rather than actual. For more information, see View infrastructure costs.

To turn on infrastructure cost tracking, you create an IAM role in your account and pass it to AWS App Monetization. AWS App Monetization assumes the role to create and manage an AWS Data Exports export that supplies cost data for your app. The role must meet the following requirements:

  • The role is in your AWS account and partition, and its name, after any path, starts with AppMonetizationCostTracking.

  • The role's trust policy allows the appmonetization.amazonaws.com service principal to assume it. Its conditions pin aws:SourceAccount to your account ID and aws:SourceArn to your account's apps, for example arn:aws:appmonetization:us-east-2:111122223333:apps/*. For an example trust policy, see Cross-service confused deputy prevention.

  • You have permission for iam:PassRole on the role.

For the permissions that the role needs, see Service roles for AWS App Monetization.

To pass the role, include the role ARN in the costTracking setting of a CreateApp or UpdateApp request. With UpdateApp, you can pass the role with or without changing the app's name or description.

The setup runs in the background after the request returns. Cost data starts to arrive within 24 to 48 hours. To run the setup again, for example after you change the role, call UpdateApp with the role again.

Note

If you retry a CreateApp request with the same clientToken, pass the same role. A different role, or a role added or dropped, fails with an IdempotencyConflictException.

Attribute AWS costs to customers

To attribute AWS costs to individual customers, your application reports each AWS service call that it makes on a customer's behalf with the PutAwsServiceEvent API operation. AWS App Monetization accepts the event and processes it asynchronously.

A PutAwsServiceEvent request includes the following:

  • userId – The same identifier that you use for the customer on usage events. Don't use personal data.

  • service – The AWS service that the call used.

  • operation – The AWS API operation that the call used.

  • timestamp – The time the call occurred.

  • scope – live or sandbox.

  • Optionally, quantity, awsRegion, properties, and a clientToken for safe retries.

The AWS App Monetization skill adds these calls to your application when it adds metering hooks.

View infrastructure costs

Infrastructure costs come in two types:

  • Estimated – Cost modeled from your application's usage, before actual billing is available.

  • Actual – Your billed cost. Actual costs are available only after you turn on infrastructure cost tracking.

With GetAppInfraCostSummary, you choose the cost type and a window of up to 720 hours that doesn't end in the future. You can group the results by AWS service (the default), by customer, or by UTC day, and filter them. The response includes the total cost, a row for each group, and when the summary was last updated.

Important

In Sandbox, infrastructure costs are real AWS spend, not test figures.

Add third-party costs

Third-party costs are non-AWS costs that apply to the whole application, such as an external API or a data provider. Adding them gives you, and Guided Pricing Strategy, a complete view of your unit economics.

You add and manage third-party costs with the AWS App Monetization skill or with the PutThirdPartyCost, GetThirdPartyCost, ListThirdPartyCosts, and DeleteThirdPartyCost API operations. In the console, third-party costs are read-only.

A third-party cost has the following properties:

  • Label – A name for the cost, such as Anthropic API.

  • Amount – A flat monthly amount in US dollars.

  • Description – An optional description.

  • Effective from and effective to – Optional first and last months, in YYYY-MM form, that the cost applies in.

The following rules apply:

  • To create a cost, call PutThirdPartyCost without a cost ID. To update a cost, pass its cost ID. To retry a create without creating a duplicate, pass the cost ID that the first call returned.

  • Third-party costs apply to your live app only. They don't apply in Sandbox.

  • Costs aren't prorated. To get a total, add the amounts.