Skip to content

create_interruptible_capacity_reservation_allocation

create_interruptible_capacity_reservation_allocation(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    capacity_reservation_id: Optional[CapacityReservationId] = None,
    instance_count: Optional[Integer] = None,
    client_token: Optional[String] = None,
    dry_run: Optional[Boolean] = None,
    tag_specifications: Optional[TagSpecificationList] = None,
    zero_size_preference: Optional[ZeroSizePreference] = None,
) -> CreateInterruptibleCapacityReservationAllocationResult

Creates 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.

Parameters:

  • capacity_reservation_id (Optional[CapacityReservationId], default: None ) –

    The ID of the source Capacity Reservation from which to create the interruptible Capacity Reservation. Your Capacity Reservation must be in active state with no end date set and have available capacity for allocation.

  • instance_count (Optional[Integer], default: None ) –

    The number of instances to allocate from your source reservation. You can only allocate available instances (also called unused capacity).

  • client_token (Optional[String], default: None ) –

    Unique, case-sensitive identifier that you provide to ensure the idempotency of the request.

  • 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.

  • tag_specifications (Optional[TagSpecificationList], default: None ) –

    The tags to apply to the interruptible Capacity Reservation during creation.

  • zero_size_preference (Optional[ZeroSizePreference], default: None ) –

    Specifies the behavior for the interruptible Capacity Reservation when you reduce its allocation to zero instances. Specify retain to keep the interruptible Capacity Reservation active at zero capacity so that you can allocate instances to it again later. Specify default to cancel the interruptible Capacity Reservation and return the capacity to your source Capacity Reservation. The default value is default.

Raises:

Source code in docs_src/capo_ec2/_services/ec2.py
def create_interruptible_capacity_reservation_allocation(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    capacity_reservation_id: Optional[
        "capo_ec2.types.capacity_reservation_id.CapacityReservationId"
    ] = None,
    instance_count: Optional["capo_ec2.types.integer.Integer"] = None,
    client_token: Optional["capo_ec2.types.string.String"] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    tag_specifications: Optional[
        "capo_ec2.types.tag_specification_list.TagSpecificationList"
    ] = None,
    zero_size_preference: Optional[
        "capo_ec2.types.zero_size_preference.ZeroSizePreference"
    ] = None,
) -> "capo_ec2.types.create_interruptible_capacity_reservation_allocation_result.CreateInterruptibleCapacityReservationAllocationResult":
    """<p> Creates 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. </p>

    Args:
        capacity_reservation_id: <p> The ID of the source Capacity Reservation from which to create the interruptible Capacity Reservation. Your Capacity Reservation must be in active state with no end date set and have available capacity for allocation. </p>
        instance_count: <p> The number of instances to allocate from your source reservation. You can only allocate available instances (also called unused capacity). </p>
        client_token: <p> Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. </p>
        dry_run: <p> Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. </p>
        tag_specifications: <p> The tags to apply to the interruptible Capacity Reservation during creation. </p>
        zero_size_preference: <p> Specifies the behavior for the interruptible Capacity Reservation when you reduce its allocation to zero instances. Specify <code>retain</code> to keep the interruptible Capacity Reservation active at zero capacity so that you can allocate instances to it again later. Specify <code>default</code> to cancel the interruptible Capacity Reservation and return the capacity to your source Capacity Reservation. The default value is <code>default</code>. </p>

    Raises:
        capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_ec2.types.create_interruptible_capacity_reservation_allocation_request.CreateInterruptibleCapacityReservationAllocationRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.create_interruptible_capacity_reservation_allocation_result.CreateInterruptibleCapacityReservationAllocationResult"
    ]:
        import capo_ec2._operations.amazon_ec2.create_interruptible_capacity_reservation_allocation

        output, http_response = (
            capo_ec2._operations.amazon_ec2.create_interruptible_capacity_reservation_allocation.create_interruptible_capacity_reservation_allocation(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateInterruptibleCapacityReservationAllocation"),
    )
    input_: capo_ec2.types.create_interruptible_capacity_reservation_allocation_request.CreateInterruptibleCapacityReservationAllocationRequest = {}
    if capacity_reservation_id is not None:
        input_["capacity_reservation_id"] = capacity_reservation_id
    if instance_count is not None:
        input_["instance_count"] = instance_count
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if tag_specifications is not None:
        input_["tag_specifications"] = tag_specifications
    if zero_size_preference is not None:
        input_["zero_size_preference"] = zero_size_preference

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output