You are viewing documentation for version 2 of the AWS SDK for Ruby. Version 3 documentation can be found here.

Class: Aws::CostExplorer::Client

Inherits:
Seahorse::Client::Base show all
Defined in:
(unknown)

Overview

An API client for AWS Cost Explorer Service. To construct a client, you need to configure a :region and :credentials.

costexplorer = Aws::CostExplorer::Client.new(
  region: region_name,
  credentials: credentials,
  # ...
)

See #initialize for a full list of supported configuration options.

Region

You can configure a default region in the following locations:

  • ENV['AWS_REGION']
  • Aws.config[:region]

Go here for a list of supported regions.

Credentials

Default credentials are loaded automatically from the following locations:

  • ENV['AWS_ACCESS_KEY_ID'] and ENV['AWS_SECRET_ACCESS_KEY']
  • Aws.config[:credentials]
  • The shared credentials ini file at ~/.aws/credentials (more information)
  • From an instance profile when running on EC2

You can also construct a credentials object from one of the following classes:

Alternatively, you configure credentials with :access_key_id and :secret_access_key:

# load credentials from disk
creds = YAML.load(File.read('/path/to/secrets'))

Aws::CostExplorer::Client.new(
  access_key_id: creds['access_key_id'],
  secret_access_key: creds['secret_access_key']
)

Always load your credentials from outside your application. Avoid configuring credentials statically and never commit them to source control.

Instance Attribute Summary

Attributes inherited from Seahorse::Client::Base

#config, #handlers

Constructor collapse

API Operations collapse

Instance Method Summary collapse

Methods inherited from Seahorse::Client::Base

add_plugin, api, #build_request, clear_plugins, define, new, #operation, #operation_names, plugins, remove_plugin, set_api, set_plugins

Methods included from Seahorse::Client::HandlerBuilder

#handle, #handle_request, #handle_response

Constructor Details

#initialize(options = {}) ⇒ Aws::CostExplorer::Client

Constructs an API client.

