All Products
Search
Document Center

Elastic Compute Service:CreateCapacityReservation

更新時間:Dec 24, 2024

Creates a capacity reservation. When you call this operation, you can specify parameters in the request, such as InstanceAmount, InstanceType, StartTime, and ZoneId.

Operation description

When you create a capacity reservation, you can specify attributes such as a zone and an instance type. The system uses a private pool to reserve resources that match the specified attributes. For more information, see Overview of Immediate Capacity Reservation.

  • Currently, only immediate capacity reservations are supported. Immediate capacity reservations take effect immediately after you purchase them. After you purchase an immediate capacity reservation, you are charged for the specified instance type based on the pay-as-you-go billing method regardless of whether you use the capacity reservation to create pay-as-you-go instances. Billing stops when you manually release the capacity reservation or when the capacity reservation expires and is automatically released.

    • You can call the CreateInstance or RunInstances operation to specify private pool attributes when you create instances. To modify the attributes of a private pool, you can call the ModifyInstanceAttachmentAttributes operation. If an instance matches a private pool associated with a capacity reservation, you are charged based on the configurations of the instance such as the instance type, disks, and public bandwidth.
    • Before you use a private pool associated with a capacity reservation to create pay-as-you-go instances, you are charged only for the specified instance type.
  • You can apply savings plans or regional reserved instances to offset hourly billing of unused immediate capacity reservations, and hourly fees of the instances that match the immediate capacity reservations. However, you cannot use zonal reserved instances to offset the hourly fees. We recommend that you purchase reserved instances or savings plans before you purchase immediate capacity reservations. This way, you can access resources free of charge within the coverage of the reserved instances or savings plans.

