All Products
Search
Document Center

Resource Orchestration Service:GetTemplateEstimateCost

Last Updated:Jun 03, 2026

Queries the estimated prices of the resources in a template.

Operation description

  • For more information about the resources that support price inquiry in Resource Orchestration Service (ROS) templates, see the "Resource types that support price inquiry" section of the Estimate resource prices topic.

  • For more information about the resources that support price inquiry in Terraform templates, see the "ROS resources supported by Terraform" section of the ROS features and resources supported by Terraform topic.

The following sample code provides an example on how to query the estimated price of an elastic IP address (EIP) that you want to create based on a template. In this example, the following template is used:

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "Isp": {
      "Type": "String",
      "Default": "BGP"
    },
    "Name": {
      "Type": "String",
      "Default": "test"
    },
    "Netmode": {
      "Type": "String",
      "Default": "public"
    },
    "Bandwidth": {
      "Type": "Number",
      "Default": 5
    }
  },
  "Resources": {
    "NewEip": {
      "Type": "ALIYUN::VPC::EIP",
      "Properties": {
        "InstanceChargeType": "Prepaid",
        "PricingCycle": "Month",
        "Isp": {
          "Ref": "Isp"
        },
        "Period": 1,
        "DeletionProtection": false,
        "AutoPay": false,
        "Name": {
          "Ref": "Name"
        },
        "InternetChargeType": "PayByTraffic",
        "Netmode": {
          "Ref": "Netmode"
        },
        "Bandwidth": {
          "Ref": "Bandwidth"
        }
      }
    }
  }
}

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ros:GetTemplateEstimateCost

get

Template

acs:ros:{#regionId}:{#accountId}:template/{#TemplateId}

None None

Request parameters

Parameter

Type

Required

Description

Example

TemplateURL

string

No

The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must make sure that the value is unique among different requests.

The token can be up to 64 characters in length, and can contain letters, digits, hyphens (-), and underscores (_).

For more information, see Ensure idempotence.

oss://ros-template/demo

RegionId

string

Yes

The ID of the template. This parameter applies to shared and private templates.

Note

You must specify only one of the following parameters: TemplateBody, TemplateURL, TemplateId, and TemplateScratchId.

cn-hangzhou

TemplateBody

string

No

The structure that contains the template body. The template body must be 1 to 524,288 bytes in length. If the length of the template body exceeds the upper limit, we recommend that you add parameters to the HTTP POST request body to prevent request failures caused by excessively long URLs.

Note

You must and can specify only one of the following parameters: TemplateBody, TemplateURL, TemplateId, and TemplateScratchId.

ROSTemplateFormatVersion: '2015-09-01'\nResources:\n vpc:\n Type: ALIYUN::ECS::VPC

ClientToken

string

No

The name of parameter N. If you do not specify the name and value of a parameter, ROS uses the default name and value that are specified in the template.

Maximum value of N: 200.

Examples:

  • Parameters.1.ParameterKey: Name

  • Parameters.2.ParameterKey: Netmode

Note

The Parameters parameter is optional. If you want to specify Parameters, you must specify both Parameters.N.ParameterKey and Parameters.N.ParameterValue.

123e4567-e89b-12d3-a456-42665544****

TemplateId

string

No

The value of parameter N.

Maximum value of N: 200.

Examples:

  • Parameters.1.ParameterValue: DemoEip

  • Parameters.2.ParameterValue: public

Note

The Parameters parameter is optional. If you want to specify Parameters, you must specify both Parameters.N.ParameterKey and Parameters.N.ParameterValue.

5ecd1e10-b0e9-4389-a565-e4c15efc****

TemplateVersion

string

No

The ID of the scenario.

For more information about how to query the IDs of scenarios, see ListTemplateScratches.

Note

You must specify only one of the following parameters: TemplateBody, TemplateURL, TemplateId, and TemplateScratchId.

v1

Parameters

array<object>

No

The region ID of the scenario. The default value is the same as the value of the RegionId parameter.

You can call the DescribeRegions operation to query the most recent region list.

object

No

The list of parameters.

ParameterKey

string

Yes

The ID of the request.

Name

ParameterValue

string

Yes

Details of the resource.

DemoEip

TemplateScratchId

string

No

The ID of the scenario.

ts-aa9c62feab844a6b****

TemplateScratchRegionId

string

No

The region ID of the scenario. The default value is the same as the value of the RegionId parameter.

You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou

StackId

string

No

The stack ID.

This parameter is used to query the estimated price in a configuration change scenario.

Assume that the specified stack contains only one Elastic Compute Service (ECS) instance and the instance type is ecs.s6-c1m2.large. You downgrade the instance type to ecs.s6-c1m1.small and specify a new ApsaraDB RDS instance in the template that is used for the price inquiry. The queried result is the sum of the downgrade refund of the ECS instance and the price of the new ApsaraDB RDS instance.

c754d2a4-28f1-46df-b557-9586173a****

For more information about common request parameters, see Common parameters.

Response elements

Element

Type

Description

Example

object

RequestId

string

The ID of the request.

6DEA36EF-C97D-5658-A4AC-4F5DB08D1A89

Resources

object

The resource details.

{   "NewEip": {     "Type": "ALIYUN::VPC::EIP",     "Success": true,     "Result": {       "Order": {         "TaxAmount": 0.0,         "Currency": "CNY",         "RuleIds": [           "102204102264****"         ],         "TradeAmount": 87.5,         "OriginalAmount": 125.0,         "DiscountAmount": 37.5       },       "OrderSupplement": {         "ChargeType": "PrePaid",         "Period": 1,         "Quantity": 1,         "PriceType": "Total",         "PeriodUnit": "Month"       },       "InquiryType": "Buy",       "Rules": {         "Rule": [           {             "RuleDescId": "102204102264****",             "Name": "Contract_Discount_Full_Order_30%_Off"           }         ]       }     }   } }

The following table describes the parameters that are contained in Resources.

ParameterTypeExampleDescription
OrderThe information about the order.
- CurrencyStringCNYThe currency unit. Valid values:CNY: This value is available only on the China site (aliyun.com).USD: This value is available only on the international site (alibabacloud.com)
- OriginalAmountLong125The original price.
- DiscountAmountLong15.63The discount amount.
- TradeAmountLong109.37The transaction price, which is equal to the original price minus the discount.
- TaxAmountLong0The available tax amount.
- CouponsArray{"Coupon": []}The available promotions.
- RuleIdsArray[102204102264****]The IDs of the promotion rules.
InquiryTypeStringBuyThe price inquiry type. Valid values:Buy: price inquiry for new resourcesModificationBuy: price inquiry for resource configuration changes
RulesThe promotion rules.
- RuleThe promotion rule.
- - NameStringContract discount_order discount_8.750 discountThe name of the promotion rule.
- - RuleDescIdLong102204102264****The ID of the promotion rule.
OrderSupplementThe supplementary information about the order.
- AutoRenewBooleanfalseSpecifies whether to enable auto-renewal. Valid values:truefalse
- ChargeTypeStringPrePaidThe billing method.
- PeriodLong1The subscription duration.
- PeriodUnitStringMonthThe unit of the subscription duration. Valid values:YearMonth
- PriceTypeStringTotalThe price type.
- QuantityLong1The quantity.

Examples

Success response

JSON format

{
  "RequestId": "6DEA36EF-C97D-5658-A4AC-4F5DB08D1A89",
  "Resources": {
    "test": "test",
    "test2": 1
  }
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.