AWS Cost Explorer Service

2018/02/22 - AWS Cost Explorer Service - 1 new 3 updated api methods

Changes  Added GetReservationCoverage API for retrieving reservation coverage information.

GetReservationCoverage (new) Link ¶

Retrieve the reservation coverage for your account. An organization's master account has access to the associated member accounts. For any time period, you can filter data about reservation usage by the following dimensions.

  • AZ

  • INSTANCE_TYPE

  • LINKED_ACCOUNT

  • PLATFORM

  • REGION

  • TENANCY

To determine valid values for a dimension, use the GetDimensionValues operation.

See also: AWS API Documentation

Request Syntax

client.get_reservation_coverage(
    TimePeriod={
        'Start': 'string',
        'End': 'string'
    },
    GroupBy=[
        {
            'Type': 'DIMENSION'|'TAG',
            'Key': 'string'
        },
    ],
    Granularity='DAILY'|'MONTHLY',
    Filter={
        'Or': [
            {'... recursive ...'},
        ],
        'And': [
            {'... recursive ...'},
        ],
        'Not': {'... recursive ...'},
        'Dimensions': {
            'Key': 'AZ'|'INSTANCE_TYPE'|'LINKED_ACCOUNT'|'OPERATION'|'PURCHASE_TYPE'|'REGION'|'SERVICE'|'USAGE_TYPE'|'USAGE_TYPE_GROUP'|'RECORD_TYPE'|'OPERATING_SYSTEM'|'TENANCY'|'SCOPE'|'PLATFORM'|'SUBSCRIPTION_ID'|'LEGAL_ENTITY_NAME'|'DEPLOYMENT_OPTION'|'DATABASE_ENGINE'|'CACHE_ENGINE'|'INSTANCE_TYPE_FAMILY',
            'Values': [
                'string',
            ]
        },
        'Tags': {
            'Key': 'string',
            'Values': [
                'string',
            ]
        }
    },
    NextPageToken='string'
)
type TimePeriod

dict

param TimePeriod

[REQUIRED]

The start and end dates of the period for which you want to retrieve data about reservation coverage. You can retrieve data for a maximum of 13 months-the last 12 months and the current month. The start date is inclusive, but the end date is exclusive. For example, if start is 2017-01-01 and end is 2017-05-01 , then the cost and usage data is retrieved from 2017-01-01 up to and including 2017-04-30 but not including 2017-05-01 .

  • Start (string) -- [REQUIRED]

    The beginning of the time period that you want the usage and costs for. The start date is inclusive. For example, if start is 2017-01-01 , then the cost and usage data is retrieved starting at 2017-01-01 up to the end date.

  • End (string) -- [REQUIRED]

    The end of the time period that you want the usage and costs for. The end date is exclusive. For example, if the end is 2017-05-01 , then the cost and usage data is retrieved from the start date but not including 2017-05-01 .

type GroupBy

list

param GroupBy

You can group the data by the following attributes.

  • AZ

  • INSTANCE_TYPE

  • LINKED_ACCOUNT

  • PLATFORM

  • REGION

  • TENANCY

  • (dict) --

    Represents a group when you specify a group by criteria, or in the response to a query with a specific grouping.

    • Type (string) --

      The string that represents the type of group.

    • Key (string) --

      The string that represents a key for a specified group.

type Granularity

string

param Granularity

The granularity of the AWS cost data for the reservation. Valid values are MONTHLY and DAILY .

If GroupBy is set, Granularity can't be set. If Granularity isn't set, the response object doesn't include the Granularity , either MONTHLY or DAILY .

type Filter

dict

param Filter

Filters utilization data by dimensions. You can filter by the following dimensions.

  • AZ

  • INSTANCE_TYPE

  • LINKED_ACCOUNT

  • PLATFORM

  • REGION

  • TENANCY

