Budget does not show actual spend

0

I am trying out AWS Budget, but it does not show the actual spend correctly.

I have created the budget 3 days ago and set it to monitor resources with certain tags. However, the calculated actual spend is still at 0.0, even though I can clearly see (in cost explorer) that the spend is already higher. I have also tried checking the calculated spend through AWS CLI "describe-budget" operation with the same result.

In the console, I am clicking through to cost explorer using the link in the "budget history", therefore I am pretty sure I am viewing the correct data.

The budget shows it was refreshed this morning, so it definitely should register the spend.


EDIT: Ok so I was doing some additional testing.

  • The original budget (that shows incorrect actual spend), I have created using Cloudformation.
  • Now I have created exactly the same budget, but using console. The budget created in console shows correct actual spend.
  • However, the Cloudformation created budget still shows 0.0.

I do not know what the heck is going on. Why do 2 completely same budgets show different actual spends is beyond me. We need to create our budgets as a part of our automation process, therefore the Cloudformation version needs to work as well.

describe-budget output for Cloudformation created:

{
    "Budget": {
        "BudgetName": "StpSimpPimpBudgetingBudget-eu-west-1-1641575151342-uuJMy1qaNeii",
        "BudgetLimit": {
            "Amount": "10.0",
            "Unit": "USD"
        },
        "CostFilters": {
            "TagKeyValue": [
                "stp:globally-unique-stack-hash$7a66815"
            ]
        },
        "CostTypes": {
            "IncludeTax": true,
            "IncludeSubscription": true,
            "UseBlended": false,
            "IncludeRefund": false,
            "IncludeCredit": false,
            "IncludeUpfront": true,
            "IncludeRecurring": true,
            "IncludeOtherSubscription": true,
            "IncludeSupport": true,
            "IncludeDiscount": true,
            "UseAmortized": false
        },
        "TimeUnit": "MONTHLY",
        "TimePeriod": {
            "Start": 1640995200.0,
            "End": 3706473600.0
        },
        "CalculatedSpend": {
            "ActualSpend": {
                "Amount": "0.0",
                "Unit": "USD"
            }
        },
        "BudgetType": "COST",
        "LastUpdatedTime": 1641742182.59
    }
}

describe-budget output for CONSOLE created:

{
    "Budget": {
        "BudgetName": "testbudget",
        "BudgetLimit": {
            "Amount": "10.0",
            "Unit": "USD"
        },
        "CostFilters": {
            "TagKeyValue": [
                "user:stp:globally-unique-stack-hash$7a66815"
            ]
        },
        "CostTypes": {
            "IncludeTax": true,
            "IncludeSubscription": true,
            "UseBlended": false,
            "IncludeRefund": false,
            "IncludeCredit": false,
            "IncludeUpfront": true,
            "IncludeRecurring": true,
            "IncludeOtherSubscription": true,
            "IncludeSupport": true,
            "IncludeDiscount": true,
            "UseAmortized": false
        },
        "TimeUnit": "MONTHLY",
        "TimePeriod": {
            "Start": 1640995200.0,
            "End": 3706473600.0
        },
        "CalculatedSpend": {
            "ActualSpend": {
                "Amount": "0.856",
                "Unit": "USD"
            }
        },
        "BudgetType": "COST",
        "LastUpdatedTime": 1641742039.652
    }
}
simon
asked 2 years ago442 views
1 Answer
0
Accepted Answer

I have resolved this issue with the help of support. I did not notice that when using user defined cost allocation tags you need to use "user" prefix. Full answer from support

From the case notes, I understand that you have created a budget using Cloudformation. The budget resource is created successfully with the CostFilters set to a tag value. However, you noticed that this budget shows the spend to be $ 0.0. Furthermore, you have a similar budget created directly from the console, which is showing the budget spends accurately. You therefore wish to understand why the budget created by cloudformation is showing inaccurate spend data.

Please let me know if I have captured your issue absolutely and kindly add on to anything I may have missed out.

Upon checking the cloudformation stack, I noticed that you are providing the following Key$Value pair to your COST [1] budget: 

“stp:globally-unique-stack-hash$7a66815”

Upon replicating a similar scenario within my AWS Environment I found the same behaviour. When created via the Console - as a sanity check - the Tag Dimension, maps directly to Tag/Value pairs. Similarly with CloudFormation I deployed the following resource and found that my key pair values were not honoured:

=================================

  Budget:
    Type: AWS::Budgets::Budget
    Properties: 
      Budget:
        TimeUnit: DAILY
        BudgetType: COST
        BudgetLimit: 
          Amount: 1600
          Unit: USD
        CostFilters: 
          TagKeyValue:
            - 'auto-delete$no'

=================================

Upon investigating this further, I found that with Cost Allocation Tags, AWS provides two types. AWS generated tags and user-defined tags [2]. Essentially, AWS generated tags are Tags propagated through resources such as Stack ID's and AutoScaling Group names. While User generated Tags are the everyday key value tag pairs we use. 

The formats are as follows:

=============================================================

Format for AWS Generated:
aws:cloudformation:logical-id$bucketCloudTrail

Format for User Generated:
user:Name$Value

Note null values can also be used for keys 

=============================================================

As your “stp:globally-unique-stack-hash$7a66815” KeyValue pair is user defined, similarly to the method used to create a budget via the CLI, see here [3]. You should include that these are "user" defined tags like so:

=============================================================

AWSTemplateFormatVersion: 2010-09-09
Resources:
  Budget:
    Type: 'AWS::Budgets::Budget'
    Properties:
      Budget:
        TimeUnit: DAILY
        BudgetType: COST
        BudgetLimit:
          Amount: 1600
          Unit: USD
        CostFilters:
          TagKeyValue:
            - 'user:stp:globally-unique-stack-hash$7a66815'

=============================================================

This differs from the behaviour when creating a budget via the Management Console as CloudFormation interacts with each services API directly. The Console allows Users to trigger multiple API actions in a more friendly way. You can also confirm this by looking at the output of the  describe-budget call that you performed to the budget created by the console, the output of which is like so:

==============
 "CostFilters": {
            "TagKeyValue": [
                "user:stp:globally-unique-stack-hash$7a66815"
            ]
        },
==============

The reason you're able to deploy the resource with no errors is because CloudFormation will validate the parameter to confirm if the JSON is valid and if so proceed with the update. In this case it does not validate if the TagKeyValue is an AWS or User defined CostFilter.

As a result of this I have created a raised an internal ticket to our team responsible for CloudFormation. Specifically, the CostFilters section of the BudgetData page on the Budgets CloudFormation documentation could reflect this information. Unfortunately, I am unable to provide an ETA as to when or if this documentation will be updated however rest assured, I have added your voice to this request on your behalf. 
simon
answered 2 years ago
profile picture
EXPERT
reviewed 9 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions