Cost Estimates

The CostEstimate resource

A Cost Estimate is the details of the cost estimation phase of a run in Scalr.

Cost estimation is optional and is enabled/disable per environment. If enabled a cost estimation is performed immediately after Terraform plan has completed for every run in every workspace, including dry runs.

Key path

Description

type* (string)

Available values: cost-estimates

id (string)

attributes.delta-monthly-cost (string)

The change in the estimated cost ($) from the previous run (if any).

attributes.error-message (string)

When the cost estimate status is errored, this field contains the error description.

attributes.matched-resources-count (integer)

The number of resources in the terraform plan, that were included into the estimation.

Cost estimation in Scalr supports a number of terraform resources from major cloud providers

attributes.prior-monthly-cost (string)

The estimated current monthly cost ($).

attributes.proposed-monthly-cost (string)

The estimated monthly cost ($) if the plan is applied.

attributes.resources-count (integer)

The total number of resources in the terraform plan.

attributes.status (string)

Available values: pending, queued, finished, canceled, errored, unreachable

The Cost estimate’s current status.

Transient states:

  • pending - Cost estimation has been created but not yet queued.

  • queued - Queued and waiting for capacity to be available.

Final states:

  • canceled - The cost estimate has been canceled.

  • errored - The cost estimate has finished with an error. Attribute error-message contains the details.

  • finished - The cost estimate has completed successfully.

  • unreachable - The cost estimate will not run.

attributes.status-timestamps (object)

Date/Time of transition to each status that has occurred.

attributes.unmatched-resources-count (integer)

The number of resources in the terraform plan that were excluded from the estimation.

links.output (string)

Link to download the raw output of the cost estimation.

links.self (string)

Get a Cost Estimate

GET /api/iacp/v3/cost-estimates/{cost_estimate}

Show details of a specific Cost Estimate phase.

Parameters
  • cost_estimate (string) – The ID of the cost estimate. Obtain it from the Get a Workspace endpoint.

Example Request:

GET /api/iacp/v3/cost-estimates/{cost_estimate} HTTP/1.1
Host: my.scalr.io
Prefer: profile=preview
Status Codes
  • 200 OK

    Success.

    Example Respone:

    HTTP/1.1 200 OK
    Content-Type: application/vnd.api+json
    Preference-Applied: profile=preview
    
    {
      "data": {
        "attributes": {
          "delta-monthly-cost": "0.000",
          "error-message": null,
          "matched-resources-count": 0,
          "prior-monthly-cost": "0.000",
          "proposed-monthly-cost": "0.000",
          "resources-count": 7,
          "status": "finished",
          "status-timestamps": {
            "finished-at": "2020-03-11T00:37:04Z",
            "queued-at": "2020-03-11T00:37:03Z"
          },
          "unmatched-resources-count": 7
        },
        "id": "ce-spu6782unvc8pl8",
        "links": {
          "output": "https://my.scalr.io/api/iacp/v3/cost-estimates/ce-spu6782unvc8pl8/output",
          "self": "https://my.scalr.io/api/iacp/v3/cost-estimates/ce-spu6782unvc8pl8"
        },
        "relationships": {},
        "type": "cost-estimates"
      },
      "included": null,
      "meta": null
    }
    

  • 404 Not Found – Cost estimate not found or user unauthorized to perform action.

  • 4XX – Client error.

  • 5XX – Server error.

Cost Estimate Log

GET /api/iacp/v3/cost-estimates/{cost_estimate}/output

Download the raw text/plain output of the cost estimation.

Parameters
  • cost_estimate (string) –

    The ID of the cost estimate. Obtain it from the Get a Workspace endpoint.

Example Request:

GET /api/iacp/v3/cost-estimates/{cost_estimate}/output HTTP/1.1
Host: my.scalr.io
Prefer: profile=preview
Status Codes
  • 200 OK – Success.

  • 404 Not Found – Cost estimate not found or user unauthorized to perform action.

  • 4XX – Client error.

  • 5XX – Server error.