GetReservationCoverage uses the same Expression object as the other operations, but only AND is supported among each dimension. You can nest only one level deep. If there are multiple values for a dimension, they are OR'd together.

  • Or (list) --

    Return results that match either Dimension .

    • (dict) --

      Use Expression to filter by cost or by usage. There are two patterns:

      • Simple dimension values - You can set the dimension name and values for the filters that you plan to use. For example, you can filter for INSTANCE_TYPE==m4.xlarge OR INSTANCE_TYPE==c4.large . The Expression for that looks like this. { "Dimensions": { "Key": "INSTANCE_TYPE", "Values": [ "m4.xlarge", “c4.large” ] } } The list of dimension values are OR'd together to retrieve cost or usage data. You can create Expression and DimensionValues objects using either with* methods or set* methods in multiple lines.

      • Compound dimension values with logical operations - You can use multiple Expression types and the logical operators AND/OR/NOT to create a list of one or more Expression objects. This allows you to filter on more advanced options. For example, you can filter on ((INSTANCE_TYPE == m4.large OR INSTANCE_TYPE == m3.large) OR (TAG.Type == Type1)) AND (USAGE_TYPE != DataTransfer) . The Expression for that looks like this. { "And": [ {"Or": [ {"Dimensions": { "Key": "INSTANCE_TYPE", "Values": [ "m4.x.large", "c4.large" ] }}, {"Tag": { "Key": "TagName", "Values": ["Value1"] } } ]}, {"Not": {"dimensions": { "Key": "USAGE_TYPE", "Values": ["DataTransfer"] }}} ] }

      Note

      Because each Expression can have only one operator, the service returns an error if more than one is specified. The following example shows an Expression object that will create an error.

      { "And": [ ... ], "DimensionValues": { "Dimension": "USAGE_TYPE", "Values": [ "DataTransfer" ] } }

  • And (list) --

    Return results that match both Dimension objects.

    • (dict) --

      Use Expression to filter by cost or by usage. There are two patterns:

      • Simple dimension values - You can set the dimension name and values for the filters that you plan to use. For example, you can filter for INSTANCE_TYPE==m4.xlarge OR INSTANCE_TYPE==c4.large . The Expression for that looks like this. { "Dimensions": { "Key": "INSTANCE_TYPE", "Values": [ "m4.xlarge", “c4.large” ] } } The list of dimension values are OR'd together to retrieve cost or usage data. You can create Expression and DimensionValues objects using either with* methods or set* methods in multiple lines.

      • Compound dimension values with logical operations - You can use multiple Expression types and the logical operators AND/OR/NOT to create a list of one or more Expression objects. This allows you to filter on more advanced options. For example, you can filter on ((INSTANCE_TYPE == m4.large OR INSTANCE_TYPE == m3.large) OR (TAG.Type == Type1)) AND (USAGE_TYPE != DataTransfer) . The Expression for that looks like this. { "And": [ {"Or": [ {"Dimensions": { "Key": "INSTANCE_TYPE", "Values": [ "m4.x.large", "c4.large" ] }}, {"Tag": { "Key": "TagName", "Values": ["Value1"] } } ]}, {"Not": {"dimensions": { "Key": "USAGE_TYPE", "Values": ["DataTransfer"] }}} ] }

      Note

      Because each Expression can have only one operator, the service returns an error if more than one is specified. The following example shows an Expression object that will create an error.

      { "And": [ ... ], "DimensionValues": { "Dimension": "USAGE_TYPE", "Values": [ "DataTransfer" ] } }

  • Not (dict) --

    Return results that don't match Dimension .

  • Dimensions (dict) --

    The specific Dimension to use for Expression .

    • Key (string) --

      The names of the metadata types that you can use to filter and group your results. For example, AZ returns a list of Availability Zones.

    • Values (list) --

      The metadata values that you can use to filter and group your results. You can use GetDimensionValues to find specific values.

      • (string) --

  • Tags (dict) --

    The specific Tag to use for Expression .

    • Key (string) --

      The key for a tag.

    • Values (list) --

      The specific value of a tag.

      • (string) --

type NextPageToken

string

param NextPageToken

The token to retrieve the next set of results. AWS provides the token when the response from a previous call has more results than the maximum page size.

rtype

dict

returns

Response Syntax

{
    'CoveragesByTime': [
        {
            'TimePeriod': {
                'Start': 'string',
                'End': 'string'
            },
            'Groups': [
                {
                    'Attributes': {
                        'string': 'string'
                    },
                    'Coverage': {
                        'CoverageHours': {
                            'OnDemandHours': 'string',
                            'ReservedHours': 'string',
                            'TotalRunningHours': 'string',
                            'CoverageHoursPercentage': 'string'
                        }
                    }
                },
            ],
            'Total': {
                'CoverageHours': {
                    'OnDemandHours': 'string',
                    'ReservedHours': 'string',
                    'TotalRunningHours': 'string',
                    'CoverageHoursPercentage': 'string'
                }
            }
        },
    ],
    'Total': {
        'CoverageHours': {
            'OnDemandHours': 'string',
            'ReservedHours': 'string',
            'TotalRunningHours': 'string',
            'CoverageHoursPercentage': 'string'
        }
    },
    'NextPageToken': 'string'
}

Response Structure

  • (dict) --

    • CoveragesByTime (list) --

      The amount of time that your reservations covered.

      • (dict) --

        Reservation coverage, in hours.

        • TimePeriod (dict) --

          The period over which this coverage was used.

          • Start (string) --

            The beginning of the time period that you want the usage and costs for. The start date is inclusive. For example, if start is 2017-01-01 , then the cost and usage data is retrieved starting at 2017-01-01 up to the end date.

          • End (string) --

            The end of the time period that you want the usage and costs for. The end date is exclusive. For example, if the end is 2017-05-01 , then the cost and usage data is retrieved from the start date but not including 2017-05-01 .

        • Groups (list) --

          The group of instances that a reservation covered.

          • (dict) --

            A group of reservations that share a set of attributes.

            • Attributes (dict) --

              The attributes for this group of reservations.

              • (string) --

                • (string) --

            • Coverage (dict) --

              How much instance usage this group of reservations covered.

              • CoverageHours (dict) --

                The amount of instance usage that a reservation covered, in hours.

                • OnDemandHours (string) --

                  The number of instance running hours covered by On-Demand Instances.

                • ReservedHours (string) --

                  The number of instance running hours covered by reservations.

                • TotalRunningHours (string) --

                  The total instance usage, in hours.

                • CoverageHoursPercentage (string) --

                  The percentage of instance hours covered by a reservation.

        • Total (dict) --

          The total reservation coverage, in hours.

          • CoverageHours (dict) --

            The amount of instance usage that a reservation covered, in hours.

            • OnDemandHours (string) --

              The number of instance running hours covered by On-Demand Instances.

            • ReservedHours (string) --

              The number of instance running hours covered by reservations.

            • TotalRunningHours (string) --

              The total instance usage, in hours.

            • CoverageHoursPercentage (string) --

              The percentage of instance hours covered by a reservation.

    • Total (dict) --

      The total amount of instance usage covered by a reservation.

      • CoverageHours (dict) --

        The amount of instance usage that a reservation covered, in hours.

        • OnDemandHours (string) --

          The number of instance running hours covered by On-Demand Instances.

        • ReservedHours (string) --

          The number of instance running hours covered by reservations.

        • TotalRunningHours (string) --

          The total instance usage, in hours.

        • CoverageHoursPercentage (string) --

          The percentage of instance hours covered by a reservation.

    • NextPageToken (string) --

      The token for the next set of retrievable results. AWS provides the token when the response from a previous call has more results than the maximum page size.

GetCostAndUsage (updated) Link ¶
Changes (request)
{'Filter': {'Dimensions': {'Key': {'CACHE_ENGINE',
                                   'DATABASE_ENGINE',
                                   'DEPLOYMENT_OPTION',
                                   'INSTANCE_TYPE_FAMILY',
                                   'LEGAL_ENTITY_NAME'}}}}

Retrieve cost and usage metrics for your account. You can specify which cost and usage-related metric, such as BlendedCosts or UsageQuantity , that you want the request to return. You can also filter and group your data by various dimensions, such as SERVICE or AZ , in a specific time range. See the GetDimensionValues action for a complete list of the valid dimensions. Master accounts in an organization have access to all member accounts.

See also: AWS API Documentation

Request Syntax

client.get_cost_and_usage(
    TimePeriod={
        'Start': 'string',
        'End': 'string'
    },
    Granularity='DAILY'|'MONTHLY',
    Filter={
        'Or': [
            {'... recursive ...'},
        ],
        'And': [
            {'... recursive ...'},
        ],
        'Not': {'... recursive ...'},
        'Dimensions': {
            'Key': 'AZ'|'INSTANCE_TYPE'|'LINKED_ACCOUNT'|'OPERATION'|'PURCHASE_TYPE'|'REGION'|'SERVICE'|'USAGE_TYPE'|'USAGE_TYPE_GROUP'|'RECORD_TYPE'|'OPERATING_SYSTEM'|'TENANCY'|'SCOPE'|'PLATFORM'|'SUBSCRIPTION_ID'|'LEGAL_ENTITY_NAME'|'DEPLOYMENT_OPTION'|'DATABASE_ENGINE'|'CACHE_ENGINE'|'INSTANCE_TYPE_FAMILY',
            'Values': [
                'string',
            ]
        },
        'Tags': {
            'Key': 'string',
            'Values': [
                'string',
            ]
        }
    },
    Metrics=[
        'string',
    ],
    GroupBy=[
        {
            'Type': 'DIMENSION'|'TAG',
            'Key': 'string'
        },
    ],
    NextPageToken='string'
)
type TimePeriod

dict

param TimePeriod

Sets the start and end dates for retrieving AWS costs. The start date is inclusive, but the end date is exclusive. For example, if start is 2017-01-01 and end is 2017-05-01 , then the cost and usage data is retrieved from 2017-01-01 up to and including 2017-04-30 but not including 2017-05-01 .

  • Start (string) -- [REQUIRED]

    The beginning of the time period that you want the usage and costs for. The start date is inclusive. For example, if start is 2017-01-01 , then the cost and usage data is retrieved starting at 2017-01-01 up to the end date.

  • End (string) -- [REQUIRED]

    The end of the time period that you want the usage and costs for. The end date is exclusive. For example, if the end is 2017-05-01 , then the cost and usage data is retrieved from the start date but not including 2017-05-01 .

type Granularity

string

param Granularity

Sets the AWS cost granularity to MONTHLY or DAILY . If Granularity isn't set, the response object doesn't include the Granularity , either MONTHLY or DAILY .

type Filter

dict

param Filter

