Skip to main content

capacity_reservations

Creates, updates, deletes, gets or lists a capacity_reservations resource.

Overview

Namecapacity_reservations
TypeResource
Idaws.ec2.capacity_reservations

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
availability_zonestringThe Availability Zone in which the capacity is reserved.
availability_zone_idstringThe ID of the Availability Zone in which the capacity is reserved.
available_instance_countintegerThe remaining capacity. Indicates the number of instances that can be launched in the Capacity Reservation.
capacity_allocationsstringInformation about instance capacity usage.
capacity_block_idstringThe ID of the Capacity Block.
capacity_reservation_arnstringThe Amazon Resource Name (ARN) of the Capacity Reservation.
capacity_reservation_fleet_idstringThe ID of the Capacity Reservation Fleet to which the Capacity Reservation belongs. Only valid for Capacity Reservations that were created by a Capacity Reservation Fleet.
capacity_reservation_idstringThe ID of the Capacity Reservation.
commitment_infostringInformation about your commitment for a future-dated Capacity Reservation.
create_datestringThe date and time the Capacity Reservation was created.
delivery_preferencestringThe delivery method for a future-dated Capacity Reservation. incremental indicates that the requested capacity is delivered in addition to any running instances and reserved capacity that you have in your account at the requested date and time.
ebs_optimizedbooleanIndicates whether the Capacity Reservation supports EBS-optimized instances. This optimization provides dedicated throughput to Amazon EBS and an optimized configuration stack to provide optimal I/O performance. This optimization isn't available with all instance types. Additional usage charges apply when using an EBS- optimized instance.
end_datestringThe date and time the Capacity Reservation expires. When a Capacity Reservation expires, the reserved capacity is released and you can no longer launch instances into it. The Capacity Reservation's state changes to expired when it reaches its end date and time.
end_date_typestringIndicates the way in which the Capacity Reservation ends. A Capacity Reservation can have one of the following end types: unlimited - The Capacity Reservation remains active until you explicitly cancel it. limited - The Capacity Reservation expires automatically at a specified date and time.
ephemeral_storagebooleanDeprecated.
instance_match_criteriastringIndicates the type of instance launches that the Capacity Reservation accepts. The options include: open - The Capacity Reservation accepts all instances that have matching attributes (instance type, platform, and Availability Zone). Instances that have matching attributes launch into the Capacity Reservation automatically without specifying any additional parameters. targeted - The Capacity Reservation only accepts instances that have matching attributes (instance type, platform, and Availability Zone), and explicitly target the Capacity Reservation. This ensures that only permitted instances can use the reserved capacity.
instance_platformstringThe type of operating system for which the Capacity Reservation reserves capacity.
instance_typestringThe type of instance for which the Capacity Reservation reserves capacity.
interruptiblebooleanIndicates whether this Capacity Reservation is interruptible, meaning instances may be terminated when the owner reclaims capacity.
interruptible_capacity_allocationstringContains allocation details for interruptible reservations, including current allocated instances and target instance counts within the interruptibleCapacityAllocation object.
interruption_infostringInformation about the interruption configuration and association with the source reservation for interruptible Capacity Reservations.
outpost_arnstringThe Amazon Resource Name (ARN) of the Outpost on which the Capacity Reservation was created.
owner_idstringThe ID of the Amazon Web Services account that owns the Capacity Reservation.
placement_group_arnstringThe Amazon Resource Name (ARN) of the cluster placement group in which the Capacity Reservation was created. For more information, see Capacity Reservations for cluster placement groups in the Amazon EC2 User Guide.
reservation_typestringThe type of Capacity Reservation.
start_datestringThe date and time the Capacity Reservation was started.
statestringThe current state of the Capacity Reservation. A Capacity Reservation can be in one of the following states: active - The capacity is available for use. expired - The Capacity Reservation expired automatically at the date and time specified in your reservation request. The reserved capacity is no longer available for your use. cancelled - The Capacity Reservation was canceled. The reserved capacity is no longer available for your use. pending - The Capacity Reservation request was successful but the capacity provisioning is still pending. failed - The Capacity Reservation request has failed. A request can fail due to request parameters that are not valid, capacity constraints, or instance limit constraints. You can view a failed request for 60 minutes. scheduled - (Future-dated Capacity Reservations) The future-dated Capacity Reservation request was approved and the Capacity Reservation is scheduled for delivery on the requested start date. payment-pending - (Capacity Blocks) The upfront payment has not been processed yet. payment-failed - (Capacity Blocks) The upfront payment was not processed in the 12-hour time frame. Your Capacity Block was released. assessing - (Future-dated Capacity Reservations) Amazon EC2 is assessing your request for a future-dated Capacity Reservation. delayed - (Future-dated Capacity Reservations) Amazon EC2 encountered a delay in provisioning the requested future-dated Capacity Reservation. Amazon EC2 is unable to deliver the requested capacity by the requested start date and time. unsupported - (Future-dated Capacity Reservations) Amazon EC2 can't support the future-dated Capacity Reservation request due to capacity constraints. You can view unsupported requests for 30 days. The Capacity Reservation will not be delivered. cancelling - (Future-dated Capacity Reservations) The Capacity Reservation is being cancelled. Capacity has been released but charges continue for the commitment wind-down period. The reservation transitions to cancelled when the wind-down completes.
tagsstringAny tags assigned to the Capacity Reservation.
tenancystringIndicates the tenancy of the Capacity Reservation. A Capacity Reservation can have one of the following tenancy settings: default - The Capacity Reservation is created on hardware that is shared with other Amazon Web Services accounts. dedicated - The Capacity Reservation is created on single-tenant hardware that is dedicated to a single Amazon Web Services account.
total_instance_countintegerThe total number of instances for which the Capacity Reservation reserves capacity.
unused_reservation_billing_owner_idstringThe ID of the Amazon Web Services account to which billing of the unused capacity of the Capacity Reservation is assigned.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
describe_capacity_reservationsselectregionCapacityReservationId, NextToken, MaxResults, Filter, DryRunDescribes one or more of your Capacity Reservations. The results describe only the Capacity Reservations in the Amazon Web Services Region that you're currently using.
create_capacity_reservationinsertInstanceType, InstancePlatform, InstanceCount, regionClientToken, AvailabilityZone, AvailabilityZoneId, Tenancy, EbsOptimized, EphemeralStorage, EndDate, EndDateType, InstanceMatchCriteria, TagSpecifications, DryRun, OutpostArn, PlacementGroupArn, StartDate, CommitmentDuration, DeliveryPreferenceCreates a new Capacity Reservation with the specified attributes. Capacity Reservations enable you to reserve capacity for your Amazon EC2 instances in a specific Availability Zone for any duration. You can create a Capacity Reservation at any time, and you can choose when it starts. You can create a Capacity Reservation for immediate use or you can request a Capacity Reservation for a future date. For more information, see Reserve compute capacity with On-Demand Capacity Reservations in the Amazon EC2 User Guide. Your request to create a Capacity Reservation could fail if: Amazon EC2 does not have sufficient capacity. In this case, try again at a later time, try in a different Availability Zone, or request a smaller Capacity Reservation. If your workload is flexible across instance types and sizes, try with different instance attributes. The requested quantity exceeds your On-Demand Instance quota. In this case, increase your On-Demand Instance quota for the requested instance type and try again. For more information, see Amazon EC2 Service Quotas in the Amazon EC2 User Guide.
create_capacity_reservation_by_splittinginsertSourceCapacityReservationId, InstanceCount, regionDryRun, ClientToken, TagSpecificationCreate a new Capacity Reservation by splitting the capacity of the source Capacity Reservation. The new Capacity Reservation will have the same attributes as the source Capacity Reservation except for tags. The source Capacity Reservation must be active and owned by your Amazon Web Services account.
create_interruptible_capacity_reservation_allocationinsertCapacityReservationId, InstanceCount, regionClientToken, DryRun, TagSpecificationCreates an interruptible Capacity Reservation by specifying the number of unused instances you want to allocate from your source reservation. This helps you make unused capacity available for other workloads within your account while maintaining control to reclaim it.
associate_capacity_reservation_billing_ownerupdateCapacityReservationId, UnusedReservationBillingOwnerId, regionDryRunInitiates a request to assign billing of the unused capacity of a shared Capacity Reservation to a consumer account that is consolidated under the same Amazon Web Services organizations payer account. For more information, see Billing assignment for shared Amazon EC2 Capacity Reservations.
update_interruptible_capacity_reservation_allocationupdateCapacityReservationId, TargetInstanceCount, regionDryRunModifies the number of instances allocated to an interruptible reservation, allowing you to add more capacity or reclaim capacity to your source Capacity Reservation.
modify_capacity_reservationupdateCapacityReservationId, regionInstanceCount, EndDate, EndDateType, Accept, DryRun, AdditionalInfo, InstanceMatchCriteriaModifies a Capacity Reservation's capacity, instance eligibility, and the conditions under which it is to be released. You can't modify a Capacity Reservation's instance type, EBS optimization, platform, instance store settings, Availability Zone, or tenancy. If you need to modify any of these attributes, we recommend that you cancel the Capacity Reservation, and then create a new one with the required attributes. For more information, see Modify an active Capacity Reservation. The allowed modifications depend on the state of the Capacity Reservation: assessing or scheduled state - You can modify the tags only. pending state - You can't modify the Capacity Reservation in any way. active state but still within the commitment duration - You can't decrease the instance count or set an end date that is within the commitment duration. All other modifications are allowed. active state with no commitment duration or elapsed commitment duration - All modifications are allowed. expired, cancelled, unsupported, or failed state - You can't modify the Capacity Reservation in any way.
accept_capacity_reservation_billing_ownershipexecCapacityReservationId, regionDryRunAccepts a request to assign billing of the available capacity of a shared Capacity Reservation to your account. For more information, see Billing assignment for shared Amazon EC2 Capacity Reservations.
cancel_capacity_reservationexecCapacityReservationId, regionDryRun, ApplyCancellationCharges, QuoteIdCancels the specified Capacity Reservation, releases the reserved capacity, and changes the Capacity Reservation's state to cancelled. You can cancel a Capacity Reservation that is in the following states: assessing scheduled — requires a cancellation quote. Use CreateCapacityReservationCancellationQuote to generate a quote, then pass the quote ID with ApplyCancellationCharges set to commitment-wind-down. The cancellation charge depends on how close the reservation is to its start date. active and there is no commitment duration or the commitment duration has elapsed. active during the commitment duration — requires a cancellation quote. Use CreateCapacityReservationCancellationQuote to generate a quote, then pass the quote ID with ApplyCancellationCharges set to commitment-wind-down. The Capacity Reservation transitions to cancelling while charges are applied. delayed — the commitment duration is waived, so no cancellation charge applies. You can't modify or cancel a Capacity Block. For more information, see Capacity Blocks for ML. Instances running in the reserved capacity continue running until you stop them. Stopped instances that target the Capacity Reservation can no longer launch. Modify these instances to either target a different Capacity Reservation, launch On-Demand Instance capacity, or run in any open Capacity Reservation that has matching attributes and sufficient capacity.
disassociate_capacity_reservation_billing_ownerexecCapacityReservationId, UnusedReservationBillingOwnerId, regionDryRunCancels a pending request to assign billing of the unused capacity of a Capacity Reservation to a consumer account, or revokes a request that has already been accepted. For more information, see Billing assignment for shared Amazon EC2 Capacity Reservations.
reject_capacity_reservation_billing_ownershipexecCapacityReservationId, regionDryRunRejects a request to assign billing of the available capacity of a shared Capacity Reservation to your account. For more information, see Billing assignment for shared Amazon EC2 Capacity Reservations.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
CapacityReservationIdstringThe ID of the Capacity Reservation for which to reject the request.
InstanceCountintegerThe number of instances to allocate from your source reservation. You can only allocate available instances (also called unused capacity).
InstancePlatformstringThe type of operating system for which to reserve capacity.
InstanceTypestringThe instance type for which to reserve capacity. You can request future-dated Capacity Reservations for instance types in the C, M, R, I, T, and G instance families only. For more information, see Instance types in the Amazon EC2 User Guide.
SourceCapacityReservationIdstringThe ID of the Capacity Reservation from which you want to split the capacity.
TargetInstanceCountintegerThe new number of instances to allocate. Enter a higher number to add more capacity to share, or a lower number to reclaim capacity to your source Capacity Reservation.
UnusedReservationBillingOwnerIdstringThe ID of the consumer account to which the request was sent.
regionstringAWS region (default: us-east-1)
AcceptbooleanReserved. Capacity Reservations you have created are accepted by default.
AdditionalInfostringReserved for future use.
ApplyCancellationChargesstringSpecifies the cancellation charge type to apply when cancelling a future-dated Capacity Reservation during its commitment duration. Possible values include commitment-wind-down, which continues billing for the remaining commitment duration without delivering capacity.
AvailabilityZonestringThe Availability Zone in which to create the Capacity Reservation.
AvailabilityZoneIdstringThe ID of the Availability Zone in which to create the Capacity Reservation.
CapacityReservationIdarrayThe ID of the Capacity Reservation.
ClientTokenstringUnique, case-sensitive identifier that you provide to ensure the idempotency of the request.
CommitmentDurationinteger (int64)Required for future-dated Capacity Reservations only. To create a Capacity Reservation for immediate use, omit this parameter. Specify a commitment duration, in seconds, for the future-dated Capacity Reservation. The commitment duration is a minimum duration for which you commit to having the future-dated Capacity Reservation in the active state in your account after it has been delivered. For more information, see Commitment duration.
DeliveryPreferencestringRequired for future-dated Capacity Reservations only. To create a Capacity Reservation for immediate use, omit this parameter. Indicates that the requested capacity will be delivered in addition to any running instances or reserved capacity that you have in your account at the requested date and time. The only supported value is incremental.
DryRunbooleanChecks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.
EbsOptimizedbooleanIndicates whether the Capacity Reservation supports EBS-optimized instances. This optimization provides dedicated throughput to Amazon EBS and an optimized configuration stack to provide optimal I/O performance. This optimization isn't available with all instance types. Additional usage charges apply when using an EBS- optimized instance.
EndDatestring (date-time)The date and time at which the Capacity Reservation expires. When a Capacity Reservation expires, the reserved capacity is released and you can no longer launch instances into it. The Capacity Reservation's state changes to expired when it reaches its end date and time. The Capacity Reservation is cancelled within an hour from the specified time. For example, if you specify 5/31/2019, 13:30:55, the Capacity Reservation is guaranteed to end between 13:30:55 and 14:30:55 on 5/31/2019. You must provide an EndDate value if EndDateType is limited. Omit EndDate if EndDateType is unlimited.
EndDateTypestringIndicates the way in which the Capacity Reservation ends. A Capacity Reservation can have one of the following end types: unlimited - The Capacity Reservation remains active until you explicitly cancel it. Do not provide an EndDate value if EndDateType is unlimited. limited - The Capacity Reservation expires automatically at a specified date and time. You must provide an EndDate value if EndDateType is limited.
EphemeralStoragebooleanDeprecated.
FilterarrayOne or more filters. instance-type - The type of instance for which the Capacity Reservation reserves capacity. owner-id - The ID of the Amazon Web Services account that owns the Capacity Reservation. instance-platform - The type of operating system for which the Capacity Reservation reserves capacity. availability-zone - The Availability Zone of the Capacity Reservation. tenancy - Indicates the tenancy of the Capacity Reservation. A Capacity Reservation can have one of the following tenancy settings: default - The Capacity Reservation is created on hardware that is shared with other Amazon Web Services accounts. dedicated - The Capacity Reservation is created on single-tenant hardware that is dedicated to a single Amazon Web Services account. outpost-arn - The Amazon Resource Name (ARN) of the Outpost on which the Capacity Reservation was created. state - The current state of the Capacity Reservation. A Capacity Reservation can be in one of the following states: active- The Capacity Reservation is active and the capacity is available for your use. expired - The Capacity Reservation expired automatically at the date and time specified in your request. The reserved capacity is no longer available for your use. cancelled - The Capacity Reservation was cancelled. The reserved capacity is no longer available for your use. pending - The Capacity Reservation request was successful but the capacity provisioning is still pending. failed - The Capacity Reservation request has failed. A request might fail due to invalid request parameters, capacity constraints, or instance limit constraints. Failed requests are retained for 60 minutes. start-date - The date and time at which the Capacity Reservation was started. end-date - The date and time at which the Capacity Reservation expires. When a Capacity Reservation expires, the reserved capacity is released and you can no longer launch instances into it. The Capacity Reservation's state changes to expired when it reaches its end date and time. end-date-type - Indicates the way in which the Capacity Reservation ends. A Capacity Reservation can have one of the following end types: unlimited - The Capacity Reservation remains active until you explicitly cancel it. limited - The Capacity Reservation expires automatically at a specified date and time. instance-match-criteria - Indicates the type of instance launches that the Capacity Reservation accepts. The options include: open - The Capacity Reservation accepts all instances that have matching attributes (instance type, platform, and Availability Zone). Instances that have matching attributes launch into the Capacity Reservation automatically without specifying any additional parameters. targeted - The Capacity Reservation only accepts instances that have matching attributes (instance type, platform, and Availability Zone), and explicitly target the Capacity Reservation. This ensures that only permitted instances can use the reserved capacity. placement-group-arn - The ARN of the cluster placement group in which the Capacity Reservation was created.
InstanceCountintegerThe number of instances for which to reserve capacity. The number of instances can't be increased or decreased by more than 1000 in a single request.
InstanceMatchCriteriastringThe matching criteria (instance eligibility) that you want to use in the modified Capacity Reservation. If you change the instance eligibility of an existing Capacity Reservation from targeted to open, any running instances that match the attributes of the Capacity Reservation, have the CapacityReservationPreference set to open, and are not yet running in the Capacity Reservation, will automatically use the modified Capacity Reservation. To modify the instance eligibility, the Capacity Reservation must be completely idle (zero usage).
MaxResultsintegerThe maximum number of items to return for this request. To get the next page of items, make another request with the token returned in the output. For more information, see Pagination.
NextTokenstringThe token to use to retrieve the next page of results.
OutpostArnstringNot supported for future-dated Capacity Reservations. The Amazon Resource Name (ARN) of the Outpost on which to create the Capacity Reservation.
PlacementGroupArnstringNot supported for future-dated Capacity Reservations. The Amazon Resource Name (ARN) of the cluster placement group in which to create the Capacity Reservation. For more information, see Capacity Reservations for cluster placement groups in the Amazon EC2 User Guide.
QuoteIdstringThe ID of the cancellation quote to use for the cancellation. You can generate a cancellation quote by using the CreateCapacityReservationCancellationQuote action. The cancellation quote must be in an active state.
StartDatestring (date-time)Required for future-dated Capacity Reservations only. To create a Capacity Reservation for immediate use, omit this parameter. The date and time at which the future-dated Capacity Reservation should become available for use, in the ISO8601 format in the UTC time zone (YYYY-MM-DDThh:mm:ss.sssZ). You can request a future-dated Capacity Reservation between 5 and 120 days in advance.
TagSpecificationarrayThe tags to apply to the interruptible Capacity Reservation during creation.
TagSpecificationsarrayThe tags to apply to the Capacity Reservation during launch.
TenancystringIndicates the tenancy of the Capacity Reservation. A Capacity Reservation can have one of the following tenancy settings: default - The Capacity Reservation is created on hardware that is shared with other Amazon Web Services accounts. dedicated - The Capacity Reservation is created on single-tenant hardware that is dedicated to a single Amazon Web Services account.

