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

gefragt vor 2 Jahren2229 Aufrufe
2 Antworten
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
beantwortet vor 2 Jahren
  • 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
beantwortet vor einem Jahr

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen