Table Of Contents

Feedback

User Guide

First time using the AWS CLI? See the User Guide for help getting started.

[ aws . ce ]

get-cost-and-usage

Description

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 get-dimension-values 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

See 'aws help' for descriptions of global parameters.

Synopsis

  get-cost-and-usage
[--time-period <value>]
[--granularity <value>]
[--filter <value>]
[--metrics <value>]
[--group-by <value>]
[--next-page-token <value>]
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]

Options

--time-period (structure)

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 .

Shorthand Syntax:

Start=string,End=string

JSON Syntax:

{
  "Start": "string",
  "End": "string"
}

--granularity (string)

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 .

Possible values:

  • DAILY
  • MONTHLY

--filter (structure)

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 filter objects to define any combination of dimension filters. For more information, see filter .

JSON Syntax:

{
  "Or": [
    {
      "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", ...]
      }
    }
    ...
  ],
  "And": [
    {
      "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", ...]
      }
    }
    ...
  ],
  "Not": {
    "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", ...]
    }
  },
  "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 (list)

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 .

Syntax:

"string" "string" ...

--group-by (list)

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 .

Shorthand Syntax:

Type=string,Key=string ...

JSON Syntax:

[
  {
    "Type": "DIMENSION"|"TAG",
    "Key": "string"
  }
  ...
]

--next-page-token (string)

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.

--cli-input-json (string) Performs service operation based on the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton. If other arguments are provided on the command line, the CLI values will override the JSON-provided values.

--generate-cli-skeleton (string) Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input, prints a sample input JSON that can be used as an argument for --cli-input-json. If provided with the value output, it validates the command inputs and returns a sample output JSON for that command.

See 'aws help' for descriptions of global parameters.

Output

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.

(structure)

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.

(structure)

The result that is associated with a time period.

TimePeriod -> (structure)

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 -> (map)

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

key -> (string)

value -> (structure)

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.

(structure)

One level of grouped data within the results.

Keys -> (list)

The keys included in this group.

(string)

Metrics -> (map)

The metrics included in this group.

key -> (string)

value -> (structure)

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.