To create a Capacity Reservation, specify the instance type, total quantity, start time, and availability zone.
Operation description
API
The Capacity Reservation service lets you reserve compute resources by specifying attributes such as the availability zone and instance type. The system then reserves matching resources in a private pool. For more information, see Overview of immediate capacity reservations.
- This service currently supports only the immediate start mode. After you purchase an immediate capacity reservation, you are billed for the reserved instance type at the standard Pay-As-You-Go rate. This billing applies regardless of whether you launch any Pay-As-You-Go instances and continues until you release the reservation or it expires.
You can specify the private pool option when creating an instance by calling the CreateInstance or RunInstances operations. To change this setting for an existing instance, call the ModifyInstanceAttachmentAttributes operation. After an instance matches a private pool, you are billed for its configured resources, such as the instance type, cloud disks, and public bandwidth.
If you do not launch any Pay-As-You-Go instances into the reserved capacity, you are billed only for the reserved instance type.
You can apply Savings Plans and Regional Reserved Instance Coupons to the hourly bills for both matched instances and unused capacity in your immediate capacity reservations. However, Zonal Reserved Instance Coupons are not supported. We recommend purchasing Savings Plans or Reserved Instance Coupons first. Using the Capacity Reservation service with coverage from these plans provides capacity assurance at no additional cost.
You can use the API to create only immediate capacity reservations. To create either immediate or scheduled capacity reservations, use the ECS Console. For more information, see Resource Reservation Service.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
ecs:CreateCapacityReservation |
create |
*CapacityReservation
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| RegionId |
string |
Yes |
The ID of the region in which to create the capacity reservation. You can call DescribeRegions to query the latest list of Alibaba Cloud regions. |
cn-hangzhou |
| ResourceGroupId |
string |
No |
The ID of the resource group to which the capacity reservation belongs. |
rg-bp67acfmxazb4p**** |
| Tag |
array<object> |
No |
The tags to add to the capacity reservation. |
|
|
object |
No |
A tag. |
||
| Key |
string |
No |
The tag key of the capacity reservation. Valid values of N: 1 to 20. The tag key cannot be an empty string. The tag key can be up to 128 characters in length and cannot start with |
TestKey |
| Value |
string |
No |
The tag value of the capacity reservation. Valid values of N: 1 to 20. The tag value can be an empty string. The tag value can be up to 128 characters in length and cannot start with |
TestValue |
| ClientToken |
string |
No |
A client-generated token that ensures the request is idempotent. You can use the same token to retry a request. The |
0c593ea1-3bea-11e9-b96b-88e9fe637760 |
| PrivatePoolOptions.Name |
string |
No |
The name of the capacity reservation. The name must be 2 to 128 characters in length. It must start with a letter or a Chinese character and cannot start with |
crpTestName |
| Description |
string |
No |
The description of the capacity reservation. The description must be 2 to 256 characters in length and cannot start with Default value: empty string. |
This is description. |
| PrivatePoolOptions.MatchCriteria |
string |
No |
The type of the private pool that is generated after the capacity reservation takes effect. Valid values:
Default value: Open. |
Open |
| InstanceAmount |
integer |
Yes |
The number of instances of the specified instance type for which to reserve capacity. |
2 |
| InstanceType |
string |
Yes |
The instance type for which to reserve capacity. You can call DescribeInstanceTypes to view the instance types that ECS provides. |
ecs.g6.xlarge |
| StartTime |
string |
No |
The time when the capacity reservation takes effect. The capacity reservation takes effect immediately after it is created. Note
If you do not specify this parameter, the capacity reservation takes effect immediately. |
2021-10-30T05:32:00Z |
| EndTime |
string |
No |
The end time of the capacity reservation. Specify the time in the ISO 8601 standard in the |
2021-10-30T06:32:00Z |
| EndTimeType |
string |
No |
The release mode of the capacity reservation. Valid values:
|
Unlimited |
| Platform |
string |
No |
The operating system of the image used by the instance. This parameter corresponds to the
Default value: Linux. Note
This parameter is not yet available for use. |
Linux |
| ZoneId |
array |
Yes |
cn-hangzhou-h |
|
|
string |
No |
The ID of the zone in which you want to create the capacity reservation. A capacity reservation can reserve resources within only one zone. |
cn-hangzhou-h |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| PrivatePoolOptionsId |
string |
The ID of the capacity reservation. |
crp-bp67acfmxazb4**** |
| RequestId |
string |
The request ID. |
473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E |
Examples
Success response
JSON format
{
"PrivatePoolOptionsId": "crp-bp67acfmxazb4****",
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | InvalidParameter.RegionId | The specified RegionId is invalid. | The specified region does not exist or is unavailable. |
| 400 | NoStock | The stock in the availability zone is insufficient. | The stock in the availability zone is insufficient. |
| 400 | MissingParameter | The input parameter StartTime is missing. | |
| 400 | OperationDenied | The specified instanceType or zone is not available or not authorized. | Specified specifications or Availability Zones are not available |
| 400 | MissingParameter.RegionId | The specified RegionId should not be null. | The RegionId parameter is required. |
| 400 | InvalidStartTime.NotSupported | The specified StartTime should be within 180 calendar days from the current date, and you must specify a precision to hour. | The specified StartTime value is out of range. |
| 400 | InvalidStartTime.MalFormed | The specified StartTime is out of the permitted range. | The specified StartTime value exceeds the maximum allowed value. |
| 400 | Invalid.PrivatePoolOptionsName.MalFormed | The specified PrivatePoolOptions.Name is not valid. | The specified PrivatePoolOptions.Name is invalid |
| 400 | Invalid.ZoneId | The specified ZoneId is not valid. | The specified ZoneId is invalid. |
| 400 | Invalid.InstanceType | The specified InstanceType is not valid. | The specified InstanceType is illegal. |
| 400 | DedicatedHostNotSupported | DedicatedHost is not supported for PrivatePool. | The private pool does not support dedicated hosts. |
| 400 | SpotNotSupported | Spot is not supported for PrivatePool. | The private pool does not support spot instances. |
| 400 | ClassicNetworkNotSupported | Classic network is not supported for PrivatePool. | The private pool does not support instances in the classic network. |
| 400 | Invalid.InstanceId | Instance does not exist. | The specified instance does not exist. |
| 400 | Invalid.PrivatePoolOptions.MatchCriteria | Target mode does not support this operation. | The operation is not supported while the PrivatePoolOptions.MatchCriteria parameter is set to Target. |
| 400 | MissingParameter.PrivatePoolOptions.Id | The specified PrivatePoolOptions.Id should not be null. | The PrivatePoolOptions.Id parameter is required. |
| 400 | Invalid.PrivatePoolOptions.Id | The PrivatePool does not exist. | The private pool does not exist. |
| 400 | Invalid.InstanceChargeType | The InstanceChargeType does not match the PrivatePool. | The instance billing method and the private pool do not match. |
| 400 | Invalid.PrivatePoolOptions.status | The PrivatePool has been used up. | The resource is exhausted. |
| 400 | InvalidPlatform.ValueNotSupported | The Platform does not match the PrivatePool. | The specified Platform parameter does not match the private pool. |
| 400 | InvalidAliUid | The PrivatePool does not belong to the user of the Instance. | The specified private pool does not belong to the user who attempted to create the instance. |
| 400 | MissingParameter.PackageType | The specified parameter "PackageType" can not be empty. | |
| 400 | MissingParameter.PrivatePoolOptions.Ids | The specified parameter "PrivatePoolOptions.Ids" can not be empty. | Specifies that the parameter "PrivatePoolOptions.ids" cannot be empty. |
| 400 | MissingParameter.InstanceCpuCoreCount | The specified parameter "InstanceCpuCoreCount" can not be empty. | The specified parameter 'InstanceCpuCocount' cannot be empty. |
| 400 | MissingParameter.InstanceAmount | The specified parameter "InstanceAmount" can not be empty. | The specified parameter InstanceAmount cannot be empty. |
| 400 | MissingParameter.InstanceCpuCoreCountOrInstanceAmount | The specified parameter "InstanceCpuCoreCount" and "InstanceAmount" must not be empty at the same time. | The specified parameter InstanceCpuCoreCount and InstanceAmount cannot be both empty. |
| 400 | Invalid.TooManyPrivatePoolOptions.Ids | Too many PrivatePoolOptions.Ids in this request. | The number of specified private pool IDs exceeds the upper limit. |
| 400 | Invalid.TooManyZoneIds | Too many ZoneIds in the request. | The number of specified zone IDs exceeds the upper limit. |
| 400 | Invalid.TooManyInstanceTypes | Too many InstanceTypes in the request. | The number of specified instance types exceeds the upper limit. |
| 400 | Invalid.TooManyUnpaidPrivatePool | Too many PrivatePools create but still unpaid. | Multiple private pools are created but not paid. |
| 400 | Invalid.InstanceCpuCoreCountOrInstanceAmount | Both InstanceCpuCoreCount and InstanceAmount are provided. | The InstanceCpuCoreCount and InstanceAmount parameters cannot be both specified. |
| 400 | Invalid.PrivatePoolOptions.Ids | The specified parameter "PrivatePoolOptions.Ids" exist invalid element Id. | The specified private pool ID does not exist. |
| 400 | Invalid.PackageType | The specified parameter "PackageType" is invalid. | The specified parameter PackageType is invalid. |
| 400 | Invalid.PrivatePool.Purchase | The PrivatePool has already paid. | The private pool is already paid. |
| 400 | Invalid.AssuranceTimes.NotSupported | The value of AssuranceTimes is not supported. | The specified AssuranceTimes parameter is invalid. |
| 400 | RepeatStartPrivatePool | PrivatePool has already been started. | The private pool is already started. |
| 400 | Invalid.TimeSlot | The param time slot is invalid. | Parameter TimeSlot is invalid. |
| 400 | Invalid.EndTime | The specified parameter "EndTime" is not valid. | The specified EndTime parameter is illegal. |
| 400 | StartTime.NotNeed | The specified parameter "StartTime" should leave empty. | The specified parameter "StartTime" should be empty. |
| 400 | AccountForbidden.ProductCreationLimited | The commodity must be officially operated by Aliyun and in pay-as-you-go billing method. | |
| 400 | RegionUnauthorized | There is no authority to create private pool in the specified region. | |
| 400 | PriceNotFound | The price of your queried resource is not available now, please try other resources. | The price of the specified resource does not exist. Modify the parameter value and try again later. |
| 500 | InternalError | The request processing has failed due to some unknown error, exception or failure. | An internal error has occurred. Try again later. |
| 403 | Zone.NotOpen | The specified zone is not granted to you to buy resources yet. | |
| 403 | InvalidResourceType.NotSupported | %s | The specified resource combination does not exist. Change to another zone or specification. |
| 403 | OperationDenied.NoStock | The resource is out of stock in the specified zone. Please try other types, or choose other regions and zones. | The requested resources are unavailable in the specified zone. Try a different resource type or select a different region or zone. |
| 403 | InvalidInstanceType.NotSupported | The specified InstanceType is invalid. | |
| 403 | Invalid.ZoneIds | At least one of the specified ZoneIds are invalid. | At least one of the specified ZoneIds is invalid. |
| 403 | Zone.NotOnSale | The specified zone is not available for purchase. | The requested resources are unavailable in the specified zone. Try a different instance type or select a different region or zone. |
| 404 | InvalidZoneId.NotFound | The specified zoneId does not exist. | The specified zone ID does not exist. |
| 404 | InvalidResourceGroup.NotFound | The ResourceGroup provided does not exist in our records. | The specified resource group does not exist. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.