SELECT examples

Describes one or more of your Capacity Reservations. The results describe only the Capacity Reservations in the Amazon Web Services Region that you're currently using.

SELECT
availability_zone,
availability_zone_id,
available_instance_count,
capacity_allocations,
capacity_block_id,
capacity_reservation_arn,
capacity_reservation_fleet_id,
capacity_reservation_id,
commitment_info,
create_date,
delivery_preference,
ebs_optimized,
end_date,
end_date_type,
ephemeral_storage,
instance_match_criteria,
instance_platform,
instance_type,
interruptible,
interruptible_capacity_allocation,
interruption_info,
outpost_arn,
owner_id,
placement_group_arn,
reservation_type,
start_date,
state,
tags,
tenancy,
total_instance_count,
unused_reservation_billing_owner_id
FROM aws.ec2.capacity_reservations
WHERE region = '{{ region }}' -- required
AND CapacityReservationId = '{{ CapacityReservationId }}'
AND NextToken = '{{ NextToken }}'
AND MaxResults = '{{ MaxResults }}'
AND Filter = '{{ Filter }}'
AND DryRun = '{{ DryRun }}'
;

INSERT examples

Creates a new Capacity Reservation with the specified attributes. Capacity Reservations enable you to reserve capacity for your Amazon EC2 instances in a specific Availability Zone for any duration. You can create a Capacity Reservation at any time, and you can choose when it starts. You can create a Capacity Reservation for immediate use or you can request a Capacity Reservation for a future date. For more information, see Reserve compute capacity with On-Demand Capacity Reservations in the Amazon EC2 User Guide. Your request to create a Capacity Reservation could fail if: Amazon EC2 does not have sufficient capacity. In this case, try again at a later time, try in a different Availability Zone, or request a smaller Capacity Reservation. If your workload is flexible across instance types and sizes, try with different instance attributes. The requested quantity exceeds your On-Demand Instance quota. In this case, increase your On-Demand Instance quota for the requested instance type and try again. For more information, see Amazon EC2 Service Quotas in the Amazon EC2 User Guide.