Filters AWS costs by different dimensions. For example, you can specify SERVICE and LINKED_ACCOUNT and get the costs associated with that account's usage of that service. You can nest Expression objects to define any combination of dimension filters. For more information, see Expression.

  • Or (list) --

    Return results that match either Dimension .

    • (dict) --

      Use Expression to filter by cost or by usage. There are two patterns:

      • Simple dimension values - You can set the dimension name and values for the filters that you plan to use. For example, you can filter for INSTANCE_TYPE==m4.xlarge OR INSTANCE_TYPE==c4.large . The Expression for that looks like this. { "Dimensions": { "Key": "INSTANCE_TYPE", "Values": [ "m4.xlarge", “c4.large” ] } } The list of dimension values are OR'd together to retrieve cost or usage data. You can create Expression and DimensionValues objects using either with* methods or set* methods in multiple lines.

      • Compound dimension values with logical operations - You can use multiple Expression types and the logical operators AND/OR/NOT to create a list of one or more Expression objects. This allows you to filter on more advanced options. For example, you can filter on ((INSTANCE_TYPE == m4.large OR INSTANCE_TYPE == m3.large) OR (TAG.Type == Type1)) AND (USAGE_TYPE != DataTransfer) . The Expression for that looks like this. { "And": [ {"Or": [ {"Dimensions": { "Key": "INSTANCE_TYPE", "Values": [ "m4.x.large", "c4.large" ] }}, {"Tag": { "Key": "TagName", "Values": ["Value1"] } } ]}, {"Not": {"dimensions": { "Key": "USAGE_TYPE", "Values": ["DataTransfer"] }}} ] }

      Note

      Because each Expression can have only one operator, the service returns an error if more than one is specified. The following example shows an Expression object that will create an error.

      { "And": [ ... ], "DimensionValues": { "Dimension": "USAGE_TYPE", "Values": [ "DataTransfer" ] } }

  • And (list) --

    Return results that match both Dimension objects.

    • (dict) --

      Use Expression to filter by cost or by usage. There are two patterns:

      • Simple dimension values - You can set the dimension name and values for the filters that you plan to use. For example, you can filter for INSTANCE_TYPE==m4.xlarge OR INSTANCE_TYPE==c4.large . The Expression for that looks like this. { "Dimensions": { "Key": "INSTANCE_TYPE", "Values": [ "m4.xlarge", “c4.large” ] } } The list of dimension values are OR'd together to retrieve cost or usage data. You can create Expression and DimensionValues objects using either with* methods or set* methods in multiple lines.

      • Compound dimension values with logical operations - You can use multiple Expression types and the logical operators AND/OR/NOT to create a list of one or more Expression objects. This allows you to filter on more advanced options. For example, you can filter on ((INSTANCE_TYPE == m4.large OR INSTANCE_TYPE == m3.large) OR (TAG.Type == Type1)) AND (USAGE_TYPE != DataTransfer) . The Expression for that looks like this. { "And": [ {"Or": [ {"Dimensions": { "Key": "INSTANCE_TYPE", "Values": [ "m4.x.large", "c4.large" ] }}, {"Tag": { "Key": "TagName", "Values": ["Value1"] } } ]}, {"Not": {"dimensions": { "Key": "USAGE_TYPE", "Values": ["DataTransfer"] }}} ] }

      Note

      Because each Expression can have only one operator, the service returns an error if more than one is specified. The following example shows an Expression object that will create an error.

      { "And": [ ... ], "DimensionValues": { "Dimension": "USAGE_TYPE", "Values": [ "DataTransfer" ] } }

  • Not (dict) --

    Return results that don't match Dimension .

  • Dimensions (dict) --

    The specific Dimension to use for Expression .

    • Key (string) --

      The names of the metadata types that you can use to filter and group your results. For example, AZ returns a list of Availability Zones.

    • Values (list) --

      The metadata values that you can use to filter and group your results. You can use GetDimensionValues to find specific values.

      • (string) --

  • Tags (dict) --

    The specific Tag to use for Expression .

    • Key (string) --

      The key for a tag.

    • Values (list) --

      The specific value of a tag.

      • (string) --

type Metrics

list

param Metrics

Which metrics are returned in the query. For more information about blended and unblended rates, see Why does the "blended" annotation appear on some line items in my bill?.

Valid values are BlendedCost , UnblendedCost , and UsageQuantity .

Note

If you return the UsageQuantity metric, the service aggregates all usage numbers without taking into account the units. For example, if you aggregate usageQuantity across all of EC2, the results aren't meaningful because EC2 compute hours and data transfer are measured in different units (for example, hours vs. GB). To get more meaningful UsageQuantity metrics, filter by UsageType or UsageTypeGroups .

  • (string) --

type GroupBy

list

param GroupBy

You can group AWS costs using up to two different groups, either dimensions, tag keys, or both.

When you group by tag key, you get all tag values, including empty strings.

Valid values are AZ , INSTANCE_TYPE , LINKED_ACCOUNT , OPERATION , PLATFORM , PURCHASE_TYPE , SERVICE , TAGS , TENANCY , and USAGE_TYPE .

  • (dict) --

    Represents a group when you specify a group by criteria, or in the response to a query with a specific grouping.

    • Type (string) --

      The string that represents the type of group.

    • Key (string) --

      The string that represents a key for a specified group.

type NextPageToken

string

param NextPageToken

The token to retrieve the next set of results. AWS provides the token when the response from a previous call has more results than the maximum page size.

rtype

dict

returns

Response Syntax

