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

posta 2 anni fa2229 visualizzazioni
2 Risposte
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
con risposta 2 anni fa
  • 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
con risposta un anno fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande