Cost explorer boto3 "Charge type"

0

in Cost explorer UI there is a filter "Charge type" How could I apply the same filter using boto3?

As a reference I'm using documentation for boto3 CostExplorer.Client.get_cost_and_usage https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ce.html#CostExplorer.Client.get_cost_and_usage

I dont see anywhere in documentation filter description for "Charge type".

I tried to specify { "Not": { 'Dimensions': { 'Key': 'CHARGE_TYPE', 'Values': ['Refund'] } } }

but received an error:

botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the GetCostAndUsage operation: Dimension CHARGE_TYPE is not allowed. Allowed dimension(s): SAVINGS_PLAN_ARN, RESERVATION_ID, AZ, CACHE_ENGINE, INSTANCE_TYPE_FAMILY, INSTANCE_TYPE, SAVINGS_PLANS_TYPE, PURCHASE_TYPE, INVOICING_ENTITY, LINKED_ACCOUNT, REGION, SERVICE, LEGAL_ENTITY_NAME, USAGE_TYPE, PLATFORM, USAGE_TYPE_GROUP, OPERATION, OPERATING_SYSTEM, DATABASE_ENGINE, TENANCY, BILLING_ENTITY, RECORD_TYPE, DEPLOYMENT_OPTION

已提問 2 年前檢視次數 2198 次
2 個答案
3

There is a description of each of the dimensions located here: https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/API_GetDimensionValues.html

You are looking for RECORD_TYPE.

AWS
已回答 2 年前
  • Hi Geno_E, thank you this is relly useful

  • So we can't use charge type in boto3 or through cost explorer api ?.

    If yes , can you provide any documentation?

0

Correct keyword to use Charge Type in boto3 is using RECORD_TYPE. For more info, click here

Example:-

Filter={
        "Not":
        {
            'Dimensions':{
            'Key': 'RECORD_TYPE',
            'Values':['Credit','Refund']
             }
        }
    },

Add the above code to your get_cost_and_usage() function and you can exclude credits.

profile picture
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南