{
    'NextPageToken': 'string',
    'GroupDefinitions': [
        {
            'Type': 'DIMENSION'|'TAG',
            'Key': 'string'
        },
    ],
    'ResultsByTime': [
        {
            'TimePeriod': {
                'Start': 'string',
                'End': 'string'
            },
            'Total': {
                'string': {
                    'Amount': 'string',
                    'Unit': 'string'
                }
            },
            'Groups': [
                {
                    'Keys': [
                        'string',
                    ],
                    'Metrics': {
                        'string': {
                            'Amount': 'string',
                            'Unit': 'string'
                        }
                    }
                },
            ],
            'Estimated': True|False
        },
    ]
}

Response Structure

  • (dict) --

    • NextPageToken (string) --

      The token for the next set of retrievable results. AWS provides the token when the response from a previous call has more results than the maximum page size.

    • GroupDefinitions (list) --

      The groups specified by the the Filter or GroupBy parameters in the request.

      • (dict) --

        Represents a group when you specify a group by criteria, or in the response to a query with a specific grouping.

        • Type (string) --

          The string that represents the type of group.

        • Key (string) --

          The string that represents a key for a specified group.

    • ResultsByTime (list) --

      The time period covered by the results in the response.

      • (dict) --

        The result that is associated with a time period.

        • TimePeriod (dict) --

          The time period covered by a result.

          • Start (string) --

            The beginning of the time period that you want the usage and costs for. The start date is inclusive. For example, if start is 2017-01-01 , then the cost and usage data is retrieved starting at 2017-01-01 up to the end date.

          • End (string) --

            The end of the time period that you want the usage and costs for. The end date is exclusive. For example, if the end is 2017-05-01 , then the cost and usage data is retrieved from the start date but not including 2017-05-01 .

        • Total (dict) --

          The total amount of cost or usage accrued during the time period.

          • (string) --

            • (dict) --

              The aggregated value for a metric.

              • Amount (string) --

                The actual number that represents the metric.

              • Unit (string) --

                The unit that the metric is given in.

        • Groups (list) --

          The groups that are included in this time period.

          • (dict) --

            One level of grouped data within the results.

            • Keys (list) --

              The keys included in this group.

              • (string) --

            • Metrics (dict) --

              The metrics included in this group.

              • (string) --

                • (dict) --

                  The aggregated value for a metric.

                  • Amount (string) --

                    The actual number that represents the metric.

                  • Unit (string) --

                    The unit that the metric is given in.

        • Estimated (boolean) --

          Whether or not this result is estimated.

GetDimensionValues (updated) Link ¶
Changes (request)
{'Dimension': {'CACHE_ENGINE',
               'DATABASE_ENGINE',
               'DEPLOYMENT_OPTION',
               'INSTANCE_TYPE_FAMILY',
               'LEGAL_ENTITY_NAME'}}

You can use GetDimensionValues to retrieve all available filter values for a specific filter over a period of time. You can search the dimension values for an arbitrary string.

See also: AWS API Documentation

Request Syntax

client.get_dimension_values(
    SearchString='string',
    TimePeriod={
        'Start': 'string',
        'End': 'string'
    },
    Dimension='AZ'|'INSTANCE_TYPE'|'LINKED_ACCOUNT'|'OPERATION'|'PURCHASE_TYPE'|'REGION'|'SERVICE'|'USAGE_TYPE'|'USAGE_TYPE_GROUP'|'RECORD_TYPE'|'OPERATING_SYSTEM'|'TENANCY'|'SCOPE'|'PLATFORM'|'SUBSCRIPTION_ID'|'LEGAL_ENTITY_NAME'|'DEPLOYMENT_OPTION'|'DATABASE_ENGINE'|'CACHE_ENGINE'|'INSTANCE_TYPE_FAMILY',
    Context='COST_AND_USAGE'|'RESERVATIONS',
    NextPageToken='string'
)
type SearchString

string

param SearchString

The value that you want to search the filter values for.

type TimePeriod

dict

param TimePeriod

[REQUIRED]

The start and end dates for retrieving the dimension values. The start date is inclusive, but the end date is exclusive. For example, if start is 2017-01-01 and end is 2017-05-01 , then the cost and usage data is retrieved from 2017-01-01 up to and including 2017-04-30 but not including 2017-05-01 .

  • Start (string) -- [REQUIRED]

    The beginning of the time period that you want the usage and costs for. The start date is inclusive. For example, if start is 2017-01-01 , then the cost and usage data is retrieved starting at 2017-01-01 up to the end date.

  • End (string) -- [REQUIRED]

    The end of the time period that you want the usage and costs for. The end date is exclusive. For example, if the end is 2017-05-01 , then the cost and usage data is retrieved from the start date but not including 2017-05-01 .

type Dimension

string

param Dimension

[REQUIRED]

The name of the dimension. Each Dimensions is available for different a Context . For more information, see Context .

type Context

string

param Context

The context for the call to GetDimensionValues . This can be RESERVATIONS or COST_AND_USAGE . The default value is COST_AND_USAGE . If the context is set to RESERVATIONS , the resulting dimension values can be used in the GetReservationUtilization action. If the context is set to COST_AND_USAGE , the resulting dimension values can be used in the GetCostAndUsage operation.