Options Hash (options):

  • :access_key_id (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :active_endpoint_cache (Boolean)

    When set to true, a thread polling for endpoints will be running in the background every 60 secs (default). Defaults to false. See Plugins::EndpointDiscovery for more details.

  • :convert_params (Boolean) — default: true

    When true, an attempt is made to coerce request parameters into the required types. See Plugins::ParamConverter for more details.

  • :credentials (required, Credentials)

    Your AWS credentials. The following locations will be searched in order for credentials:

    • :access_key_id, :secret_access_key, and :session_token options
    • ENV['AWS_ACCESS_KEY_ID'], ENV['AWS_SECRET_ACCESS_KEY']
    • HOME/.aws/credentials shared credentials file
    • EC2 instance profile credentials See Plugins::RequestSigner for more details.
  • :disable_host_prefix_injection (Boolean)

    Set to true to disable SDK automatically adding host prefix to default service endpoint when available. See Plugins::EndpointPattern for more details.

  • :endpoint (String)

    A default endpoint is constructed from the :region. See Plugins::RegionalEndpoint for more details.

  • :endpoint_cache_max_entries (Integer)

    Used for the maximum size limit of the LRU cache storing endpoints data for endpoint discovery enabled operations. Defaults to 1000. See Plugins::EndpointDiscovery for more details.

  • :endpoint_cache_max_threads (Integer)

    Used for the maximum threads in use for polling endpoints to be cached, defaults to 10. See Plugins::EndpointDiscovery for more details.

  • :endpoint_cache_poll_interval (Integer)

    When :endpoint_discovery and :active_endpoint_cache is enabled, Use this option to config the time interval in seconds for making requests fetching endpoints information. Defaults to 60 sec. See Plugins::EndpointDiscovery for more details.

  • :endpoint_discovery (Boolean)

    When set to true, endpoint discovery will be enabled for operations when available. Defaults to false. See Plugins::EndpointDiscovery for more details.

  • :http_continue_timeout (Float) — default: 1

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_idle_timeout (Integer) — default: 5

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_open_timeout (Integer) — default: 15

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_proxy (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_read_timeout (Integer) — default: 60

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :http_wire_trace (Boolean) — default: false

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :log_level (Symbol) — default: :info

    The log level to send messages to the logger at. See Plugins::Logging for more details.

  • :log_formatter (Logging::LogFormatter)

    The log formatter. Defaults to Seahorse::Client::Logging::Formatter.default. See Plugins::Logging for more details.

  • :logger (Logger) — default: nil

    The Logger instance to send log messages to. If this option is not set, logging will be disabled. See Plugins::Logging for more details.

  • :profile (String)

    Used when loading credentials from the shared credentials file at HOME/.aws/credentials. When not specified, 'default' is used. See Plugins::RequestSigner for more details.

  • :raise_response_errors (Boolean) — default: true

    When true, response errors are raised. See Seahorse::Client::Plugins::RaiseResponseErrors for more details.

  • :region (required, String)

    The AWS region to connect to. The region is used to construct the client endpoint. Defaults to ENV['AWS_REGION']. Also checks AMAZON_REGION and AWS_DEFAULT_REGION. See Plugins::RegionalEndpoint for more details.

  • :retry_limit (Integer) — default: 3

    The maximum number of times to retry failed requests. Only ~ 500 level server errors and certain ~ 400 level client errors are retried. Generally, these are throttling errors, data checksum errors, networking errors, timeout errors and auth errors from expired credentials. See Plugins::RetryErrors for more details.

  • :secret_access_key (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :session_token (String)

    Used to set credentials statically. See Plugins::RequestSigner for more details.

  • :simple_json (Boolean) — default: false

    Disables request parameter conversion, validation, and formatting. Also disable response data type conversions. This option is useful when you want to ensure the highest level of performance by avoiding overhead of walking request parameters and response data structures.

    When :simple_json is enabled, the request parameters hash must be formatted exactly as the DynamoDB API expects. See Plugins::Protocols::JsonRpc for more details.

  • :ssl_ca_bundle (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_ca_directory (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_ca_store (String)

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :ssl_verify_peer (Boolean) — default: true

    See Seahorse::Client::Plugins::NetHttp for more details.

  • :stub_responses (Boolean) — default: false

    Causes the client to return stubbed responses. By default fake responses are generated and returned. You can specify the response data to return or errors to raise by calling Aws::ClientStubs#stub_responses. See Aws::ClientStubs for more information.

    Please note When response stubbing is enabled, no HTTP requests are made, and retries are disabled. See Plugins::StubResponses for more details.

  • :validate_params (Boolean) — default: true

    When true, request parameters are validated before sending the request. See Plugins::ParamValidator for more details.

Instance Method Details

#get_cost_and_usage(options = {}) ⇒ Types::GetCostAndUsageResponse

Retrieves 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. For a complete list of valid dimensions, see the GetDimensionValues operation. Master accounts in an organization in AWS Organizations have access to all member accounts.

Examples:

Request syntax with placeholder values


resp = client.get_cost_and_usage({
  time_period: { # required
    start: "YearMonthDay", # required
    end: "YearMonthDay", # required
  },
  granularity: "DAILY", # accepts DAILY, MONTHLY, HOURLY
  filter: {
    or: [
      {
        # recursive Expression
      },
    ],
    and: [
      {
        # recursive Expression
      },
    ],
    not: {
      # recursive Expression
    },
    dimensions: {
      key: "AZ", # accepts 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, BILLING_ENTITY, RESERVATION_ID, RESOURCE_ID, RIGHTSIZING_TYPE, SAVINGS_PLANS_TYPE, SAVINGS_PLAN_ARN, PAYMENT_OPTION
      values: ["Value"],
    },
    tags: {
      key: "TagKey",
      values: ["Value"],
    },
  },
  metrics: ["MetricName"],
  group_by: [
    {
      type: "DIMENSION", # accepts DIMENSION, TAG
      key: "GroupDefinitionKey",
    },
  ],
  next_page_token: "NextPageToken",
})

Response structure


resp.next_page_token #=> String
resp.group_definitions #=> Array
resp.group_definitions[0].type #=> String, one of "DIMENSION", "TAG"
resp.group_definitions[0].key #=> String
resp.results_by_time #=> Array
resp.results_by_time[0].time_period.start #=> String
resp.results_by_time[0].time_period.end #=> String
resp.results_by_time[0].total #=> Hash
resp.results_by_time[0].total["MetricName"].amount #=> String
resp.results_by_time[0].total["MetricName"].unit #=> String
resp.results_by_time[0].groups #=> Array
resp.results_by_time[0].groups[0].keys #=> Array
resp.results_by_time[0].groups[0].keys[0] #=> String
resp.results_by_time[0].groups[0].metrics #=> Hash
resp.results_by_time[0].groups[0].metrics["MetricName"].amount #=> String
resp.results_by_time[0].groups[0].metrics["MetricName"].unit #=> String
resp.results_by_time[0].estimated #=> true/false

Options Hash (options):

  • :time_period (required, Types::DateInterval)

    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.

  • :granularity (String)

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

  • :filter (Types::Expression)

    Filters AWS costs by different dimensions. For example, you can specify SERVICE and LINKED_ACCOUNT and get the costs that are 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.

  • :metrics (Array<String>)

    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 AmortizedCost, BlendedCost, NetAmortizedCost, NetUnblendedCost, NormalizedUsageAmount, UnblendedCost, and UsageQuantity.

    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 Amazon EC2, the results aren\'t meaningful because Amazon 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.

    Metrics is required for GetCostAndUsage requests.

  • :group_by (Array<Types::GroupDefinition>)

    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, LEGAL_ENTITY_NAME, LINKED_ACCOUNT, OPERATION, PLATFORM, PURCHASE_TYPE, SERVICE, TAGS, TENANCY, RECORD_TYPE, and USAGE_TYPE.

  • :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.

Returns:

See Also:

#get_cost_and_usage_with_resources(options = {}) ⇒ Types::GetCostAndUsageWithResourcesResponse

Retrieves cost and usage metrics with resources 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. For a complete list of valid dimensions, see the GetDimensionValues operation. Master accounts in an organization in AWS Organizations have access to all member accounts. This API is currently available for the Amazon Elastic Compute Cloud – Compute service only.

This is an opt-in only feature. You can enable this feature from the Cost Explorer Settings page. For information on how to access the Settings page, see Controlling Access for Cost Explorer in the AWS Billing and Cost Management User Guide.

Examples:

Request syntax with placeholder values


resp = client.get_cost_and_usage_with_resources({
  time_period: { # required
    start: "YearMonthDay", # required
    end: "YearMonthDay", # required
  },
  granularity: "DAILY", # accepts DAILY, MONTHLY, HOURLY
  filter: {
    or: [
      {
        # recursive Expression
      },
    ],
    and: [
      {
        # recursive Expression
      },
    ],
    not: {
      # recursive Expression
    },
    dimensions: {
      key: "AZ", # accepts 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, BILLING_ENTITY, RESERVATION_ID, RESOURCE_ID, RIGHTSIZING_TYPE, SAVINGS_PLANS_TYPE, SAVINGS_PLAN_ARN, PAYMENT_OPTION
      values: ["Value"],
    },
    tags: {
      key: "TagKey",
      values: ["Value"],
    },
  },
  metrics: ["MetricName"],
  group_by: [
    {
      type: "DIMENSION", # accepts DIMENSION, TAG
      key: "GroupDefinitionKey",
    },
  ],
  next_page_token: "NextPageToken",
})

Response structure


resp.next_page_token #=> String
resp.group_definitions #=> Array
resp.group_definitions[0].type #=> String, one of "DIMENSION", "TAG"
resp.group_definitions[0].key #=> String
resp.results_by_time #=> Array
resp.results_by_time[0].time_period.start #=> String
resp.results_by_time[0].time_period.end #=> String
resp.results_by_time[0].total #=> Hash
resp.results_by_time[0].total["MetricName"].amount #=> String
resp.results_by_time[0].total["MetricName"].unit #=> String
resp.results_by_time[0].groups #=> Array
resp.results_by_time[0].groups[0].keys #=> Array
resp.results_by_time[0].groups[0].keys[0] #=> String
resp.results_by_time[0].groups[0].metrics #=> Hash
resp.results_by_time[0].groups[0].metrics["MetricName"].amount #=> String
resp.results_by_time[0].groups[0].metrics["MetricName"].unit #=> String
resp.results_by_time[0].estimated #=> true/false

Options Hash (options):

  • :time_period (required, Types::DateInterval)

    Sets the start and end dates for retrieving Amazon Web Services costs. The range must be within the last 14 days (the start date cannot be earlier than 14 days ago). 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.

  • :granularity (String)

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

  • :filter (Types::Expression)

    Filters Amazon Web Services costs by different dimensions. For example, you can specify SERVICE and LINKED_ACCOUNT and get the costs that are 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.

    The GetCostAndUsageWithResources operation requires that you either group by or filter by a ResourceId.

  • :metrics (Array<String>)

    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 AmortizedCost, BlendedCost, NetAmortizedCost, NetUnblendedCost, NormalizedUsageAmount, UnblendedCost, and UsageQuantity.

    If you return the UsageQuantity metric, the service aggregates all usage numbers without taking the units into account. For example, if you aggregate usageQuantity across all of Amazon EC2, the results aren\'t meaningful because Amazon 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.

    Metrics is required for GetCostAndUsageWithResources requests.

  • :group_by (Array<Types::GroupDefinition>)

    You can group Amazon Web Services costs using up to two different groups: either dimensions, tag keys, or both.

  • :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.

Returns:

See Also:

#get_cost_forecast(options = {}) ⇒ Types::GetCostForecastResponse

Retrieves a forecast for how much Amazon Web Services predicts that you will spend over the forecast time period that you select, based on your past costs.

Examples:

Request syntax with placeholder values


resp = client.get_cost_forecast({
  time_period: { # required
    start: "YearMonthDay", # required
    end: "YearMonthDay", # required
  },
  metric: "BLENDED_COST", # required, accepts BLENDED_COST, UNBLENDED_COST, AMORTIZED_COST, NET_UNBLENDED_COST, NET_AMORTIZED_COST, USAGE_QUANTITY, NORMALIZED_USAGE_AMOUNT
  granularity: "DAILY", # required, accepts DAILY, MONTHLY, HOURLY
  filter: {
    or: [
      {
        # recursive Expression
      },
    ],
    and: [
      {
        # recursive Expression
      },
    ],
    not: {
      # recursive Expression
    },
    dimensions: {
      key: "AZ", # accepts 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, BILLING_ENTITY, RESERVATION_ID, RESOURCE_ID, RIGHTSIZING_TYPE, SAVINGS_PLANS_TYPE, SAVINGS_PLAN_ARN, PAYMENT_OPTION
      values: ["Value"],
    },
    tags: {
      key: "TagKey",
      values: ["Value"],
    },
  },
  prediction_interval_level: 1,
})

Response structure


resp.total.amount #=> String
resp.total.unit #=> String
resp.forecast_results_by_time #=> Array
resp.forecast_results_by_time[0].time_period.start #=> String
resp.forecast_results_by_time[0].time_period.end #=> String
resp.forecast_results_by_time[0].mean_value #=> String
resp.forecast_results_by_time[0].prediction_interval_lower_bound #=> String
resp.forecast_results_by_time[0].prediction_interval_upper_bound #=> String

Options Hash (options):

  • :time_period (required, Types::DateInterval)

    The period of time that you want the forecast to cover.

  • :metric (required, String)

    Which metric Cost Explorer uses to create your forecast. For more information about blended and unblended rates, see Why does the \"blended\" annotation appear on some line items in my bill?.

    Valid values for a GetCostForecast call are the following:

    • AMORTIZED_COST

    • BLENDED_COST

    • NET_AMORTIZED_COST

    • NET_UNBLENDED_COST

    • UNBLENDED_COST

  • :granularity (required, String)

    How granular you want the forecast to be. You can get 3 months of DAILY forecasts or 12 months of MONTHLY forecasts.

    The GetCostForecast operation supports only DAILY and MONTHLY granularities.

  • :filter (Types::Expression)

    The filters that you want to use to filter your forecast. Cost Explorer API supports all of the Cost Explorer filters.

  • :prediction_interval_level (Integer)

    Cost Explorer always returns the mean forecast as a single point. You can request a prediction interval around the mean by specifying a confidence level. The higher the confidence level, the more confident Cost Explorer is about the actual value falling in the prediction interval. Higher confidence levels result in wider prediction intervals.

Returns:

See Also:

#get_dimension_values(options = {}) ⇒ Types::GetDimensionValuesResponse

Retrieves all available filter values for a specified filter over a period of time. You can search the dimension values for an arbitrary string.

Examples:

Request syntax with placeholder values


resp = client.get_dimension_values({
  search_string: "SearchString",
  time_period: { # required
    start: "YearMonthDay", # required
    end: "YearMonthDay", # required
  },
  dimension: "AZ", # required, accepts 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, BILLING_ENTITY, RESERVATION_ID, RESOURCE_ID, RIGHTSIZING_TYPE, SAVINGS_PLANS_TYPE, SAVINGS_PLAN_ARN, PAYMENT_OPTION
  context: "COST_AND_USAGE", # accepts COST_AND_USAGE, RESERVATIONS, SAVINGS_PLANS
  next_page_token: "NextPageToken",
})

Response structure


resp.dimension_values #=> Array
resp.dimension_values[0].value #=> String
resp.dimension_values[0].attributes #=> Hash
resp.dimension_values[0].attributes["AttributeType"] #=> <Hash,Array,String,Numeric,Boolean,IO,Set,nil>
resp.return_size #=> Integer
resp.total_size #=> Integer
resp.next_page_token #=> String

Options Hash (options):

  • :search_string (String)

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

  • :time_period (required, Types::DateInterval)

    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.

  • :dimension (required, String)

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

  • :context (String)

    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 operation. 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 COST_AND_USAGE, you can use the following dimensions for searching:

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

    • DATABASE_ENGINE - The Amazon Relational Database Service database. Examples are Aurora or MySQL.

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

    • LEGAL_ENTITY_NAME - The name of the organization that sells you AWS services, such as Amazon Web Services.

    • 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.

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

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

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

    • 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 Amazon DynamoDB.

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

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

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

    • RESOURCE_ID - The unique identifier of the resource. ResourceId is an opt-in feature only available for last 14 days for EC2-Compute Service.

    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.

    • CACHE_ENGINE - The Amazon ElastiCache operating system. Examples are Windows or Linux.

    • DEPLOYMENT_OPTION - The scope of Amazon Relational Database Service deployments. Valid values are SingleAZ and MultiAZ.

    • INSTANCE_TYPE - The type of Amazon 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 Amazon EC2 operating system. Examples are Windows or Linux.

    • REGION - The AWS Region.

    • SCOPE (Utilization only) - The scope of a Reserved Instance (RI). Values are regional or a single Availability Zone.

    • TAG (Coverage only) - The tags that are associated with a Reserved Instance (RI).

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

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

    • SAVINGS_PLANS_TYPE - Type of Savings Plans (EC2 Instance or Compute)

    • PAYMENT_OPTION - Payment option for the given Savings Plans (for example, All Upfront)

    • REGION - The AWS Region.

    • INSTANCE_TYPE_FAMILY - The family of instances (For example, m5)

    • 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.

    • SAVINGS_PLAN_ARN - The unique identifier for your Savings Plan

  • :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.

Returns:

See Also:

#get_reservation_coverage(options = {}) ⇒ Types::GetReservationCoverageResponse

Retrieves the reservation coverage for your account. This enables you to see how much of your Amazon Elastic Compute Cloud, Amazon ElastiCache, Amazon Relational Database Service, or Amazon Redshift usage is covered by a reservation. An organization's master account can see the coverage of the associated member accounts. For any time period, you can filter data about reservation usage by the following dimensions:

  • AZ

  • CACHE_ENGINE

  • DATABASE_ENGINE

  • DEPLOYMENT_OPTION

  • INSTANCE_TYPE

  • LINKED_ACCOUNT

  • OPERATING_SYSTEM

  • PLATFORM

  • REGION

  • SERVICE

  • TAG

  • TENANCY

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

Examples:

Request syntax with placeholder values


resp = client.get_reservation_coverage({
  time_period: { # required
    start: "YearMonthDay", # required
    end: "YearMonthDay", # required
  },
  group_by: [
    {
      type: "DIMENSION", # accepts DIMENSION, TAG
      key: "GroupDefinitionKey",
    },
  ],
  granularity: "DAILY", # accepts DAILY, MONTHLY, HOURLY
  filter: {
    or: [
      {
        # recursive Expression
      },
    ],
    and: [
      {
        # recursive Expression
      },
    ],
    not: {
      # recursive Expression
    },
    dimensions: {
      key: "AZ", # accepts 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, BILLING_ENTITY, RESERVATION_ID, RESOURCE_ID, RIGHTSIZING_TYPE, SAVINGS_PLANS_TYPE, SAVINGS_PLAN_ARN, PAYMENT_OPTION
      values: ["Value"],
    },
    tags: {
      key: "TagKey",
      values: ["Value"],
    },
  },
  metrics: ["MetricName"],
  next_page_token: "NextPageToken",
})

Response structure


resp.coverages_by_time #=> Array
resp.coverages_by_time[0].time_period.start #=> String
resp.coverages_by_time[0].time_period.end #=> String
resp.coverages_by_time[0].groups #=> Array
resp.coverages_by_time[0].groups[0].attributes #=> Hash
resp.coverages_by_time[0].groups[0].attributes["AttributeType"] #=> <Hash,Array,String,Numeric,Boolean,IO,Set,nil>
resp.coverages_by_time[0].groups[0].coverage.coverage_hours.on_demand_hours #=> String
resp.coverages_by_time[0].groups[0].coverage.coverage_hours.reserved_hours #=> String
resp.coverages_by_time[0].groups[0].coverage.coverage_hours.total_running_hours #=> String
resp.coverages_by_time[0].groups[0].coverage.coverage_hours.coverage_hours_percentage #=> String
resp.coverages_by_time[0].groups[0].coverage.coverage_normalized_units.on_demand_normalized_units #=> String
resp.coverages_by_time[0].groups[0].coverage.coverage_normalized_units.reserved_normalized_units #=> String
resp.coverages_by_time[0].groups[0].coverage.coverage_normalized_units.total_running_normalized_units #=> String
resp.coverages_by_time[0].groups[0].coverage.coverage_normalized_units.coverage_normalized_units_percentage #=> String
resp.coverages_by_time[0].groups[0].coverage.coverage_cost.on_demand_cost #=> String
resp.coverages_by_time[0].total.coverage_hours.on_demand_hours #=> String
resp.coverages_by_time[0].total.coverage_hours.reserved_hours #=> String
resp.coverages_by_time[0].total.coverage_hours.total_running_hours #=> String
resp.coverages_by_time[0].total.coverage_hours.coverage_hours_percentage #=> String
resp.coverages_by_time[0].total.coverage_normalized_units.on_demand_normalized_units #=> String
resp.coverages_by_time[0].total.coverage_normalized_units.reserved_normalized_units #=> String
resp.coverages_by_time[0].total.coverage_normalized_units.total_running_normalized_units #=> String
resp.coverages_by_time[0].total.coverage_normalized_units.coverage_normalized_units_percentage #=> String
resp.coverages_by_time[0].total.coverage_cost.on_demand_cost #=> String
resp.total.coverage_hours.on_demand_hours #=> String
resp.total.coverage_hours.reserved_hours #=> String
resp.total.coverage_hours.total_running_hours #=> String
resp.total.coverage_hours.coverage_hours_percentage #=> String
resp.total.coverage_normalized_units.on_demand_normalized_units #=> String
resp.total.coverage_normalized_units.reserved_normalized_units #=> String
resp.total.coverage_normalized_units.total_running_normalized_units #=> String
resp.total.coverage_normalized_units.coverage_normalized_units_percentage #=> String
resp.total.coverage_cost.on_demand_cost #=> String
resp.next_page_token #=> String

Options Hash (options):

  • :time_period (required, Types::DateInterval)

    The start and end dates of the period that you want to retrieve data about reservation coverage for. 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.

  • :group_by (Array<Types::GroupDefinition>)

    You can group the data by the following attributes:

    • AZ

    • CACHE_ENGINE

    • DATABASE_ENGINE

    • DEPLOYMENT_OPTION

    • INSTANCE_TYPE

    • LINKED_ACCOUNT

    • OPERATING_SYSTEM

    • PLATFORM

    • REGION

    • TENANCY

  • :granularity (String)

    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 Granularity, either MONTHLY or DAILY.

    The GetReservationCoverage operation supports only DAILY and MONTHLY granularities.

  • :filter (Types::Expression)

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

    • AZ

    • CACHE_ENGINE

    • DATABASE_ENGINE

    • DEPLOYMENT_OPTION

    • INSTANCE_TYPE

    • LINKED_ACCOUNT

    • OPERATING_SYSTEM

    • PLATFORM

    • REGION

    • SERVICE

    • TAG

    • 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.

    If you don\'t provide a SERVICE filter, Cost Explorer defaults to EC2.

  • :metrics (Array<String>)

    The measurement that you want your reservation coverage reported in.

    Valid values are Hour, Unit, and Cost. You can use multiple values in a request.

  • :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.

Returns:

See Also:

#get_reservation_purchase_recommendation(options = {}) ⇒ Types::GetReservationPurchaseRecommendationResponse

Gets recommendations for which reservations to purchase. These recommendations could help you reduce your costs. Reservations provide a discounted hourly rate (up to 75%) compared to On-Demand pricing.

AWS generates your recommendations by identifying your On-Demand usage during a specific time period and collecting your usage into categories that are eligible for a reservation. After AWS has these categories, it simulates every combination of reservations in each category of usage to identify the best number of each type of RI to purchase to maximize your estimated savings.

For example, AWS automatically aggregates your Amazon EC2 Linux, shared tenancy, and c4 family usage in the US West (Oregon) Region and recommends that you buy size-flexible regional reservations to apply to the c4 family usage. AWS recommends the smallest size instance in an instance family. This makes it easier to purchase a size-flexible RI. AWS also shows the equal number of normalized units so that you can purchase any instance size that you want. For this example, your RI recommendation would be for c4.large because that is the smallest size instance in the c4 instance family.

Examples:

Request syntax with placeholder values


resp = client.get_reservation_purchase_recommendation({
  account_id: "GenericString",
  service: "GenericString", # required
  account_scope: "PAYER", # accepts PAYER, LINKED
  lookback_period_in_days: "SEVEN_DAYS", # accepts SEVEN_DAYS, THIRTY_DAYS, SIXTY_DAYS
  term_in_years: "ONE_YEAR", # accepts ONE_YEAR, THREE_YEARS
  payment_option: "NO_UPFRONT", # accepts NO_UPFRONT, PARTIAL_UPFRONT, ALL_UPFRONT, LIGHT_UTILIZATION, MEDIUM_UTILIZATION, HEAVY_UTILIZATION
  service_specification: {
    ec2_specification: {
      offering_class: "STANDARD", # accepts STANDARD, CONVERTIBLE
    },
  },
  page_size: 1,
  next_page_token: "NextPageToken",
})

Response structure


resp..recommendation_id #=> String
resp..generation_timestamp #=> String
resp.recommendations #=> Array
resp.recommendations[0]. #=> String, one of "PAYER", "LINKED"
resp.recommendations[0].lookback_period_in_days #=> String, one of "SEVEN_DAYS", "THIRTY_DAYS", "SIXTY_DAYS"
resp.recommendations[0].term_in_years #=> String, one of "ONE_YEAR", "THREE_YEARS"
resp.recommendations[0].payment_option #=> String, one of "NO_UPFRONT", "PARTIAL_UPFRONT", "ALL_UPFRONT", "LIGHT_UTILIZATION", "MEDIUM_UTILIZATION", "HEAVY_UTILIZATION"
resp.recommendations[0].service_specification.ec2_specification.offering_class #=> String, one of "STANDARD", "CONVERTIBLE"
resp.recommendations[0].recommendation_details #=> Array
resp.recommendations[0].recommendation_details[0]. #=> String
resp.recommendations[0].recommendation_details[0].instance_details.ec2_instance_details.family #=> String
resp.recommendations[0].recommendation_details[0].instance_details.ec2_instance_details.instance_type #=> String
resp.recommendations[0].recommendation_details[0].instance_details.ec2_instance_details.region #=> String
resp.recommendations[0].recommendation_details[0].instance_details.ec2_instance_details.availability_zone #=> String
resp.recommendations[0].recommendation_details[0].instance_details.ec2_instance_details.platform #=> String
resp.recommendations[0].recommendation_details[0].instance_details.ec2_instance_details.tenancy #=> String
resp.recommendations[0].recommendation_details[0].instance_details.ec2_instance_details.current_generation #=> true/false
resp.recommendations[0].recommendation_details[0].instance_details.ec2_instance_details.size_flex_eligible #=> true/false
resp.recommendations[0].recommendation_details[0].instance_details.rds_instance_details.family #=> String
resp.recommendations[0].recommendation_details[0].instance_details.rds_instance_details.instance_type #=> String
resp.recommendations[0].recommendation_details[0].instance_details.rds_instance_details.region #=> String
resp.recommendations[0].recommendation_details[0].instance_details.rds_instance_details.database_engine #=> String
resp.recommendations[0].recommendation_details[0].instance_details.rds_instance_details.database_edition #=> String
resp.recommendations[0].recommendation_details[0].instance_details.rds_instance_details.deployment_option #=> String
resp.recommendations[0].recommendation_details[0].instance_details.rds_instance_details.license_model #=> String
resp.recommendations[0].recommendation_details[0].instance_details.rds_instance_details.current_generation #=> true/false
resp.recommendations[0].recommendation_details[0].instance_details.rds_instance_details.size_flex_eligible #=> true/false
resp.recommendations[0].recommendation_details[0].instance_details.redshift_instance_details.family #=> String
resp.recommendations[0].recommendation_details[0].instance_details.redshift_instance_details.node_type #=> String
resp.recommendations[0].recommendation_details[0].instance_details.redshift_instance_details.region #=> String
resp.recommendations[0].recommendation_details[0].instance_details.redshift_instance_details.current_generation #=> true/false
resp.recommendations[0].recommendation_details[0].instance_details.redshift_instance_details.size_flex_eligible #=> true/false
resp.recommendations[0].recommendation_details[0].instance_details.elasticache_instance_details.family #=> String
resp.recommendations[0].recommendation_details[0].instance_details.elasticache_instance_details.node_type #=> String
resp.recommendations[0].recommendation_details[0].instance_details.elasticache_instance_details.region #=> String
resp.recommendations[0].recommendation_details[0].instance_details.elasticache_instance_details.product_description #=> String
resp.recommendations[0].recommendation_details[0].instance_details.elasticache_instance_details.current_generation #=> true/false
resp.recommendations[0].recommendation_details[0].instance_details.elasticache_instance_details.size_flex_eligible #=> true/false
resp.recommendations[0].recommendation_details[0].instance_details.es_instance_details.instance_class #=> String
resp.recommendations[0].recommendation_details[0].instance_details.es_instance_details.instance_size #=> String
resp.recommendations[0].recommendation_details[0].instance_details.es_instance_details.region #=> String
resp.recommendations[0].recommendation_details[0].instance_details.es_instance_details.current_generation #=> true/false
resp.recommendations[0].recommendation_details[0].instance_details.es_instance_details.size_flex_eligible #=> true/false
resp.recommendations[0].recommendation_details[0].recommended_number_of_instances_to_purchase #=> String
resp.recommendations[0].recommendation_details[0].recommended_normalized_units_to_purchase #=> String
resp.recommendations[0].recommendation_details[0].minimum_number_of_instances_used_per_hour #=> String
resp.recommendations[0].recommendation_details[0].minimum_normalized_units_used_per_hour #=> String
resp.recommendations[0].recommendation_details[0].maximum_number_of_instances_used_per_hour #=> String
resp.recommendations[0].recommendation_details[0].maximum_normalized_units_used_per_hour #=> String
resp.recommendations[0].recommendation_details[0].average_number_of_instances_used_per_hour #=> String
resp.recommendations[0].recommendation_details[0].average_normalized_units_used_per_hour #=> String
resp.recommendations[0].recommendation_details[0].average_utilization #=> String
resp.recommendations[0].recommendation_details[0].estimated_break_even_in_months #=> String
resp.recommendations[0].recommendation_details[0].currency_code #=> String
resp.recommendations[0].recommendation_details[0].estimated_monthly_savings_amount #=> String
resp.recommendations[0].recommendation_details[0].estimated_monthly_savings_percentage #=> String
resp.recommendations[0].recommendation_details[0].estimated_monthly_on_demand_cost #=> String
resp.recommendations[0].recommendation_details[0].estimated_reservation_cost_for_lookback_period #=> String
resp.recommendations[0].recommendation_details[0].upfront_cost #=> String
resp.recommendations[0].recommendation_details[0].recurring_standard_monthly_cost #=> String
resp.recommendations[0].recommendation_summary.total_estimated_monthly_savings_amount #=> String
resp.recommendations[0].recommendation_summary.total_estimated_monthly_savings_percentage #=> String
resp.recommendations[0].recommendation_summary.currency_code #=> String
resp.next_page_token #=> String

Options Hash (options):

  • :account_id (String)

    The account ID that is associated with the recommendation.

  • :service (required, String)

    The specific service that you want recommendations for.

  • :account_scope (String)

    The account scope that you want recommendations for. PAYER means that AWS includes the master account and any member accounts when it calculates its recommendations. LINKED means that AWS includes only member accounts when it calculates its recommendations.

    Valid values are PAYER and LINKED.

  • :lookback_period_in_days (String)

    The number of previous days that you want AWS to consider when it calculates your recommendations.

  • :term_in_years (String)

    The reservation term that you want recommendations for.

  • :payment_option (String)

    The reservation purchase option that you want recommendations for.

  • :service_specification (Types::ServiceSpecification)

    The hardware specifications for the service instances that you want recommendations for, such as standard or convertible Amazon EC2 instances.

  • :page_size (Integer)

    The number of recommendations that you want returned in a single response object.

  • :next_page_token (String)

    The pagination token that indicates the next set of results that you want to retrieve.

Returns:

See Also:

#get_reservation_utilization(options = {}) ⇒ Types::GetReservationUtilizationResponse

Retrieves the reservation utilization for your account. Master accounts in an organization have access to 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.

Examples:

Request syntax with placeholder values


resp = client.get_reservation_utilization({
  time_period: { # required
    start: "YearMonthDay", # required
    end: "YearMonthDay", # required
  },
  group_by: [
    {
      type: "DIMENSION", # accepts DIMENSION, TAG
      key: "GroupDefinitionKey",
    },
  ],
  granularity: "DAILY", # accepts DAILY, MONTHLY, HOURLY
  filter: {
    or: [
      {
        # recursive Expression
      },
    ],
    and: [
      {
        # recursive Expression
      },
    ],
    not: {
      # recursive Expression
    },
    dimensions: {
      key: "AZ", # accepts 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, BILLING_ENTITY, RESERVATION_ID, RESOURCE_ID, RIGHTSIZING_TYPE, SAVINGS_PLANS_TYPE, SAVINGS_PLAN_ARN, PAYMENT_OPTION
      values: ["Value"],
    },
    tags: {
      key: "TagKey",
      values: ["Value"],
    },
  },
  next_page_token: "NextPageToken",
})

Response structure


resp.utilizations_by_time #=> Array
resp.utilizations_by_time[0].time_period.start #=> String
resp.utilizations_by_time[0].time_period.end #=> String
resp.utilizations_by_time[0].groups #=> Array
resp.utilizations_by_time[0].groups[0].key #=> String
resp.utilizations_by_time[0].groups[0].value #=> String
resp.utilizations_by_time[0].groups[0].attributes #=> Hash
resp.utilizations_by_time[0].groups[0].attributes["AttributeType"] #=> <Hash,Array,String,Numeric,Boolean,IO,Set,nil>
resp.utilizations_by_time[0].groups[0].utilization.utilization_percentage #=> String
resp.utilizations_by_time[0].groups[0].utilization.utilization_percentage_in_units #=> String
resp.utilizations_by_time[0].groups[0].utilization.purchased_hours #=> String
resp.utilizations_by_time[0].groups[0].utilization.purchased_units #=> String
resp.utilizations_by_time[0].groups[0].utilization.total_actual_hours #=> String
resp.utilizations_by_time[0].groups[0].utilization.total_actual_units #=> String
resp.utilizations_by_time[0].groups[0].utilization.unused_hours #=> String
resp.utilizations_by_time[0].groups[0].utilization.unused_units #=> String
resp.utilizations_by_time[0].groups[0].utilization.on_demand_cost_of_ri_hours_used #=> String
resp.utilizations_by_time[0].groups[0].utilization.net_ri_savings #=> String
resp.utilizations_by_time[0].groups[0].utilization.total_potential_ri_savings #=> String
resp.utilizations_by_time[0].groups[0].utilization.amortized_upfront_fee #=> String
resp.utilizations_by_time[0].groups[0].utilization.amortized_recurring_fee #=> String
resp.utilizations_by_time[0].groups[0].utilization.total_amortized_fee #=> String
resp.utilizations_by_time[0].total.utilization_percentage #=> String
resp.utilizations_by_time[0].total.utilization_percentage_in_units #=> String
resp.utilizations_by_time[0].total.purchased_hours #=> String
resp.utilizations_by_time[0].total.purchased_units #=> String
resp.utilizations_by_time[0].total.total_actual_hours #=> String
resp.utilizations_by_time[0].total.total_actual_units #=> String
resp.utilizations_by_time[0].total.unused_hours #=> String
resp.utilizations_by_time[0].total.unused_units #=> String
resp.utilizations_by_time[0].total.on_demand_cost_of_ri_hours_used #=> String
resp.utilizations_by_time[0].total.net_ri_savings #=> String
resp.utilizations_by_time[0].total.total_potential_ri_savings #=> String
resp.utilizations_by_time[0].total.amortized_upfront_fee #=> String
resp.utilizations_by_time[0].total.amortized_recurring_fee #=> String
resp.utilizations_by_time[0].total.total_amortized_fee #=> String
resp.total.utilization_percentage #=> String
resp.total.utilization_percentage_in_units #=> String
resp.total.purchased_hours #=> String
resp.total.purchased_units #=> String
resp.total.total_actual_hours #=> String
resp.total.total_actual_units #=> String
resp.total.unused_hours #=> String
resp.total.unused_units #=> String
resp.total.on_demand_cost_of_ri_hours_used #=> String
resp.total.net_ri_savings #=> String
resp.total.total_potential_ri_savings #=> String
resp.total.amortized_upfront_fee #=> String
resp.total.amortized_recurring_fee #=> String
resp.total.total_amortized_fee #=> String
resp.next_page_token #=> String

Options Hash (options):

  • :time_period (required, Types::DateInterval)

    Sets the start and end dates for retrieving 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.

  • :group_by (Array<Types::GroupDefinition>)

    Groups only by SUBSCRIPTION_ID. Metadata is included.

  • :granularity (String)

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

    The GetReservationUtilization operation supports only DAILY and MONTHLY granularities.

  • :filter (Types::Expression)

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

    • AZ

    • CACHE_ENGINE

    • DATABASE_ENGINE

    • DEPLOYMENT_OPTION

    • INSTANCE_TYPE

    • LINKED_ACCOUNT

    • OPERATING_SYSTEM

    • PLATFORM

    • REGION

    • SERVICE

    • SCOPE

    • TENANCY

    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.

  • :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.

Returns:

See Also:

#get_rightsizing_recommendation(options = {}) ⇒ Types::GetRightsizingRecommendationResponse

Creates recommendations that helps you save cost by identifying idle and underutilized Amazon EC2 instances.

Recommendations are generated to either downsize or terminate instances, along with providing savings detail and metrics. For details on calculation and function, see Optimizing Your Cost with Rightsizing Recommendations.

Examples:

Request syntax with placeholder values


resp = client.get_rightsizing_recommendation({
  filter: {
    or: [
      {
        # recursive Expression
      },
    ],
    and: [
      {
        # recursive Expression
      },
    ],
    not: {
      # recursive Expression
    },
    dimensions: {
      key: "AZ", # accepts 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, BILLING_ENTITY, RESERVATION_ID, RESOURCE_ID, RIGHTSIZING_TYPE, SAVINGS_PLANS_TYPE, SAVINGS_PLAN_ARN, PAYMENT_OPTION
      values: ["Value"],
    },
    tags: {
      key: "TagKey",
      values: ["Value"],
    },
  },
  service: "GenericString", # required
  page_size: 1,
  next_page_token: "NextPageToken",
})

Response structure


resp..recommendation_id #=> String
resp..generation_timestamp #=> String
resp..lookback_period_in_days #=> String, one of "SEVEN_DAYS", "THIRTY_DAYS", "SIXTY_DAYS"
resp.summary.total_recommendation_count #=> String
resp.summary.estimated_total_monthly_savings_amount #=> String
resp.summary.savings_currency_code #=> String
resp.summary.savings_percentage #=> String
resp.rightsizing_recommendations #=> Array
resp.rightsizing_recommendations[0]. #=> String
resp.rightsizing_recommendations[0].current_instance.resource_id #=> String
resp.rightsizing_recommendations[0].current_instance.tags #=> Array
resp.rightsizing_recommendations[0].current_instance.tags[0].key #=> String
resp.rightsizing_recommendations[0].current_instance.tags[0].values #=> Array
resp.rightsizing_recommendations[0].current_instance.tags[0].values[0] #=> String
resp.rightsizing_recommendations[0].current_instance.resource_details.ec2_resource_details.hourly_on_demand_rate #=> String
resp.rightsizing_recommendations[0].current_instance.resource_details.ec2_resource_details.instance_type #=> String
resp.rightsizing_recommendations[0].current_instance.resource_details.ec2_resource_details.platform #=> String
resp.rightsizing_recommendations[0].current_instance.resource_details.ec2_resource_details.region #=> String
resp.rightsizing_recommendations[0].current_instance.resource_details.ec2_resource_details.sku #=> String
resp.rightsizing_recommendations[0].current_instance.resource_details.ec2_resource_details.memory #=> String
resp.rightsizing_recommendations[0].current_instance.resource_details.ec2_resource_details.network_performance #=> String
resp.rightsizing_recommendations[0].current_instance.resource_details.ec2_resource_details.storage #=> String
resp.rightsizing_recommendations[0].current_instance.resource_details.ec2_resource_details.vcpu #=> String
resp.rightsizing_recommendations[0].current_instance.resource_utilization.ec2_resource_utilization.max_cpu_utilization_percentage #=> String
resp.rightsizing_recommendations[0].current_instance.resource_utilization.ec2_resource_utilization.max_memory_utilization_percentage #=> String
resp.rightsizing_recommendations[0].current_instance.resource_utilization.ec2_resource_utilization.max_storage_utilization_percentage #=> String
resp.rightsizing_recommendations[0].current_instance.reservation_covered_hours_in_lookback_period #=> String
resp.rightsizing_recommendations[0].current_instance.savings_plans_covered_hours_in_lookback_period #=> String
resp.rightsizing_recommendations[0].current_instance.on_demand_hours_in_lookback_period #=> String
resp.rightsizing_recommendations[0].current_instance.total_running_hours_in_lookback_period #=> String
resp.rightsizing_recommendations[0].current_instance.monthly_cost #=> String
resp.rightsizing_recommendations[0].current_instance.currency_code #=> String
resp.rightsizing_recommendations[0].rightsizing_type #=> String, one of "TERMINATE", "MODIFY"
resp.rightsizing_recommendations[0].modify_recommendation_detail.target_instances #=> Array
resp.rightsizing_recommendations[0].modify_recommendation_detail.target_instances[0].estimated_monthly_cost #=> String
resp.rightsizing_recommendations[0].modify_recommendation_detail.target_instances[0].estimated_monthly_savings #=> String
resp.rightsizing_recommendations[0].modify_recommendation_detail.target_instances[0].currency_code #=> String
resp.rightsizing_recommendations[0].modify_recommendation_detail.target_instances[0].default_target_instance #=> true/false
resp.rightsizing_recommendations[0].modify_recommendation_detail.target_instances[0].resource_details.ec2_resource_details.hourly_on_demand_rate #=> String
resp.rightsizing_recommendations[0].modify_recommendation_detail.target_instances[0].resource_details.ec2_resource_details.instance_type #=> String
resp.rightsizing_recommendations[0].modify_recommendation_detail.target_instances[0].resource_details.ec2_resource_details.platform #=> String
resp.rightsizing_recommendations[0].modify_recommendation_detail.target_instances[0].resource_details.ec2_resource_details.region #=> String
resp.rightsizing_recommendations[0].modify_recommendation_detail.target_instances[0].resource_details.ec2_resource_details.sku #=> String
resp.rightsizing_recommendations[0].modify_recommendation_detail.target_instances[0].resource_details.ec2_resource_details.memory #=> String
resp.rightsizing_recommendations[0].modify_recommendation_detail.target_instances[0].resource_details.ec2_resource_details.network_performance #=> String
resp.rightsizing_recommendations[0].modify_recommendation_detail.target_instances[0].resource_details.ec2_resource_details.storage #=> String
resp.rightsizing_recommendations[0].modify_recommendation_detail.target_instances[0].resource_details.ec2_resource_details.vcpu #=> String
resp.rightsizing_recommendations[0].modify_recommendation_detail.target_instances[0].expected_resource_utilization.ec2_resource_utilization.max_cpu_utilization_percentage #=> String
resp.rightsizing_recommendations[0].modify_recommendation_detail.target_instances[0].expected_resource_utilization.ec2_resource_utilization.max_memory_utilization_percentage #=> String
resp.rightsizing_recommendations[0].modify_recommendation_detail.target_instances[0].expected_resource_utilization.ec2_resource_utilization.max_storage_utilization_percentage #=> String
resp.rightsizing_recommendations[0].terminate_recommendation_detail.estimated_monthly_savings #=> String
resp.rightsizing_recommendations[0].terminate_recommendation_detail.currency_code #=> String
resp.next_page_token #=> String

Options Hash (options):

  • :filter (Types::Expression)

    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 REGION==us-east-1 OR REGION==us-west-1. The Expression for that looks like this:

      { "Dimensions": { "Key": "REGION", "Values": [ "us-east-1", “us-west-1” ] } }

      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 ((REGION == us-east-1 OR REGION == us-west-1) OR (TAG.Type == Type1)) AND (USAGE_TYPE != DataTransfer). The Expression for that looks like this:

      { "And": [ {"Or": [ {"Dimensions": { "Key": "REGION", "Values": [ "us-east-1", "us-west-1" ] }}, {"Tags": { "Key": "TagName", "Values": ["Value1"] } } ]}, {"Not": {"Dimensions": { "Key": "USAGE_TYPE", "Values": ["DataTransfer"] }}} ] }

      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 creates an error.

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

    For GetRightsizingRecommendation action, a combination of OR and NOT is not supported. OR is not supported between different dimensions, or dimensions and tags. NOT operators aren't supported. Dimensions are also limited to LINKED_ACCOUNT, REGION, or RIGHTSIZING_TYPE.

  • :service (required, String)

    The specific service that you want recommendations for. The only valid value for GetRightsizingRecommendation is \"AmazonEC2\".

  • :page_size (Integer)

    The number of recommendations that you want returned in a single response object.

  • :next_page_token (String)

    The pagination token that indicates the next set of results that you want to retrieve.

Returns:

See Also:

#get_savings_plans_coverage(options = {}) ⇒ Types::GetSavingsPlansCoverageResponse

Retrieves the Savings Plans covered for your account. This enables you to see how much of your cost is covered by a Savings Plan. An organization’s master account can see the coverage of the associated member accounts. For any time period, you can filter data for Savings Plans usage with the following dimensions:

  • LINKED_ACCOUNT

  • REGION

  • SERVICE

  • INSTANCE_FAMILY

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

Examples:

Request syntax with placeholder values


resp = client.get_savings_plans_coverage({
  time_period: { # required
    start: "YearMonthDay", # required
    end: "YearMonthDay", # required
  },
  group_by: [
    {
      type: "DIMENSION", # accepts DIMENSION, TAG
      key: "GroupDefinitionKey",
    },
  ],
  granularity: "DAILY", # accepts DAILY, MONTHLY, HOURLY
  filter: {
    or: [
      {
        # recursive Expression
      },
    ],
    and: [
      {
        # recursive Expression
      },
    ],
    not: {
      # recursive Expression
    },
    dimensions: {
      key: "AZ", # accepts 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, BILLING_ENTITY, RESERVATION_ID, RESOURCE_ID, RIGHTSIZING_TYPE, SAVINGS_PLANS_TYPE, SAVINGS_PLAN_ARN, PAYMENT_OPTION
      values: ["Value"],
    },
    tags: {
      key: "TagKey",
      values: ["Value"],
    },
  },
  metrics: ["MetricName"],
  next_token: "NextPageToken",
  max_results: 1,
})

Response structure


resp.savings_plans_coverages #=> Array
resp.savings_plans_coverages[0].attributes #=> Hash
resp.savings_plans_coverages[0].attributes["AttributeType"] #=> <Hash,Array,String,Numeric,Boolean,IO,Set,nil>
resp.savings_plans_coverages[0].coverage.spend_covered_by_savings_plans #=> String
resp.savings_plans_coverages[0].coverage.on_demand_cost #=> String
resp.savings_plans_coverages[0].coverage.total_cost #=> String
resp.savings_plans_coverages[0].coverage.coverage_percentage #=> String
resp.savings_plans_coverages[0].time_period.start #=> String
resp.savings_plans_coverages[0].time_period.end #=> String
resp.next_token #=> String

Options Hash (options):

  • :time_period (required, Types::DateInterval)

    The time period that you want the usage and costs for. The Start date must be within 13 months. The End date must be after the Start date, and before the current date. Future dates can\'t be used as an End date.

  • :group_by (Array<Types::GroupDefinition>)

    You can group the data using the attributes INSTANCE_FAMILY, REGION, or SERVICE.

  • :granularity (String)

    The granularity of the Amazon Web Services cost data for your Savings Plans. Granularity can\'t be set if GroupBy is set.

    The GetSavingsPlansCoverage operation supports only DAILY and MONTHLY granularities.

  • :filter (Types::Expression)

    Filters Savings Plans coverage data by dimensions. You can filter data for Savings Plans usage with the following dimensions:

    • LINKED_ACCOUNT

    • REGION

    • SERVICE

    • INSTANCE_FAMILY

    GetSavingsPlansCoverage uses the same Expression object as the other operations, but only AND is supported among each dimension. If there are multiple values for a dimension, they are OR\'d together.

  • :metrics (Array<String>)

    The measurement that you want your Savings Plans coverage reported in. The only valid value is SpendCoveredBySavingsPlans.

  • :next_token (String)

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

  • :max_results (Integer)

    The number of items to be returned in a response. The default is 20, with a minimum value of 1.

Returns:

See Also:

#get_savings_plans_purchase_recommendation(options = {}) ⇒ Types::GetSavingsPlansPurchaseRecommendationResponse

Retrieves your request parameters, Savings Plan Recommendations Summary and Details.

Examples:

Request syntax with placeholder values


resp = client.get_savings_plans_purchase_recommendation({
  savings_plans_type: "COMPUTE_SP", # required, accepts COMPUTE_SP, EC2_INSTANCE_SP
  term_in_years: "ONE_YEAR", # required, accepts ONE_YEAR, THREE_YEARS
  payment_option: "NO_UPFRONT", # required, accepts NO_UPFRONT, PARTIAL_UPFRONT, ALL_UPFRONT, LIGHT_UTILIZATION, MEDIUM_UTILIZATION, HEAVY_UTILIZATION
  next_page_token: "NextPageToken",
  page_size: 1,
  lookback_period_in_days: "SEVEN_DAYS", # required, accepts SEVEN_DAYS, THIRTY_DAYS, SIXTY_DAYS
})

Response structure


resp..recommendation_id #=> String
resp..generation_timestamp #=> String
resp.savings_plans_purchase_recommendation.savings_plans_type #=> String, one of "COMPUTE_SP", "EC2_INSTANCE_SP"
resp.savings_plans_purchase_recommendation.term_in_years #=> String, one of "ONE_YEAR", "THREE_YEARS"
resp.savings_plans_purchase_recommendation.payment_option #=> String, one of "NO_UPFRONT", "PARTIAL_UPFRONT", "ALL_UPFRONT", "LIGHT_UTILIZATION", "MEDIUM_UTILIZATION", "HEAVY_UTILIZATION"
resp.savings_plans_purchase_recommendation.lookback_period_in_days #=> String, one of "SEVEN_DAYS", "THIRTY_DAYS", "SIXTY_DAYS"
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_details #=> Array
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_details[0].savings_plans_details.region #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_details[0].savings_plans_details.instance_family #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_details[0].savings_plans_details.offering_id #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_details[0]. #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_details[0].upfront_cost #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_details[0].estimated_roi #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_details[0].currency_code #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_details[0].estimated_sp_cost #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_details[0].estimated_on_demand_cost #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_details[0].estimated_on_demand_cost_with_current_commitment #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_details[0].estimated_savings_amount #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_details[0].estimated_savings_percentage #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_details[0].hourly_commitment_to_purchase #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_details[0].estimated_average_utilization #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_details[0].estimated_monthly_savings_amount #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_details[0].current_minimum_hourly_on_demand_spend #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_details[0].current_maximum_hourly_on_demand_spend #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_details[0].current_average_hourly_on_demand_spend #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_summary.estimated_roi #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_summary.currency_code #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_summary.estimated_total_cost #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_summary.current_on_demand_spend #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_summary.estimated_savings_amount #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_summary.total_recommendation_count #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_summary.daily_commitment_to_purchase #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_summary.hourly_commitment_to_purchase #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_summary.estimated_savings_percentage #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_summary.estimated_monthly_savings_amount #=> String
resp.savings_plans_purchase_recommendation.savings_plans_purchase_recommendation_summary.estimated_on_demand_cost_with_current_commitment #=> String
resp.next_page_token #=> String

Options Hash (options):

  • :savings_plans_type (required, String)

    The Savings Plans recommendation type requested.

  • :term_in_years (required, String)

    The savings plan recommendation term used to generated these recommendations.

  • :payment_option (required, String)

    The payment option used to generate these recommendations.

  • :next_page_token (String)

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

  • :page_size (Integer)

    The number of recommendations that you want returned in a single response object.

  • :lookback_period_in_days (required, String)

    The lookback period used to generate the recommendation.

Returns:

See Also:

#get_savings_plans_utilization(options = {}) ⇒ Types::GetSavingsPlansUtilizationResponse

Retrieves the Savings Plans utilization for your account across date ranges with daily or monthly granularity. Master accounts in an organization have access to member accounts. You can use GetDimensionValues in SAVINGS_PLANS to determine the possible dimension values.

You cannot group by any dimension values for GetSavingsPlansUtilization.

Examples:

Request syntax with placeholder values


resp = client.get_savings_plans_utilization({
  time_period: { # required
    start: "YearMonthDay", # required
    end: "YearMonthDay", # required
  },
  granularity: "DAILY", # accepts DAILY, MONTHLY, HOURLY
  filter: {
    or: [
      {
        # recursive Expression
      },
    ],
    and: [
      {
        # recursive Expression
      },
    ],
    not: {
      # recursive Expression
    },
    dimensions: {
      key: "AZ", # accepts 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, BILLING_ENTITY, RESERVATION_ID, RESOURCE_ID, RIGHTSIZING_TYPE, SAVINGS_PLANS_TYPE, SAVINGS_PLAN_ARN, PAYMENT_OPTION
      values: ["Value"],
    },
    tags: {
      key: "TagKey",
      values: ["Value"],
    },
  },
})

Response structure


resp.savings_plans_utilizations_by_time #=> Array
resp.savings_plans_utilizations_by_time[0].time_period.start #=> String
resp.savings_plans_utilizations_by_time[0].time_period.end #=> String
resp.savings_plans_utilizations_by_time[0].utilization.total_commitment #=> String
resp.savings_plans_utilizations_by_time[0].utilization.used_commitment #=> String
resp.savings_plans_utilizations_by_time[0].utilization.unused_commitment #=> String
resp.savings_plans_utilizations_by_time[0].utilization.utilization_percentage #=> String
resp.savings_plans_utilizations_by_time[0].savings.net_savings #=> String
resp.savings_plans_utilizations_by_time[0].savings.on_demand_cost_equivalent #=> String
resp.savings_plans_utilizations_by_time[0].amortized_commitment.amortized_recurring_commitment #=> String
resp.savings_plans_utilizations_by_time[0].amortized_commitment.amortized_upfront_commitment #=> String
resp.savings_plans_utilizations_by_time[0].amortized_commitment.total_amortized_commitment #=> String
resp.total.utilization.total_commitment #=> String
resp.total.utilization.used_commitment #=> String
resp.total.utilization.unused_commitment #=> String
resp.total.utilization.utilization_percentage #=> String
resp.total.savings.net_savings #=> String
resp.total.savings.on_demand_cost_equivalent #=> String
resp.total.amortized_commitment.amortized_recurring_commitment #=> String
resp.total.amortized_commitment.amortized_upfront_commitment #=> String
resp.total.amortized_commitment.total_amortized_commitment #=> String

Options Hash (options):

  • :time_period (required, Types::DateInterval)

    The time period that you want the usage and costs for. The Start date must be within 13 months. The End date must be after the Start date, and before the current date. Future dates can\'t be used as an End date.

  • :granularity (String)

    The granularity of the Amazon Web Services utillization data for your Savings Plans.

    The GetSavingsPlansUtilization operation supports only DAILY and MONTHLY granularities.

  • :filter (Types::Expression)

    Filters Savings Plans utilization coverage data for active Savings Plans dimensions. You can filter data with the following dimensions:

    • LINKED_ACCOUNT

    • SAVINGS_PLAN_ARN

    • SAVINGS_PLANS_TYPE

    • REGION

    • PAYMENT_OPTION

    • INSTANCE_TYPE_FAMILY

    GetSavingsPlansUtilization uses the same Expression object as the other operations, but only AND is supported among each dimension.

Returns:

See Also:

#get_savings_plans_utilization_details(options = {}) ⇒ Types::GetSavingsPlansUtilizationDetailsResponse

Retrieves attribute data along with aggregate utilization and savings data for a given time period. This doesn't support granular or grouped data (daily/monthly) in response. You can't retrieve data by dates in a single response similar to GetSavingsPlanUtilization, but you have the option to make multiple calls to GetSavingsPlanUtilizationDetails by providing individual dates. You can use GetDimensionValues in SAVINGS_PLANS to determine the possible dimension values.

GetSavingsPlanUtilizationDetails internally groups data by SavingsPlansArn.

Examples:

Request syntax with placeholder values


resp = client.get_savings_plans_utilization_details({
  time_period: { # required
    start: "YearMonthDay", # required
    end: "YearMonthDay", # required
  },
  filter: {
    or: [
      {
        # recursive Expression
      },
    ],
    and: [
      {
        # recursive Expression
      },
    ],
    not: {
      # recursive Expression
    },
    dimensions: {
      key: "AZ", # accepts 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, BILLING_ENTITY, RESERVATION_ID, RESOURCE_ID, RIGHTSIZING_TYPE, SAVINGS_PLANS_TYPE, SAVINGS_PLAN_ARN, PAYMENT_OPTION
      values: ["Value"],
    },
    tags: {
      key: "TagKey",
      values: ["Value"],
    },
  },
  next_token: "NextPageToken",
  max_results: 1,
})

Response structure


resp.savings_plans_utilization_details #=> Array
resp.savings_plans_utilization_details[0].savings_plan_arn #=> String
resp.savings_plans_utilization_details[0].attributes #=> Hash
resp.savings_plans_utilization_details[0].attributes["AttributeType"] #=> <Hash,Array,String,Numeric,Boolean,IO,Set,nil>
resp.savings_plans_utilization_details[0].utilization.total_commitment #=> String
resp.savings_plans_utilization_details[0].utilization.used_commitment #=> String
resp.savings_plans_utilization_details[0].utilization.unused_commitment #=> String
resp.savings_plans_utilization_details[0].utilization.utilization_percentage #=> String
resp.savings_plans_utilization_details[0].savings.net_savings #=> String
resp.savings_plans_utilization_details[0].savings.on_demand_cost_equivalent #=> String
resp.savings_plans_utilization_details[0].amortized_commitment.amortized_recurring_commitment #=> String
resp.savings_plans_utilization_details[0].amortized_commitment.amortized_upfront_commitment #=> String
resp.savings_plans_utilization_details[0].amortized_commitment.total_amortized_commitment #=> String
resp.total.utilization.total_commitment #=> String
resp.total.utilization.used_commitment #=> String
resp.total.utilization.unused_commitment #=> String
resp.total.utilization.utilization_percentage #=> String
resp.total.savings.net_savings #=> String
resp.total.savings.on_demand_cost_equivalent #=> String
resp.total.amortized_commitment.amortized_recurring_commitment #=> String
resp.total.amortized_commitment.amortized_upfront_commitment #=> String
resp.total.amortized_commitment.total_amortized_commitment #=> String
resp.time_period.start #=> String
resp.time_period.end #=> String
resp.next_token #=> String

Options Hash (options):

  • :time_period (required, Types::DateInterval)

    The time period that you want the usage and costs for. The Start date must be within 13 months. The End date must be after the Start date, and before the current date. Future dates can\'t be used as an End date.

  • :filter (Types::Expression)

    Filters Savings Plans utilization coverage data for active Savings Plans dimensions. You can filter data with the following dimensions:

    • LINKED_ACCOUNT

    • SAVINGS_PLAN_ARN

    • REGION

    • PAYMENT_OPTION

    • INSTANCE_TYPE_FAMILY

    GetSavingsPlansUtilizationDetails uses the same Expression object as the other operations, but only AND is supported among each dimension.

  • :next_token (String)

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

  • :max_results (Integer)

    The number of items to be returned in a response. The default is 20, with a minimum value of 1.

Returns:

See Also:

#get_tags(options = {}) ⇒ Types::GetTagsResponse

Queries for available tag keys and tag values for a specified period. You can search the tag values for an arbitrary string.

Examples:

Request syntax with placeholder values


resp = client.get_tags({
  search_string: "SearchString",
  time_period: { # required
    start: "YearMonthDay", # required
    end: "YearMonthDay", # required
  },
  tag_key: "TagKey",
  next_page_token: "NextPageToken",
})

Response structure


resp.next_page_token #=> String
resp.tags #=> Array
resp.tags[0] #=> String
resp.return_size #=> Integer
resp.total_size #=> Integer

Options Hash (options):

  • :search_string (String)

    The value that you want to search for.

  • :time_period (required, Types::DateInterval)

    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.

  • :tag_key (String)

    The key of the tag that you want to return values for.

  • :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.

Returns:

See Also:

#get_usage_forecast(options = {}) ⇒ Types::GetUsageForecastResponse

Retrieves a forecast for how much Amazon Web Services predicts that you will use over the forecast time period that you select, based on your past usage.

Examples:

Request syntax with placeholder values


resp = client.get_usage_forecast({
  time_period: { # required
    start: "YearMonthDay", # required
    end: "YearMonthDay", # required
  },
  metric: "BLENDED_COST", # required, accepts BLENDED_COST, UNBLENDED_COST, AMORTIZED_COST, NET_UNBLENDED_COST, NET_AMORTIZED_COST, USAGE_QUANTITY, NORMALIZED_USAGE_AMOUNT
  granularity: "DAILY", # required, accepts DAILY, MONTHLY, HOURLY
  filter: {
    or: [
      {
        # recursive Expression
      },
    ],
    and: [
      {
        # recursive Expression
      },
    ],
    not: {
      # recursive Expression
    },
    dimensions: {
      key: "AZ", # accepts 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, BILLING_ENTITY, RESERVATION_ID, RESOURCE_ID, RIGHTSIZING_TYPE, SAVINGS_PLANS_TYPE, SAVINGS_PLAN_ARN, PAYMENT_OPTION
      values: ["Value"],
    },
    tags: {
      key: "TagKey",
      values: ["Value"],
    },
  },
  prediction_interval_level: 1,
})

Response structure


resp.total.amount #=> String
resp.total.unit #=> String
resp.forecast_results_by_time #=> Array
resp.forecast_results_by_time[0].time_period.start #=> String
resp.forecast_results_by_time[0].time_period.end #=> String
resp.forecast_results_by_time[0].mean_value #=> String
resp.forecast_results_by_time[0].prediction_interval_lower_bound #=> String
resp.forecast_results_by_time[0].prediction_interval_upper_bound #=> String

Options Hash (options):

  • :time_period (required, Types::DateInterval)

    The start and end dates of the period that you want to retrieve usage forecast for. 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.

  • :metric (required, String)

    Which metric Cost Explorer uses to create your forecast.

    Valid values for a GetUsageForecast call are the following:

    • USAGE_QUANTITY

    • NORMALIZED_USAGE_AMOUNT

  • :granularity (required, String)

    How granular you want the forecast to be. You can get 3 months of DAILY forecasts or 12 months of MONTHLY forecasts.

    The GetUsageForecast operation supports only DAILY and MONTHLY granularities.

  • :filter (Types::Expression)

    The filters that you want to use to filter your forecast. Cost Explorer API supports all of the Cost Explorer filters.

  • :prediction_interval_level (Integer)

    Cost Explorer always returns the mean forecast as a single point. You can request a prediction interval around the mean by specifying a confidence level. The higher the confidence level, the more confident Cost Explorer is about the actual value falling in the prediction interval. Higher confidence levels result in wider prediction intervals.

Returns:

See Also:

#wait_until(waiter_name, params = {}) {|waiter| ... } ⇒ Boolean

Waiters polls an API operation until a resource enters a desired state.

Basic Usage

Waiters will poll until they are succesful, they fail by entering a terminal state, or until a maximum number of attempts are made.

# polls in a loop, sleeping between attempts client.waiter_until(waiter_name, params)

Configuration

You can configure the maximum number of polling attempts, and the delay (in seconds) between each polling attempt. You configure waiters by passing a block to #wait_until:

# poll for ~25 seconds
client.wait_until(...) do |w|
  w.max_attempts = 5
  w.delay = 5
end

Callbacks

You can be notified before each polling attempt and before each delay. If you throw :success or :failure from these callbacks, it will terminate the waiter.

started_at = Time.now
client.wait_until(...) do |w|

  # disable max attempts
  w.max_attempts = nil

  # poll for 1 hour, instead of a number of attempts
  w.before_wait do |attempts, response|
    throw :failure if Time.now - started_at > 3600
  end

end

Handling Errors

When a waiter is successful, it returns true. When a waiter fails, it raises an error. All errors raised extend from Waiters::Errors::WaiterFailed.

begin
  client.wait_until(...)
rescue Aws::Waiters::Errors::WaiterFailed
  # resource did not enter the desired state in time
end

Parameters:

  • waiter_name (Symbol)

    The name of the waiter. See #waiter_names for a full list of supported waiters.

  • params (Hash) (defaults to: {})

    Additional request parameters. See the #waiter_names for a list of supported waiters and what request they call. The called request determines the list of accepted parameters.

Yield Parameters:

Returns:

  • (Boolean)

    Returns true if the waiter was successful.

Raises:

  • (Errors::FailureStateError)

    Raised when the waiter terminates because the waiter has entered a state that it will not transition out of, preventing success.

  • (Errors::TooManyAttemptsError)

    Raised when the configured maximum number of attempts have been made, and the waiter is not yet successful.

  • (Errors::UnexpectedError)

    Raised when an error is encounted while polling for a resource that is not expected.

  • (Errors::NoSuchWaiterError)

    Raised when you request to wait for an unknown state.

#waiter_namesArray<Symbol>

Returns the list of supported waiters. The following table lists the supported waiters and the client method they call:

Waiter NameClient MethodDefault Delay:Default Max Attempts:

Returns:

  • (Array<Symbol>)

    the list of supported waiters.