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년 전2195회 조회
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
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