If you set the context to CostAndUsage , you can use the following dimensions for searching:

  • AZ - The Availability Zone. An example is us-east-1a.

  • INSTANCE_TYPE - The type of EC2 instance. An example is m4.xlarge.

  • LINKED_ACCOUNT - The description in the attribute map that includes the full name of the member account. The value field contains the AWS ID of the member account

  • OPERATION - The action performed. Examples include RunInstance and CreateBucket.

  • PURCHASE_TYPE - The reservation type of the purchase to which this usage is related. Examples include: On Demand Instances and Standard Reserved Instances

  • SERVICE - The AWS service such as DynamoDB.

  • USAGE_TYPE - The type of usage. An example is DataTransfer-In-Bytes. The response for the GetDimensionValues action includes a unit attribute, examples of which include GB and Hrs.

  • USAGE_TYPE_GROUP - The grouping of common usage types. An example is EC2: CloudWatch – Alarms. The response for this action includes a unit attribute.

  • RECORD_TYPE - The different types of charges such as RI fees, usage costs, tax refunds, and credits.

If you set the context to RESERVATIONS , you can use the following dimensions for searching:

  • AZ - The Availability Zone. An example is us-east-1a.

  • INSTANCE_TYPE - The type of EC2 instance. An example is m4.xlarge.

  • LINKED_ACCOUNT - The description in the attribute map that includes the full name of the member account. The value field contains the AWS ID of the member account

  • PLATFORM - The operating system. Examples are Windows or Linux.

  • REGION - The AWS region.

  • SCOPE - The scope of a reserved instance (RI). Values are regional or a single availability zone.

  • TENANCY - The tenancy of a resource. Examples are shared or dedicated.

type NextPageToken

string

param NextPageToken

The token to retrieve the next set of results. AWS provides the token when the response from a previous call has more results than the maximum page size.

rtype

dict

returns

Response Syntax

{
    'DimensionValues': [
        {
            'Value': 'string',
            'Attributes': {
                'string': 'string'
            }
        },
    ],
    'ReturnSize': 123,
    'TotalSize': 123,
    'NextPageToken': 'string'
}

Response Structure

  • (dict) --

    • DimensionValues (list) --

      The filters that you used to filter your request. Some dimensions are available only for a specific context:

      If you set the context to CostAndUsage , you can use the following dimensions for searching:

      • AZ - The Availability Zone. An example is us-east-1a.

      • INSTANCE_TYPE - The type of EC2 instance. An example is m4.xlarge.

      • LINKED_ACCOUNT - The description in the attribute map that includes the full name of the member account. The value field contains the AWS ID of the member account

      • OPERATION - The action performed. Examples include RunInstance and CreateBucket.

      • PURCHASE_TYPE - The reservation type of the purchase to which this usage is related. Examples include: On Demand Instances and Standard Reserved Instances

      • SERVICE - The AWS service such as DynamoDB.

      • USAGE_TYPE - The type of usage. An example is DataTransfer-In-Bytes. The response for the GetDimensionValues action includes a unit attribute, examples of which include GB and Hrs.

      • USAGE_TYPE_GROUP - The grouping of common usage types. An example is EC2: CloudWatch – Alarms. The response for this action includes a unit attribute.

      • RECORD_TYPE - The different types of charges such as RI fees, usage costs, tax refunds, and credits.

      If you set the context to RESERVATIONS , you can use the following dimensions for searching:

      • AZ - The Availability Zone. An example is us-east-1a.

      • INSTANCE_TYPE - The type of EC2 instance. An example is m4.xlarge.

      • LINKED_ACCOUNT - The description in the attribute map that includes the full name of the member account. The value field contains the AWS ID of the member account

      • PLATFORM - The operating system. Examples are Windows or Linux.

      • REGION - The AWS region.

      • SCOPE - The scope of a reserved instance (RI). Values are regional or a single availability zone.

      • TENANCY - The tenancy of a resource. Examples are shared or dedicated.

      • (dict) --

        The metadata of a specific type that you can use to filter and group your results. You can use GetDimensionValues to find specific values.

        • Value (string) --

          The value of a dimension with a specific attribute.

        • Attributes (dict) --

          The attribute that applies to a specific Dimension .

          • (string) --

            • (string) --

    • ReturnSize (integer) --

      The number of results that AWS returned at one time.

    • TotalSize (integer) --

      The total number of search results.

    • NextPageToken (string) --

      The token for the next set of retrievable results. AWS provides the token when the response from a previous call has more results than the maximum page size.

GetReservationUtilization (updated) Link ¶
Changes (request)
{'Filter': {'Dimensions': {'Key': {'CACHE_ENGINE',
                                   'DATABASE_ENGINE',
                                   'DEPLOYMENT_OPTION',
                                   'INSTANCE_TYPE_FAMILY',
                                   'LEGAL_ENTITY_NAME'}}}}

You can retrieve the Reservation utilization for your account. Master accounts in an organization have access to their associated member accounts. You can filter data by dimensions in a time period. You can use GetDimensionValues to determine the possible dimension values. Currently, you can group only by SUBSCRIPTION_ID .

See also: AWS API Documentation

