1개 답변
- 최신
- 최다 투표
- 가장 많은 댓글
0
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.
답변함 2년 전