create_capacity_reservation
async
¶
create_capacity_reservation(
*,
config_overrides: Optional[AsyncEC2ClientConfig] = None,
client_token: Optional[String] = None,
instance_type: Optional[String] = None,
instance_platform: Optional[CapacityReservationInstancePlatform] = None,
availability_zone: Optional[AvailabilityZoneName] = None,
availability_zone_id: Optional[AvailabilityZoneId] = None,
tenancy: Optional[CapacityReservationTenancy] = None,
instance_count: Optional[Integer] = None,
ebs_optimized: Optional[Boolean] = None,
ephemeral_storage: Optional[Boolean] = None,
end_date: Optional[DateTime] = None,
end_date_type: Optional[EndDateType] = None,
instance_match_criteria: Optional[InstanceMatchCriteria] = None,
tag_specifications: Optional[TagSpecificationList] = None,
dry_run: Optional[Boolean] = None,
outpost_arn: Optional[OutpostArn] = None,
placement_group_arn: Optional[PlacementGroupArn] = None,
start_date: Optional[MillisecondDateTime] = None,
commitment_duration: Optional[CapacityReservationCommitmentDuration] = None,
delivery_preference: Optional[CapacityReservationDeliveryPreference] = None,
) -> CreateCapacityReservationResult
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.
Parameters:
-
client_token(Optional[String], default:None) –Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see Ensure Idempotency.
-
instance_type(Optional[String], default:None) –The 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.
-
instance_platform(Optional[CapacityReservationInstancePlatform], default:None) –The type of operating system for which to reserve capacity.
-
availability_zone(Optional[AvailabilityZoneName], default:None) –The Availability Zone in which to create the Capacity Reservation.
-
availability_zone_id(Optional[AvailabilityZoneId], default:None) –The ID of the Availability Zone in which to create the Capacity Reservation.
-
tenancy(Optional[CapacityReservationTenancy], default:None) –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.
-
-
instance_count(Optional[Integer], default:None) –The number of instances for which to reserve capacity.
You can request future-dated Capacity Reservations for an instance count with a minimum of 32 vCPUs. For example, if you request a future-dated Capacity Reservation for
m5.xlargeinstances, you must request at least 8 instances (8 * m5.xlarge = 32 vCPUs).Valid range: 1 - 1000
-
ebs_optimized(Optional[Boolean], default:None) –Indicates 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.
-
ephemeral_storage(Optional[Boolean], default:None) –Deprecated.
-
end_date(Optional[DateTime], default:None) –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
expiredwhen it reaches its end date and time.You must provide an
EndDatevalue ifEndDateTypeislimited. OmitEndDateifEndDateTypeisunlimited.If the
EndDateTypeislimited, 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.If you are requesting a future-dated Capacity Reservation, you can't specify an end date and time that is within the commitment duration.
-
end_date_type(Optional[EndDateType], default:None) –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. Do not provide anEndDateif theEndDateTypeisunlimited. -
limited- The Capacity Reservation expires automatically at a specified date and time. You must provide anEndDatevalue if theEndDateTypevalue islimited.
-
-
instance_match_criteria(Optional[InstanceMatchCriteria], default:None) –Indicates the type of instance launches that the Capacity Reservation accepts. The options include:
-
open- The Capacity Reservation automatically matches all instances that have matching attributes (instance type, platform, and Availability Zone). Instances that have matching attributes run in 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.
If you are requesting a future-dated Capacity Reservation, you must specify
targeted.Default:
open -
-
tag_specifications(Optional[TagSpecificationList], default:None) –The tags to apply to the Capacity Reservation during launch.
-
dry_run(Optional[Boolean], default:None) –Checks 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 isUnauthorizedOperation. -
outpost_arn(Optional[OutpostArn], default:None) –Not supported for future-dated Capacity Reservations.
The Amazon Resource Name (ARN) of the Outpost on which to create the Capacity Reservation.
-
placement_group_arn(Optional[PlacementGroupArn], default:None) –Not 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.
-
start_date(Optional[MillisecondDateTime], default:None) –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).ss.sssZ
You can request a future-dated Capacity Reservation between 5 and 120 days in advance.
-
commitment_duration(Optional[CapacityReservationCommitmentDuration], default:None) –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
activestate in your account after it has been delivered.For more information, see Commitment duration.
-
delivery_preference(Optional[CapacityReservationDeliveryPreference], default:None) –Required 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.
Raises:
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_ec2/_services/async_ec2.py
7121 7122 7123 7124 7125 7126 7127 7128 7129 7130 7131 7132 7133 7134 7135 7136 7137 7138 7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 7170 7171 7172 7173 7174 7175 7176 7177 7178 7179 7180 7181 7182 7183 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 7231 7232 7233 7234 7235 7236 7237 7238 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 | |