Request Syntax

client.get_reservation_utilization(
    TimePeriod={
        'Start': 'string',
        'End': 'string'
    },
    GroupBy=[
        {
            'Type': 'DIMENSION'|'TAG',
            'Key': 'string'
        },
    ],
    Granularity='DAILY'|'MONTHLY',
    Filter={
        'Or': [
            {'... recursive ...'},
        ],
        'And': [
            {'... recursive ...'},
        ],
        'Not': {'... recursive ...'},
        'Dimensions': {
            'Key': 'AZ'|'INSTANCE_TYPE'|'LINKED_ACCOUNT'|'OPERATION'|'PURCHASE_TYPE'|'REGION'|'SERVICE'|'USAGE_TYPE'|'USAGE_TYPE_GROUP'|'RECORD_TYPE'|'OPERATING_SYSTEM'|'TENANCY'|'SCOPE'|'PLATFORM'|'SUBSCRIPTION_ID'|'LEGAL_ENTITY_NAME'|'DEPLOYMENT_OPTION'|'DATABASE_ENGINE'|'CACHE_ENGINE'|'INSTANCE_TYPE_FAMILY',
            'Values': [
                'string',
            ]
        },
        'Tags': {
            'Key': 'string',
            'Values': [
                'string',
            ]
        }
    },
    NextPageToken='string'
)
type TimePeriod

dict

param TimePeriod

[REQUIRED]

Sets the start and end dates for retrieving reserve instance (RI) utilization. The start date is inclusive, but the end date is exclusive. For example, if start is 2017-01-01 and end is 2017-05-01 , then the cost and usage data is retrieved from 2017-01-01 up to and including 2017-04-30 but not including 2017-05-01 .

  • Start (string) -- [REQUIRED]

    The beginning of the time period that you want the usage and costs for. The start date is inclusive. For example, if start is 2017-01-01 , then the cost and usage data is retrieved starting at 2017-01-01 up to the end date.

  • End (string) -- [REQUIRED]

    The end of the time period that you want the usage and costs for. The end date is exclusive. For example, if the end is 2017-05-01 , then the cost and usage data is retrieved from the start date but not including 2017-05-01 .

type GroupBy

list

param GroupBy

Groups only by SUBSCRIPTION_ID . Metadata is included.

  • (dict) --

    Represents a group when you specify a group by criteria, or in the response to a query with a specific grouping.

    • Type (string) --

      The string that represents the type of group.

    • Key (string) --

      The string that represents a key for a specified group.

type Granularity

string

param Granularity

If GroupBy is set, Granularity can't be set. If Granularity isn't set, the response object doesn't include the Granularity , either MONTHLY or DAILY . If both GroupBy and Granularity aren't set, GetReservationUtilization defaults to DAILY .

type Filter

dict

param Filter

Filters utilization data by using different dimensions. GetReservationUtilization uses the same Expression object as the other operations, but only AND is supported among each dimension, and nesting is supported up to only one level deep. If there are multiple values for a dimension, they are OR'd together.

  • Or (list) --

    Return results that match either Dimension .

    • (dict) --

      Use Expression to filter by cost or by usage. There are two patterns:

      • Simple dimension values - You can set the dimension name and values for the filters that you plan to use. For example, you can filter for INSTANCE_TYPE==m4.xlarge OR INSTANCE_TYPE==c4.large . The Expression for that looks like this. { "Dimensions": { "Key": "INSTANCE_TYPE", "Values": [ "m4.xlarge", “c4.large” ] } } The list of dimension values are OR'd together to retrieve cost or usage data. You can create Expression and DimensionValues objects using either with* methods or set* methods in multiple lines.

      • Compound dimension values with logical operations - You can use multiple Expression types and the logical operators AND/OR/NOT to create a list of one or more Expression objects. This allows you to filter on more advanced options. For example, you can filter on ((INSTANCE_TYPE == m4.large OR INSTANCE_TYPE == m3.large) OR (TAG.Type == Type1)) AND (USAGE_TYPE != DataTransfer) . The Expression for that looks like this. { "And": [ {"Or": [ {"Dimensions": { "Key": "INSTANCE_TYPE", "Values": [ "m4.x.large", "c4.large" ] }}, {"Tag": { "Key": "TagName", "Values": ["Value1"] } } ]}, {"Not": {"dimensions": { "Key": "USAGE_TYPE", "Values": ["DataTransfer"] }}} ] }

      Note

      Because each Expression can have only one operator, the service returns an error if more than one is specified. The following example shows an Expression object that will create an error.

      { "And": [ ... ], "DimensionValues": { "Dimension": "USAGE_TYPE", "Values": [ "DataTransfer" ] } }

  • And (list) --

    Return results that match both Dimension objects.

    • (dict) --

      Use Expression to filter by cost or by usage. There are two patterns:

      • Simple dimension values - You can set the dimension name and values for the filters that you plan to use. For example, you can filter for INSTANCE_TYPE==m4.xlarge OR INSTANCE_TYPE==c4.large . The Expression for that looks like this. { "Dimensions": { "Key": "INSTANCE_TYPE", "Values": [ "m4.xlarge", “c4.large” ] } } The list of dimension values are OR'd together to retrieve cost or usage data. You can create Expression and DimensionValues objects using either with* methods or set* methods in multiple lines.

      • Compound dimension values with logical operations - You can use multiple Expression types and the logical operators AND/OR/NOT to create a list of one or more Expression objects. This allows you to filter on more advanced options. For example, you can filter on ((INSTANCE_TYPE == m4.large OR INSTANCE_TYPE == m3.large) OR (TAG.Type == Type1)) AND (USAGE_TYPE != DataTransfer) . The Expression for that looks like this. { "And": [ {"Or": [ {"Dimensions": { "Key": "INSTANCE_TYPE", "Values": [ "m4.x.large", "c4.large" ] }}, {"Tag": { "Key": "TagName", "Values": ["Value1"] } } ]}, {"Not": {"dimensions": { "Key": "USAGE_TYPE", "Values": ["DataTransfer"] }}} ] }

      Note

      Because each Expression can have only one operator, the service returns an error if more than one is specified. The following example shows an Expression object that will create an error.

      { "And": [ ... ], "DimensionValues": { "Dimension": "USAGE_TYPE", "Values": [ "DataTransfer" ] } }

  • Not (dict) --

    Return results that don't match Dimension .

  • Dimensions (dict) --

    The specific Dimension to use for Expression .

    • Key (string) --

      The names of the metadata types that you can use to filter and group your results. For example, AZ returns a list of Availability Zones.

    • Values (list) --

      The metadata values that you can use to filter and group your results. You can use GetDimensionValues to find specific values.

      • (string) --

  • Tags (dict) --

    The specific Tag to use for Expression .

    • Key (string) --

      The key for a tag.

    • Values (list) --

      The specific value of a tag.

      • (string) --