INSERT INTO aws.ec2.capacity_reservations (
InstanceType,
InstancePlatform,
InstanceCount,
region,
ClientToken,
AvailabilityZone,
AvailabilityZoneId,
Tenancy,
EbsOptimized,
EphemeralStorage,
EndDate,
EndDateType,
InstanceMatchCriteria,
TagSpecifications,
DryRun,
OutpostArn,
PlacementGroupArn,
StartDate,
CommitmentDuration,
DeliveryPreference
)
SELECT
'{{ InstanceType }}',
'{{ InstancePlatform }}',
'{{ InstanceCount }}',
'{{ region }}',
'{{ ClientToken }}',
'{{ AvailabilityZone }}',
'{{ AvailabilityZoneId }}',
'{{ Tenancy }}',
'{{ EbsOptimized }}',
'{{ EphemeralStorage }}',
'{{ EndDate }}',
'{{ EndDateType }}',
'{{ InstanceMatchCriteria }}',
'{{ TagSpecifications }}',
'{{ DryRun }}',
'{{ OutpostArn }}',
'{{ PlacementGroupArn }}',
'{{ StartDate }}',
'{{ CommitmentDuration }}',
'{{ DeliveryPreference }}'
RETURNING
availability_zone,
availability_zone_id,
available_instance_count,
capacity_allocations,
capacity_block_id,
capacity_reservation_arn,
capacity_reservation_fleet_id,
capacity_reservation_id,
commitment_info,
create_date,
delivery_preference,
ebs_optimized,
end_date,
end_date_type,
ephemeral_storage,
instance_match_criteria,
instance_platform,
instance_type,
interruptible,
interruptible_capacity_allocation,
interruption_info,
outpost_arn,
owner_id,
placement_group_arn,
reservation_type,
start_date,
state,
tags,
tenancy,
total_instance_count,
unused_reservation_billing_owner_id
;

UPDATE examples

Initiates a request to assign billing of the unused capacity of a shared Capacity Reservation to a consumer account that is consolidated under the same Amazon Web Services organizations payer account. For more information, see Billing assignment for shared Amazon EC2 Capacity Reservations.

UPDATE aws.ec2.capacity_reservations
SET
-- No updatable properties
WHERE
CapacityReservationId = '{{ CapacityReservationId }}' --required
AND UnusedReservationBillingOwnerId = '{{ UnusedReservationBillingOwnerId }}' --required
AND region = '{{ region }}' --required
AND DryRun = {{ DryRun}}
RETURNING
return;

Lifecycle Methods

Accepts a request to assign billing of the available capacity of a shared Capacity Reservation to your account. For more information, see Billing assignment for shared Amazon EC2 Capacity Reservations.

EXEC aws.ec2.capacity_reservations.accept_capacity_reservation_billing_ownership
@CapacityReservationId='{{ CapacityReservationId }}' --required,
@region='{{ region }}' --required,
@DryRun={{ DryRun }}
;