Note You can call the CreateCapacityReservation operation to create only immediate capacity reservations. You can create immediate or scheduled capacity reservations in the Elastic Compute Service (ECS) console. For more information, see Overview .

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
ecs:CreateCapacityReservationcreate
*CapacityReservation
acs:ecs:{#regionId}:{#accountId}:capacityreservation/*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

The ID of the region in which to create the capacity reservation. You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou
ResourceGroupIdstringNo

The ID of the resource group to which you want to assign the capacity reservation.

rg-bp67acfmxazb4p****
Tagarray<object>No

The tags to add to the capacity reservation.

objectNo
KeystringNo

The key of tag N to add to 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 contain http:// or https://. The tag key cannot start with acs: or aliyun.

TestKey
ValuestringNo

The value of tag N to add to 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 contain http:// or https://. The tag value cannot start with acs:.

TestValue
ClientTokenstringNo

The client token that is used to ensure the idempotency of the request. You can use the client to generate the token, but you must make sure that the token is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

0c593ea1-3bea-11e9-b96b-88e9fe637760
PrivatePoolOptions.NamestringNo

The capacity reservation name. The name must be 2 to 128 characters in length. It must start with a letter but cannot start with http:// or https://. The name can contain letters, digits, colons (:), underscores (_), and hyphens (-).

crpTestName
DescriptionstringNo

The description of the capacity reservation. The description must be 2 to 256 characters in length and cannot start with http:// or https://.

This parameter is empty by default.

This is description.
PrivatePoolOptions.MatchCriteriastringNo

The type of the private pool to generate after the capacity reservation takes effect. Valid values:

  • Open: open private pool
  • Target: targeted private pool

Default value: Open.

Open
InstanceAmountintegerYes

The total number of instances for which the capacity of an instance type is reserved.

2
InstanceTypestringYes

The instance type. You can create a capacity reservation to reserve the capacity of only one instance type. You can call the DescribeInstanceTypes operation to query the instance types provided by ECS.

ecs.g6.xlarge
StartTimestringNo

The mode in which the capacity reservation takes effect. You can call the CreateCapacityReservation operation to create only immediate capacity reservations.

Note If you do not specify this parameter, the capacity reservation immediately takes effect.
2021-10-30T05:32:00Z
EndTimestringNo

The time when the capacity reservation expires. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC. For more information, see ISO 8601.

2021-10-30T06:32:00Z
EndTimeTypestringNo

The release mode of the capacity reservation. Valid values:

  • Limited: The capacity reservation is automatically released at a specified time. If you specify this parameter, you must specify the EndTime parameter.
  • Unlimited: The capacity reservation is manually released. The capacity reservation can be released anytime.
Unlimited
PlatformstringNo

The operating system of the image used by the instance. This parameter corresponds to the Platform parameter of regional reserved instances. If the operating system of a capacity reservation matches the operating system of a regional reserved instance, you can apply the regional reserved instance to offset fees of the unused capacity of the capacity reservation. Valid values:

  • Windows: Windows Server operating system
  • Linux: Linux and UNIX-like operating system

Default value: Linux.

Note This parameter is unavailable.
Linux
ZoneIdarrayYes

The ID of the zone in which you want to create the capacity reservation. A capacity reservation can reserve resources within only one zone.

stringYes

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 parameters

ParameterTypeDescriptionExample
object
PrivatePoolOptionsIdstring

The capacity reservation ID.

crp-bp67acfmxazb4****
RequestIdstring

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

Examples

Sample success responses

JSONformat

{
  "PrivatePoolOptionsId": "crp-bp67acfmxazb4****",
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E"
}

Error codes

HTTP status codeError codeError messageDescription
400NoStockIt has not enough stock in the iz.-
400MissingParameterThe input parameter StartTime is missing.-
400OperationDeniedThe specified InstanceType or Zone is not available or not authorized.The specified instance type or zone is unavailable or you are not authorized to use the specified instance type or access the specified zone.
400MissingParameter.RegionIdThe specified RegionId should not be null.The RegionId parameter is required.
400InvalidStartTime.NotSupportedThe 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.
400InvalidStartTime.MalFormedThe specified StartTime is out of the permitted range.The specified StartTime value exceeds the maximum allowed value.
400Invalid.PrivatePoolOptionsName.MalFormedThe specified PrivatePoolOptions.Name is not valid.-
400Invalid.ZoneIdThe specified ZoneId is not valid.-
400Invalid.InstanceTypeThe specified InstanceType is not valid.-
400DedicatedHostNotSupportedDedicatedHost is not supported for PrivatePool.The private pool does not support dedicated hosts.
400SpotNotSupportedSpot is not supported for PrivatePool.The private pool does not support preemptible instances.
400ClassicNetworkNotSupportedClassic network is not supported for PrivatePool.The private pool does not support instances in the classic network.
400Invalid.InstanceIdInstance does not exist.The specified instance does not exist.
400Invalid.PrivatePoolOptions.MatchCriteriaTarget mode does not support this operation.The operation is not supported while the PrivatePoolOptions.MatchCriteria parameter is set to Target.
400MissingParameter.PrivatePoolOptions.IdThe specified PrivatePoolOptions.Id should not be null.The PrivatePoolOptions.Id parameter is required.
400Invalid.PrivatePoolOptions.IdThe PrivatePool does not exist.The private pool does not exist.
400Invalid.InstanceTypeThe InstanceType does not match the PrivatePool.The instance type and the private pool do not match.
400Invalid.InstanceChargeTypeThe InstanceChargeType does not match the PrivatePool.The instance billing method and the private pool do not match.
400Invalid.ZoneIdThe ZoneId does not match the PrivatePool.The zone and the private pool do not match.
400Invalid.PrivatePoolOptions.statusThe PrivatePool has been used up.-
400Invalid.PrivatePoolOptions.MatchCriteriaThe PrivatePoolOptions.MatchCriteria does not match the PrivatePool.The specified PrivatePoolOptions.MatchCriteria parameter does not match the private pool.
400InvalidPlatform.ValueNotSupportedThe Platform does not match the PrivatePool.The specified Platform parameter does not match the private pool.
400Invalid.PrivatePoolOptions.statusThe PrivatePool is expired or inactive.-
400Invalid.PrivatePoolOptions.statusThe PrivatePool status is not valid.-
400Invalid.PrivatePoolOptions.statusThe Instance should be created within 48 hours once the PrivatePool is started.-
400InvalidAliUidThe 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.
400Invalid.InstanceIdThe Instance dose not attached to a PrivatePool.The instance and the private pool do not match.
400MissingParameter.PackageTypeThe specified parameter "PackageType" can not be empty.-
400MissingParameter.PrivatePoolOptions.IdsThe specified parameter "PrivatePoolOptions.Ids" can not be empty.-
400MissingParameter.PrivatePoolOptions.IdThe specified parameter "PrivatePoolOptions.Id" can not be empty.-
400MissingParameter.InstanceCpuCoreCountThe specified parameter "InstanceCpuCoreCount" can not be empty.-
400MissingParameter.InstanceAmountThe specified parameter "InstanceAmount" can not be empty.-
400MissingParameter.InstanceCpuCoreCountOrInstanceAmountThe specified parameter "InstanceCpuCoreCount" and "InstanceAmount" must not be empty at the same time.-
400Invalid.TooManyPrivatePoolOptions.IdsToo many PrivatePoolOptions.Ids in this request.The number of specified private pool IDs exceeds the upper limit.
400Invalid.TooManyZoneIdsToo many ZoneIds in the request.The number of specified zone IDs exceeds the upper limit.
400Invalid.TooManyInstanceTypesToo many InstanceTypes in the request.The number of specified instance types exceeds the upper limit.
400Invalid.TooManyUnpaidPrivatePoolToo many PrivatePools create but still unpaid.Multiple private pools are created but not paid.
400Invalid.InstanceCpuCoreCountOrInstanceAmountBoth InstanceCpuCoreCount and InstanceAmount are provided.The InstanceCpuCoreCount and InstanceAmount parameters cannot be both specified.
400Invalid.PrivatePoolOptions.IdsThe specified parameter "PrivatePoolOptions.Ids" exist invalid element Id.-
400Invalid.PackageTypeThe specified parameter "PackageType" is invalid.-
400Invalid.PrivatePool.PurchaseThe PrivatePool has already paid.The private pool is already paid.
400Invalid.AssuranceTimes.NotSupportedThe value of AssuranceTimes is not supported.The specified AssuranceTimes parameter is invalid.
400Invalid.TooManyInstanceTypesThe specified parameter "InstanceType" should only has one item.-
400Invalid.PrivatePoolOptions.MatchCriteriaThe specified parameter "PrivatePoolOptions.MatchCriteria" is invalid.-
400RepeatStartPrivatePoolPrivatePool has already been started.The private pool is already started.
400Invalid.PrivatePoolOptions.IdThe specified parameter "PrivatePoolOptions.Id" should be empty.-
400Invalid.InstanceIdModify DedicatedHost Instance's attachment attributes is not supported.-
400Invalid.InstanceIdModify Spot Instance's attachment attributes is not supported.-
400Invalid.InstanceIdModify Classic Network Instance's attachment attributes is not supported.-
400Invalid.TimeSlotThe param time slot is invalid.-
400Invalid.EndTimeThe specified parameter "EndTime" is not valid.-
400StartTime.NotNeedThe specified parameter "StartTime" should leave empty.-
400AccountForbidden.ProductCreationLimitedThe commodity must be officially operated by Aliyun and in pay-as-you-go billing method.-
400RegionUnauthorizedThere is no authority to create private pool in the specified region.-
400PriceNotFoundThe 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.
403Zone.NotOpenThe specified zone is not granted to you to buy resources yet.You are not authorized to purchase resources in the specified zone.
403InvalidResourceType.NotSupported%s-
403OperationDenied.NoStockThe 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.
403InvalidInstanceType.NotSupportedThe specified InstanceType is invalid.-
403Invalid.ZoneIdsAt least one of the specified ZoneIds are invalid.-
403Zone.NotOnSaleThe 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.
404InvalidZoneId.NotFoundThe specified zoneId does not exist.The specified zone ID does not exist.
404InvalidResourceGroup.NotFoundThe ResourceGroup provided does not exist in our records.The specified resource group does not exist.
500InternalErrorThe request processing has failed due to some unknown error, exception or failure.An internal error has occurred. Try again later.
500InternalErrorThe request processing has failed due to some unknown error.An internal error has occurred. Try again later.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2021-07-29The Error code has changedView Change Details