type NextPageToken

string

param NextPageToken

The token to retrieve the next set of results. AWS provides the token when the response from a previous call has more results than the maximum page size.

rtype

dict

returns

Response Syntax

{
    'UtilizationsByTime': [
        {
            'TimePeriod': {
                'Start': 'string',
                'End': 'string'
            },
            'Groups': [
                {
                    'Key': 'string',
                    'Value': 'string',
                    'Attributes': {
                        'string': 'string'
                    },
                    'Utilization': {
                        'UtilizationPercentage': 'string',
                        'PurchasedHours': 'string',
                        'TotalActualHours': 'string',
                        'UnusedHours': 'string'
                    }
                },
            ],
            'Total': {
                'UtilizationPercentage': 'string',
                'PurchasedHours': 'string',
                'TotalActualHours': 'string',
                'UnusedHours': 'string'
            }
        },
    ],
    'Total': {
        'UtilizationPercentage': 'string',
        'PurchasedHours': 'string',
        'TotalActualHours': 'string',
        'UnusedHours': 'string'
    },
    'NextPageToken': 'string'
}

Response Structure

  • (dict) --

    • UtilizationsByTime (list) --

      The amount of time that you utilized your RIs.

      • (dict) --

        The amount of utilization, in hours.

        • TimePeriod (dict) --

          The period of time over which this utilization was used.

          • Start (string) --

            The beginning of the time period that you want the usage and costs for. The start date is inclusive. For example, if start is 2017-01-01 , then the cost and usage data is retrieved starting at 2017-01-01 up to the end date.

          • End (string) --

            The end of the time period that you want the usage and costs for. The end date is exclusive. For example, if the end is 2017-05-01 , then the cost and usage data is retrieved from the start date but not including 2017-05-01 .

        • Groups (list) --

          The groups that are included in this utilization result.

          • (dict) --

            A group of RIs that share a set of attributes.

            • Key (string) --

              The key for a specific RI attribute.

            • Value (string) --

              The value of a specific RI attribute.

            • Attributes (dict) --

              The attributes for this group of RIs.

              • (string) --

                • (string) --

            • Utilization (dict) --

              How much you used this group of RIs.

              • UtilizationPercentage (string) --

                The percentage of RI time that you used.

              • PurchasedHours (string) --

                How many RI hours you purchased.

              • TotalActualHours (string) --

                The total number of RI hours that you used.

              • UnusedHours (string) --

                The number of RI hours that you didn't use.

        • Total (dict) --

          The total number of RI hours that were used.

          • UtilizationPercentage (string) --

            The percentage of RI time that you used.

          • PurchasedHours (string) --

            How many RI hours you purchased.

          • TotalActualHours (string) --

            The total number of RI hours that you used.

          • UnusedHours (string) --

            The number of RI hours that you didn't use.

    • Total (dict) --

      The total amount of time that you utilized your RIs.

      • UtilizationPercentage (string) --

        The percentage of RI time that you used.

      • PurchasedHours (string) --

        How many RI hours you purchased.

      • TotalActualHours (string) --

        The total number of RI hours that you used.

      • UnusedHours (string) --

        The number of RI hours that you didn't use.

    • NextPageToken (string) --

      The token for the next set of retrievable results. AWS provides the token when the response from a previous call has more results than the maximum page size.